Interface TaskExecutionDao

All Known Implementing Classes:
JdbcTaskExecutionDao, MapTaskExecutionDao

public interface TaskExecutionDao
Data Access Object for task executions.
Author:
Glenn Renfro, Gunnar Hillert, David Turanski
  • Method Details

    • createTaskExecution

      TaskExecution createTaskExecution(String taskName, Date startTime, List<String> arguments, String externalExecutionId)
      Save a new TaskExecution.
      Parameters:
      taskName - the name that associated with the task execution.
      startTime - the time task began.
      arguments - list of key/value pairs that configure the task.
      externalExecutionId - id assigned to the task by the platform
      Returns:
      A fully qualified TaskExecution instance.
    • createTaskExecution

      TaskExecution createTaskExecution(String taskName, Date startTime, List<String> arguments, String externalExecutionId, Long parentExecutionId)
      Save a new TaskExecution.
      Parameters:
      taskName - the name that associated with the task execution.
      startTime - the time task began.
      arguments - list of key/value pairs that configure the task.
      externalExecutionId - id assigned to the task by the platform
      parentExecutionId - the parent task execution id.
      Returns:
      A fully qualified TaskExecution instance.
      Since:
      1.2.0
    • startTaskExecution

      TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List<String> arguments, String externalExecutionId)
      Update and existing TaskExecution to mark it as started.
      Parameters:
      executionId - the id of the taskExecution to be updated.
      taskName - the name that associated with the task execution.
      startTime - the time task began.
      arguments - list of key/value pairs that configure the task.
      externalExecutionId - id assigned to the task by the platform
      Returns:
      A TaskExecution containing the information available at task execution start.
      Since:
      1.1.0
    • startTaskExecution

      TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List<String> arguments, String externalExecutionId, Long parentExecutionId)
      Update and existing TaskExecution to mark it as started.
      Parameters:
      executionId - the id of the taskExecution to be updated.
      taskName - the name that associated with the task execution.
      startTime - the time task began.
      arguments - list of key/value pairs that configure the task.
      externalExecutionId - id assigned to the task by the platform
      parentExecutionId - the parent task execution id.
      Returns:
      A TaskExecution containing the information available at task execution start.
      Since:
      1.2.0
    • completeTaskExecution

      void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage, String errorMessage)
      Update and existing TaskExecution to mark it as completed.
      Parameters:
      executionId - the id of the taskExecution to be updated.
      exitCode - the status of the task upon completion.
      endTime - the time the task completed.
      exitMessage - the message assigned to the task upon completion.
      errorMessage - error information available upon failure of a task.
      Since:
      1.1.0
    • completeTaskExecution

      void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage)
      Update and existing TaskExecution.
      Parameters:
      executionId - the id of the taskExecution to be updated.
      exitCode - the status of the task upon completion.
      endTime - the time the task completed.
      exitMessage - the message assigned to the task upon completion.
    • getTaskExecution

      TaskExecution getTaskExecution(long executionId)
      Retrieves a task execution from the task repository.
      Parameters:
      executionId - the id associated with the task execution.
      Returns:
      a fully qualified TaskExecution instance.
    • getTaskExecutionCountByTaskName

      long getTaskExecutionCountByTaskName(String taskName)
      Retrieves current number of task executions for a taskName.
      Parameters:
      taskName - the name of the task to search for in the repository.
      Returns:
      current number of task executions for the taskName.
    • getRunningTaskExecutionCountByTaskName

      long getRunningTaskExecutionCountByTaskName(String taskName)
      Retrieves current number of task executions for a taskName and with an endTime of null.
      Parameters:
      taskName - the name of the task to search for in the repository.
      Returns:
      current number of task executions for the taskName.
    • getRunningTaskExecutionCount

      long getRunningTaskExecutionCount()
      Retrieves current number of task executions with an endTime of null.
      Returns:
      current number of task executions.
    • getTaskExecutionCount

      long getTaskExecutionCount()
      Retrieves current number of task executions.
      Returns:
      current number of task executions.
    • findRunningTaskExecutions

      org.springframework.data.domain.Page<TaskExecution> findRunningTaskExecutions(String taskName, org.springframework.data.domain.Pageable pageable)
      Retrieves a set of task executions that are running for a taskName.
      Parameters:
      taskName - the name of the task to search for in the repository.
      pageable - the constraints for the search.
      Returns:
      set of running task executions.
    • findTaskExecutionsByName

      org.springframework.data.domain.Page<TaskExecution> findTaskExecutionsByName(String taskName, org.springframework.data.domain.Pageable pageable)
      Retrieves a subset of task executions by task name, start location and size.
      Parameters:
      taskName - the name of the task to search for in the repository.
      pageable - the constraints for the search.
      Returns:
      a list that contains task executions from the query bound by the start position and count specified by the user.
    • getTaskNames

      List<String> getTaskNames()
      Retrieves a sorted list of distinct task names for the task executions.
      Returns:
      a list of distinct task names from the task repository..
    • findAll

      org.springframework.data.domain.Page<TaskExecution> findAll(org.springframework.data.domain.Pageable pageable)
      Retrieves all the task executions within the pageable constraints.
      Parameters:
      pageable - the constraints for the search
      Returns:
      page containing the results from the search
    • getNextExecutionId

      long getNextExecutionId()
      Retrieves the next available execution id for a task execution.
      Returns:
      long containing the executionId.
    • getTaskExecutionIdByJobExecutionId

      Long getTaskExecutionIdByJobExecutionId(long jobExecutionId)
      Returns the id of the TaskExecution that the requested Spring Batch job execution was executed within the context of. Returns null if non were found.
      Parameters:
      jobExecutionId - the id of the JobExecution
      Returns:
      the id of the TaskExecution
    • getJobExecutionIdsByTaskExecutionId

      Set<Long> getJobExecutionIdsByTaskExecutionId(long taskExecutionId)
      Returns the job execution ids associated with a task execution id.
      Parameters:
      taskExecutionId - id of the TaskExecution
      Returns:
      a Set of the ids of the job executions executed within the task.
    • updateExternalExecutionId

      void updateExternalExecutionId(long taskExecutionId, String externalExecutionId)
      Updates the externalExecutionId for the execution id specified.
      Parameters:
      taskExecutionId - the execution id for the task to be updated.
      externalExecutionId - the new externalExecutionId.
    • getLatestTaskExecutionsByTaskNames

      List<TaskExecution> getLatestTaskExecutionsByTaskNames(String... taskNames)
      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.
      Parameters:
      taskNames - At least 1 task name must be provided
      Returns:
      List of TaskExecutions. May be empty but never null.
    • getLatestTaskExecutionForTaskName

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