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 Details

    • TASK_DEFINITION_DSL_TEXT

      public static final String TASK_DEFINITION_DSL_TEXT
      See Also:
    • TASK_DEPLOYMENT_PROPERTIES

      public static final String TASK_DEPLOYMENT_PROPERTIES
      See Also:
    • COMMAND_LINE_ARGS

      public static final String COMMAND_LINE_ARGS
      See Also:
    • TASK_PLATFORM_NAME

      public static final String 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)
      Parameters:
      propertyResolver - the spring application context
      launcherRepository - the repository of task launcher used to launch task apps.
      auditRecordService - the audit record service
      taskRepository - the repository to use for accessing and updating task executions
      taskExecutionInfoService - the task execution info service
      taskDeploymentRepository - the repository to track task deployment
      taskDefinitionRepository - the repository to query the task definition
      taskExecutionRepositoryService - the service used to create the task execution
      taskAppDeploymentRequestCreator - the task app deployment request creator
      taskExplorer - the task explorer
      dataflowTaskExecutionDao - the dataflow task execution dao
      dataflowTaskExecutionMetadataDao - repository used to manipulate task manifests
      dataflowTaskExecutionQueryDao - repository to query aggregate task execution data.
      oauth2TokenUtilsService - the oauth2 token server
      taskSaveService - the task save service
      taskConfigurationProperties - task configuration properties
      composedTaskRunnerConfigurationProperties - 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 interface TaskExecutionService
      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

      public String getLog(String platformName, String taskId)
      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 interface TaskExecutionService
      Parameters:
      platformName - the platform
      taskId - the deploymentID (externalExecutionId) associated with the task execution.
      Returns:
      the log of the specified task.
    • stopTaskExecution

      public void stopTaskExecution(Set<Long> ids)
      Description copied from interface: TaskExecutionService
      Request the platform to stop the task executions for the ids provided.
      Specified by:
      stopTaskExecution in interface TaskExecutionService
      Parameters:
      ids - a set of ids for the task executions to be stopped.
    • stopTaskExecution

      public void stopTaskExecution(Set<Long> ids, String platform)
      Description copied from interface: TaskExecutionService
      Request the platform to stop the task executions for the ids provided.
      Specified by:
      stopTaskExecution in interface TaskExecutionService
      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

      public TaskManifest findTaskManifestById(Long id)
      Description copied from interface: TaskExecutionService
      Retrieve the TaskManifest for the execution id provided
      Specified by:
      findTaskManifestById in interface TaskExecutionService
      Parameters:
      id - task exectution id
      Returns:
      TaskManifest or null if not found.
    • findTaskManifestByIds

      public Map<Long,TaskManifest> findTaskManifestByIds(Set<Long> ids)
      Specified by:
      findTaskManifestByIds in interface TaskExecutionService
      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

      protected void updateExternalExecutionId(long executionId, String taskLaunchId)
    • getAllTaskExecutionIds

      public Set<Long> getAllTaskExecutionIds(boolean onlyCompleted, String taskName)
      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 interface TaskExecutionService
      Parameters:
      onlyCompleted - filter by completed task executions
      taskName - the task name, if null then retrieve all the tasks
      Returns:
      the set of execution ids.
    • getAllTaskExecutionsCount

      public Integer getAllTaskExecutionsCount(boolean onlyCompleted, String taskName)
      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 interface TaskExecutionService
      Parameters:
      onlyCompleted - whether to include only completed task executions
      taskName - the task name, if null then retrieve all the tasks
      Returns:
      the number of executions
    • getAllTaskExecutionsCount

      public Integer getAllTaskExecutionsCount(boolean onlyCompleted, String taskName, Integer days)
      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 interface TaskExecutionService
      Parameters:
      onlyCompleted - whether to include only completed task executions (ignored when includeTasksEndedMinDaysAgo is specified)
      taskName - the task name, if null then retrieve all the tasks
      days - only include tasks that have ended at least this many days ago
      Returns:
      the number of executions, 0 if no data, never null