Class MapTaskExecutionDao
java.lang.Object
org.springframework.cloud.task.repository.dao.MapTaskExecutionDao
- All Implemented Interfaces:
TaskExecutionDao
Stores Task Execution Information to a in-memory map.
- Author:
- Glenn Renfro, Gunnar Hillert, David Turanski
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
completeTaskExecution
(long executionId, Integer exitCode, LocalDateTime endTime, String exitMessage) Update and existingTaskExecution
.void
completeTaskExecution
(long executionId, Integer exitCode, LocalDateTime endTime, String exitMessage, String errorMessage) Update and existingTaskExecution
to mark it as completed.createTaskExecution
(String taskName, LocalDateTime startTime, List<String> arguments, String externalExecutionId) Save a newTaskExecution
.createTaskExecution
(String taskName, LocalDateTime startTime, List<String> arguments, String externalExecutionId, Long parentExecutionId) Save a newTaskExecution
.org.springframework.data.domain.Page<TaskExecution>
findAll
(org.springframework.data.domain.Pageable pageable) Retrieves all the task executions within the pageable constraints.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.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.getJobExecutionIdsByTaskExecutionId
(long taskExecutionId) Returns the job execution ids associated with a task execution id.getLatestTaskExecutionForTaskName
(String taskName) Returns the latest task execution for a given task name.getLatestTaskExecutionsByTaskNames
(String... taskNames) Returns aList
of the latestTaskExecution
for 1 or more task names.long
Retrieves the next available execution id for a task execution.long
Retrieves current number of task executions with an endTime of null.long
getRunningTaskExecutionCountByTaskName
(String taskName) Retrieves current number of task executions for a taskName and with an endTime of null.getTaskExecution
(long executionId) Retrieves a task execution from the task repository.long
Retrieves current number of task executions.long
getTaskExecutionCountByTaskName
(String taskName) Retrieves current number of task executions for a taskName.getTaskExecutionIdByJobExecutionId
(long jobExecutionId) Returns the id of the TaskExecution that the requested Spring Batch job execution was executed within the context of.Retrieves a sorted list of distinct task names for the task executions.startTaskExecution
(long executionId, String taskName, LocalDateTime startTime, List<String> arguments, String externalExecutionid) Update and existingTaskExecution
to mark it as started.startTaskExecution
(long executionId, String taskName, LocalDateTime startTime, List<String> arguments, String externalExecutionid, Long parentExecutionId) Update and existingTaskExecution
to mark it as started.void
updateExternalExecutionId
(long taskExecutionId, String externalExecutionId) Updates the externalExecutionId for the execution id specified.
-
Constructor Details
-
MapTaskExecutionDao
public MapTaskExecutionDao()
-
-
Method Details
-
createTaskExecution
public TaskExecution createTaskExecution(String taskName, LocalDateTime startTime, List<String> arguments, String externalExecutionId) Description copied from interface:TaskExecutionDao
Save a newTaskExecution
.- Specified by:
createTaskExecution
in interfaceTaskExecutionDao
- 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
public TaskExecution createTaskExecution(String taskName, LocalDateTime startTime, List<String> arguments, String externalExecutionId, Long parentExecutionId) Description copied from interface:TaskExecutionDao
Save a newTaskExecution
.- Specified by:
createTaskExecution
in interfaceTaskExecutionDao
- 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 platformparentExecutionId
- the parent task execution id.- Returns:
- A fully qualified
TaskExecution
instance.
-
startTaskExecution
public TaskExecution startTaskExecution(long executionId, String taskName, LocalDateTime startTime, List<String> arguments, String externalExecutionid) Description copied from interface:TaskExecutionDao
Update and existingTaskExecution
to mark it as started.- Specified by:
startTaskExecution
in interfaceTaskExecutionDao
- 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.
-
startTaskExecution
public TaskExecution startTaskExecution(long executionId, String taskName, LocalDateTime startTime, List<String> arguments, String externalExecutionid, Long parentExecutionId) Description copied from interface:TaskExecutionDao
Update and existingTaskExecution
to mark it as started.- Specified by:
startTaskExecution
in interfaceTaskExecutionDao
- 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 platformparentExecutionId
- the parent task execution id.- Returns:
- A TaskExecution containing the information available at task execution start.
-
completeTaskExecution
public void completeTaskExecution(long executionId, Integer exitCode, LocalDateTime endTime, String exitMessage, String errorMessage) Description copied from interface:TaskExecutionDao
Update and existingTaskExecution
to mark it as completed.- Specified by:
completeTaskExecution
in interfaceTaskExecutionDao
- 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.
-
completeTaskExecution
public void completeTaskExecution(long executionId, Integer exitCode, LocalDateTime endTime, String exitMessage) Description copied from interface:TaskExecutionDao
Update and existingTaskExecution
.- Specified by:
completeTaskExecution
in interfaceTaskExecutionDao
- 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
Description copied from interface:TaskExecutionDao
Retrieves a task execution from the task repository.- Specified by:
getTaskExecution
in interfaceTaskExecutionDao
- Parameters:
executionId
- the id associated with the task execution.- Returns:
- a fully qualified TaskExecution instance.
-
getTaskExecutionCountByTaskName
Description copied from interface:TaskExecutionDao
Retrieves current number of task executions for a taskName.- Specified by:
getTaskExecutionCountByTaskName
in interfaceTaskExecutionDao
- Parameters:
taskName
- the name of the task to search for in the repository.- Returns:
- current number of task executions for the taskName.
-
getRunningTaskExecutionCountByTaskName
Description copied from interface:TaskExecutionDao
Retrieves current number of task executions for a taskName and with an endTime of null.- Specified by:
getRunningTaskExecutionCountByTaskName
in interfaceTaskExecutionDao
- Parameters:
taskName
- the name of the task to search for in the repository.- Returns:
- current number of task executions for the taskName.
-
getRunningTaskExecutionCount
public long getRunningTaskExecutionCount()Description copied from interface:TaskExecutionDao
Retrieves current number of task executions with an endTime of null.- Specified by:
getRunningTaskExecutionCount
in interfaceTaskExecutionDao
- Returns:
- current number of task executions.
-
getTaskExecutionCount
public long getTaskExecutionCount()Description copied from interface:TaskExecutionDao
Retrieves current number of task executions.- Specified by:
getTaskExecutionCount
in interfaceTaskExecutionDao
- Returns:
- current number of task executions.
-
findRunningTaskExecutions
public org.springframework.data.domain.Page<TaskExecution> findRunningTaskExecutions(String taskName, org.springframework.data.domain.Pageable pageable) Description copied from interface:TaskExecutionDao
Retrieves a set of task executions that are running for a taskName.- Specified by:
findRunningTaskExecutions
in interfaceTaskExecutionDao
- 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
public org.springframework.data.domain.Page<TaskExecution> findTaskExecutionsByName(String taskName, org.springframework.data.domain.Pageable pageable) Description copied from interface:TaskExecutionDao
Retrieves a subset of task executions by task name, start location and size.- Specified by:
findTaskExecutionsByName
in interfaceTaskExecutionDao
- 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
Description copied from interface:TaskExecutionDao
Retrieves a sorted list of distinct task names for the task executions.- Specified by:
getTaskNames
in interfaceTaskExecutionDao
- Returns:
- a list of distinct task names from the task repository..
-
findAll
public org.springframework.data.domain.Page<TaskExecution> findAll(org.springframework.data.domain.Pageable pageable) Description copied from interface:TaskExecutionDao
Retrieves all the task executions within the pageable constraints.- Specified by:
findAll
in interfaceTaskExecutionDao
- Parameters:
pageable
- the constraints for the search- Returns:
- page containing the results from the search
-
getTaskExecutions
-
getNextExecutionId
public long getNextExecutionId()Description copied from interface:TaskExecutionDao
Retrieves the next available execution id for a task execution.- Specified by:
getNextExecutionId
in interfaceTaskExecutionDao
- Returns:
- long containing the executionId.
-
getTaskExecutionIdByJobExecutionId
Description copied from interface:TaskExecutionDao
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.- Specified by:
getTaskExecutionIdByJobExecutionId
in interfaceTaskExecutionDao
- Parameters:
jobExecutionId
- the id of the JobExecution- Returns:
- the id of the
TaskExecution
-
getJobExecutionIdsByTaskExecutionId
Description copied from interface:TaskExecutionDao
Returns the job execution ids associated with a task execution id.- Specified by:
getJobExecutionIdsByTaskExecutionId
in interfaceTaskExecutionDao
- Parameters:
taskExecutionId
- id of theTaskExecution
- Returns:
- a
Set
of the ids of the job executions executed within the task.
-
updateExternalExecutionId
Description copied from interface:TaskExecutionDao
Updates the externalExecutionId for the execution id specified.- Specified by:
updateExternalExecutionId
in interfaceTaskExecutionDao
- Parameters:
taskExecutionId
- the execution id for the task to be updated.externalExecutionId
- the new externalExecutionId.
-
getBatchJobAssociations
-
getLatestTaskExecutionsByTaskNames
Description copied from interface:TaskExecutionDao
Returns aList
of the latestTaskExecution
for 1 or more task names. Latest is defined by the most recent start time. ATaskExecution
does not have to be finished (The results may including pendingTaskExecution
s). It is theoretically possible that aTaskExecution
with the same name to have more than 1TaskExecution
for the exact same start time. In that case theTaskExecution
with the highest Task Execution ID is returned. This method will not consider end times in its calculations. Thus, when a task executionA
starts after task executionB
but finishes BEFORE task executionA
, then task executionB
is being returned.- Specified by:
getLatestTaskExecutionsByTaskNames
in interfaceTaskExecutionDao
- Parameters:
taskNames
- At least 1 task name must be provided- Returns:
- List of TaskExecutions. May be empty but never null.
-
getLatestTaskExecutionForTaskName
Description copied from interface:TaskExecutionDao
Returns the latest task execution for a given task name. Will ultimately apply the same algorithm underneath asTaskExecutionDao.getLatestTaskExecutionsByTaskNames(String...)
but will only return a single result.- Specified by:
getLatestTaskExecutionForTaskName
in interfaceTaskExecutionDao
- Parameters:
taskName
- Must not be null or empty- Returns:
- The latest Task Execution or null
- See Also:
-