Class DefaultTaskExecutionService
java.lang.Object
org.springframework.cloud.dataflow.server.service.impl.DefaultTaskExecutionService
- All Implemented Interfaces:
TaskExecutionService
@Transactional
public class DefaultTaskExecutionService
extends Object
implements TaskExecutionService
Default implementation of the
TaskExecutionService
interface. Provide service
methods for Tasks.- Author:
- Michael Minella, Marius Bogoevici, Glenn Renfro, Mark Fisher, Janne Valkealahti, Gunnar Hillert, Thomas Risberg, Ilayaperumal Gopinathan, Michael Wirth, David Turanski, Daniel Serleg, Corneil du Plessis
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefaultTaskExecutionService
(PropertyResolver propertyResolver, LauncherRepository launcherRepository, org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService, org.springframework.cloud.task.repository.TaskRepository taskRepository, TaskExecutionInfoService taskExecutionInfoService, TaskDeploymentRepository taskDeploymentRepository, TaskDefinitionRepository taskDefinitionRepository, TaskExecutionCreationService taskExecutionRepositoryService, TaskAppDeploymentRequestCreator taskAppDeploymentRequestCreator, DataflowTaskExplorer taskExplorer, DataflowTaskExecutionDao dataflowTaskExecutionDao, DataflowTaskExecutionMetadataDao dataflowTaskExecutionMetadataDao, DataflowTaskExecutionQueryDao dataflowTaskExecutionQueryDao, org.springframework.cloud.common.security.core.support.OAuth2TokenUtilsService oauth2TokenUtilsService, TaskSaveService taskSaveService, TaskConfigurationProperties taskConfigurationProperties, ComposedTaskRunnerConfigurationProperties composedTaskRunnerConfigurationProperties) Initializes theDefaultTaskExecutionService
. -
Method Summary
Modifier and TypeMethodDescriptionexecuteTask
(String taskName, Map<String, String> taskDeploymentProperties, List<String> commandLineArgs) Launch a task.Retrieve the TaskManifest for the execution id providedfindTaskManifestByIds
(Set<Long> ids) getAllTaskExecutionIds
(boolean onlyCompleted, String taskName) Returns all the task execution IDs with the option to include only the completed task executions.getAllTaskExecutionsCount
(boolean onlyCompleted, String taskName) Returns the count of all the task execution IDs with the option to include only the completed task executions.getAllTaskExecutionsCount
(boolean onlyCompleted, String taskName, Integer days) Returns the count of all the task execution IDs with the option to include only the completed task executions.Return the log content of the task execution identified by the given task deployment ID (external execution ID).void
setAutoCreateTaskDefinitions
(boolean autoCreateTaskDefinitions) void
stopTaskExecution
(Set<Long> ids) Request the platform to stop the task executions for the ids provided.void
stopTaskExecution
(Set<Long> ids, String platform) Request the platform to stop the task executions for the ids provided.protected void
updateExternalExecutionId
(long executionId, String taskLaunchId)
-
Field Details
-
TASK_DEFINITION_DSL_TEXT
- See Also:
-
TASK_DEPLOYMENT_PROPERTIES
- See Also:
-
COMMAND_LINE_ARGS
- See Also:
-
TASK_PLATFORM_NAME
- See Also:
-
auditRecordService
protected final org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService
-
-
Constructor Details
-
DefaultTaskExecutionService
public DefaultTaskExecutionService(PropertyResolver propertyResolver, LauncherRepository launcherRepository, org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService, org.springframework.cloud.task.repository.TaskRepository taskRepository, TaskExecutionInfoService taskExecutionInfoService, TaskDeploymentRepository taskDeploymentRepository, TaskDefinitionRepository taskDefinitionRepository, TaskExecutionCreationService taskExecutionRepositoryService, TaskAppDeploymentRequestCreator taskAppDeploymentRequestCreator, DataflowTaskExplorer taskExplorer, DataflowTaskExecutionDao dataflowTaskExecutionDao, DataflowTaskExecutionMetadataDao dataflowTaskExecutionMetadataDao, DataflowTaskExecutionQueryDao dataflowTaskExecutionQueryDao, org.springframework.cloud.common.security.core.support.OAuth2TokenUtilsService oauth2TokenUtilsService, TaskSaveService taskSaveService, TaskConfigurationProperties taskConfigurationProperties, ComposedTaskRunnerConfigurationProperties composedTaskRunnerConfigurationProperties) Initializes theDefaultTaskExecutionService
.- Parameters:
propertyResolver
- the spring application contextlauncherRepository
- the repository of task launcher used to launch task apps.auditRecordService
- the audit record servicetaskRepository
- the repository to use for accessing and updating task executionstaskExecutionInfoService
- the task execution info servicetaskDeploymentRepository
- the repository to track task deploymenttaskDefinitionRepository
- the repository to query the task definitiontaskExecutionRepositoryService
- the service used to create the task executiontaskAppDeploymentRequestCreator
- the task app deployment request creatortaskExplorer
- the task explorerdataflowTaskExecutionDao
- the dataflow task execution daodataflowTaskExecutionMetadataDao
- repository used to manipulate task manifestsdataflowTaskExecutionQueryDao
- repository to query aggregate task execution data.oauth2TokenUtilsService
- the oauth2 token servertaskSaveService
- the task save servicetaskConfigurationProperties
- task configuration propertiescomposedTaskRunnerConfigurationProperties
- properties used to configure the composed task runner
-
-
Method Details
-
executeTask
public LaunchResponse executeTask(String taskName, Map<String, String> taskDeploymentProperties, List<String> commandLineArgs) Launch a task.- Specified by:
executeTask
in interfaceTaskExecutionService
- Parameters:
taskName
- Name of the task definition or registered task application. If a task definition does not exist, one will be created if `autoCreateTask-Definitions` is true. Must not be null or empty.taskDeploymentProperties
- Optional deployment properties. Must not be null.commandLineArgs
- Optional runtime commandline argument- Returns:
- the task execution ID.
-
getLog
Return the log content of the task execution identified by the given task deployment ID (external execution ID). In case of concurrent task executions on Cloud Foundry, the logs of all the concurrent executions are displayed. Also, on Cloud Foundry, the task execution log is retrieved only for the latest execution that matches the given deployment ID (external execution ID).- Specified by:
getLog
in interfaceTaskExecutionService
- Parameters:
platformName
- the platformtaskId
- the deploymentID (externalExecutionId) associated with the task execution.- Returns:
- the log of the specified task.
-
stopTaskExecution
Description copied from interface:TaskExecutionService
Request the platform to stop the task executions for the ids provided.- Specified by:
stopTaskExecution
in interfaceTaskExecutionService
- Parameters:
ids
- a set of ids for the task executions to be stopped.
-
stopTaskExecution
Description copied from interface:TaskExecutionService
Request the platform to stop the task executions for the ids provided.- Specified by:
stopTaskExecution
in interfaceTaskExecutionService
- Parameters:
ids
- a set of ids for the task executions to be stopped.platform
- The name of the platform where the tasks are executing.
-
findTaskManifestById
Description copied from interface:TaskExecutionService
Retrieve the TaskManifest for the execution id provided- Specified by:
findTaskManifestById
in interfaceTaskExecutionService
- Parameters:
id
- task exectution id- Returns:
TaskManifest
or null if not found.
-
findTaskManifestByIds
- Specified by:
findTaskManifestByIds
in interfaceTaskExecutionService
- Parameters:
ids
- A set of task execution ids.- Returns:
- collection of manifests mapped by the relevant task execution id.
-
setAutoCreateTaskDefinitions
public void setAutoCreateTaskDefinitions(boolean autoCreateTaskDefinitions) -
updateExternalExecutionId
-
getAllTaskExecutionIds
Description copied from interface:TaskExecutionService
Returns all the task execution IDs with the option to include only the completed task executions.- Specified by:
getAllTaskExecutionIds
in interfaceTaskExecutionService
- Parameters:
onlyCompleted
- filter by completed task executionstaskName
- the task name, if null then retrieve all the tasks- Returns:
- the set of execution ids.
-
getAllTaskExecutionsCount
Description copied from interface:TaskExecutionService
Returns the count of all the task execution IDs with the option to include only the completed task executions.- Specified by:
getAllTaskExecutionsCount
in interfaceTaskExecutionService
- Parameters:
onlyCompleted
- whether to include only completed task executionstaskName
- the task name, if null then retrieve all the tasks- Returns:
- the number of executions
-
getAllTaskExecutionsCount
Description copied from interface:TaskExecutionService
Returns the count of all the task execution IDs with the option to include only the completed task executions.- Specified by:
getAllTaskExecutionsCount
in interfaceTaskExecutionService
- Parameters:
onlyCompleted
- whether to include only completed task executions (ignored whenincludeTasksEndedMinDaysAgo
is specified)taskName
- the task name, if null then retrieve all the tasksdays
- only include tasks that have ended at least this many days ago- Returns:
- the number of executions, 0 if no data, never null
-