public class SharedTaskContext extends Object
TimeoutGuardTask
to stop a running guarded task.
This class is called shared since it is shared by the guarded task and the guard task in order to communicate the task abort strategy.
Constructor and Description |
---|
SharedTaskContext(String taskName,
ExecutorConfigurationProperties executorConfigurationProperties,
ExecutorStatistics executorStatistics)
Construct an instance.
|
Modifier and Type | Method and Description |
---|---|
void |
abortBusinessTask()
Invoke the
taskAbortStrategy . |
void |
finish()
This method is invoked when the guarded task is finished.
|
String |
getTaskId()
Get the task's id.
|
String |
getTaskName()
Retrieve the task's name.
|
TaskStatistics |
getTaskStatistics()
Return the task's execution statistics.
|
Integer |
getTimeout()
Get the timeout for the task this strategy is for.
|
boolean |
isAborted()
Has the task been aborted?
|
void |
setTaskAbortStrategy(TaskAbortStrategy taskAbortStrategy)
Register the task abort strategy.
|
void |
setTaskRemoveStrategy(TaskRemoveStrategy taskRemoveStrategy)
Register the task removal strategy.
|
void |
setTimeoutGuardTaskRemoveStrategy(TaskRemoveStrategy timeoutGuardTaskRemoveStrategy)
Register the timeout guard task removal strategy.
|
void |
startExecution()
Signal the start of the task's execution.
|
void |
timeout()
Remove the guarded task from the queue, or else abort the running guarded task.
|
public SharedTaskContext(String taskName, ExecutorConfigurationProperties executorConfigurationProperties, ExecutorStatistics executorStatistics)
taskName
- the task nameexecutorConfigurationProperties
- the executor configuration propertiespublic void setTaskRemoveStrategy(TaskRemoveStrategy taskRemoveStrategy)
taskRemoveStrategy
- The TaskRemoveStrategy
to share.public void setTimeoutGuardTaskRemoveStrategy(TaskRemoveStrategy timeoutGuardTaskRemoveStrategy)
timeoutGuardTaskRemoveStrategy
- the TaskRemoveStrategy
to set.public void setTaskAbortStrategy(TaskAbortStrategy taskAbortStrategy)
taskAbortStrategy
- The TaskAbortStrategy
to share.public void abortBusinessTask()
taskAbortStrategy
.public Integer getTimeout()
ExecutorConfigurationProperties.getTaskTimeout(String)
public String getTaskId()
public String getTaskName()
public boolean isAborted()
public void timeout()
public void finish()
It will perform cleanups. The finish should always be invoked.
public TaskStatistics getTaskStatistics()
public void startExecution()