Class SimpleTaskExplorer

java.lang.Object
org.springframework.cloud.task.repository.support.SimpleTaskExplorer
All Implemented Interfaces:
TaskExplorer

public class SimpleTaskExplorer extends Object implements TaskExplorer
TaskExplorer for that gathers task information from a task repository.
Author:
Glenn Renfro, Michael Minella, Gunnar Hillert, David Turanski
  • Constructor Details

  • Method Details

    • getTaskExecution

      public TaskExecution getTaskExecution(long executionId)
      Description copied from interface: TaskExplorer
      Retrieve a TaskExecution by its id.
      Specified by:
      getTaskExecution in interface TaskExplorer
      Parameters:
      executionId - the task execution id
      Returns:
      the TaskExecution with this id, or null if not found
    • findRunningTaskExecutions

      public org.springframework.data.domain.Page<TaskExecution> findRunningTaskExecutions(String taskName, org.springframework.data.domain.Pageable pageable)
      Description copied from interface: TaskExplorer
      Retrieve a collection of taskExecutions that have the task name provided.
      Specified by:
      findRunningTaskExecutions in interface TaskExplorer
      Parameters:
      taskName - the name of the task
      pageable - the constraints for the search
      Returns:
      the set of running executions for tasks with the specified name
    • getTaskNames

      public List<String> getTaskNames()
      Description copied from interface: TaskExplorer
      Retrieve a list of available task names.
      Specified by:
      getTaskNames in interface TaskExplorer
      Returns:
      the set of task names that have been executed
    • getTaskExecutionCountByTaskName

      public long getTaskExecutionCountByTaskName(String taskName)
      Description copied from interface: TaskExplorer
      Get number of executions for a taskName.
      Specified by:
      getTaskExecutionCountByTaskName in interface TaskExplorer
      Parameters:
      taskName - the name of the task to be searched
      Returns:
      the number of running tasks that have the taskname specified
    • getTaskExecutionCount

      public long getTaskExecutionCount()
      Description copied from interface: TaskExplorer
      Retrieves current number of task executions.
      Specified by:
      getTaskExecutionCount in interface TaskExplorer
      Returns:
      current number of task executions.
    • getRunningTaskExecutionCount

      public long getRunningTaskExecutionCount()
      Description copied from interface: TaskExplorer
      Retrieves current number of running task executions.
      Specified by:
      getRunningTaskExecutionCount in interface TaskExplorer
      Returns:
      current number of running task executions.
    • findTaskExecutionsByName

      public org.springframework.data.domain.Page<TaskExecution> findTaskExecutionsByName(String taskName, org.springframework.data.domain.Pageable pageable)
      Description copied from interface: TaskExplorer
      Get a collection/page of executions.
      Specified by:
      findTaskExecutionsByName in interface TaskExplorer
      Parameters:
      taskName - the name of the task to be searched
      pageable - the constraints for the search
      Returns:
      list of task executions
    • findAll

      public org.springframework.data.domain.Page<TaskExecution> findAll(org.springframework.data.domain.Pageable pageable)
      Description copied from interface: TaskExplorer
      Retrieves all the task executions within the pageable constraints sorted by start date descending, taskExecution id descending.
      Specified by:
      findAll in interface TaskExplorer
      Parameters:
      pageable - the constraints for the search
      Returns:
      page containing the results from the search
    • getTaskExecutionIdByJobExecutionId

      public Long getTaskExecutionIdByJobExecutionId(long jobExecutionId)
      Description copied from interface: TaskExplorer
      Returns the id of the TaskExecution that the requested Spring Batch job execution was executed within the context of. Returns null if none were found.
      Specified by:
      getTaskExecutionIdByJobExecutionId in interface TaskExplorer
      Parameters:
      jobExecutionId - the id of the JobExecution
      Returns:
      the id of the TaskExecution
    • getJobExecutionIdsByTaskExecutionId

      public Set<Long> getJobExecutionIdsByTaskExecutionId(long taskExecutionId)
      Description copied from interface: TaskExplorer
      Returns a Set of JobExecution ids for the jobs that were executed within the scope of the requested task.
      Specified by:
      getJobExecutionIdsByTaskExecutionId in interface TaskExplorer
      Parameters:
      taskExecutionId - id of the TaskExecution
      Returns:
      a Set of the ids of the job executions executed within the task.
    • getLatestTaskExecutionsByTaskNames

      public List<TaskExecution> getLatestTaskExecutionsByTaskNames(String... taskNames)
      Description copied from interface: TaskExplorer
      Returns a List of the latest TaskExecution for 1 or more task names. Latest is defined by the most recent start time. A TaskExecution does not have to be finished (The results may including pending TaskExecutions). It is theoretically possible that a TaskExecution with the same name to have more than 1 TaskExecution for the exact same start time. In that case the TaskExecution with the highest Task Execution ID is returned. This method will not consider end times in its calculations. Thus, when a task execution A starts after task execution B but finishes BEFORE task execution A, then task execution B is being returned.
      Specified by:
      getLatestTaskExecutionsByTaskNames in interface TaskExplorer
      Parameters:
      taskNames - At least 1 task name must be provided
      Returns:
      List of TaskExecutions. May be empty but never null.
    • getLatestTaskExecutionForTaskName

      public TaskExecution getLatestTaskExecutionForTaskName(String taskName)
      Description copied from interface: TaskExplorer
      Returns the latest task execution for a given task name. Will ultimately apply the same algorithm underneath as TaskExplorer.getLatestTaskExecutionsByTaskNames(String...) but will only return a single result.
      Specified by:
      getLatestTaskExecutionForTaskName in interface TaskExplorer
      Parameters:
      taskName - Must not be null or empty
      Returns:
      The latest Task Execution or null
      See Also: