Class SharedTaskContext
java.lang.Object
org.hawaiiframework.async.timeout.SharedTaskContext
The strategy is used by the
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.
- Since:
- 2.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionSharedTaskContext(String taskName, ExecutorConfigurationProperties executorConfigurationProperties, ExecutorStatistics executorStatistics, List<TaskListener> taskListeners) Construct an instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoke thetaskAbortStrategy.voidfinish()This method is invoked when the guarded task is finished.Get the task's id.Retrieve the task's name.Return the task's execution statistics.Get the timeout for the task this strategy is for.booleanWhether the task has been aborted or not..voidsetTaskAbortStrategy(TaskAbortStrategy taskAbortStrategy) Register the task abort strategy.voidsetTaskRemoveStrategy(TaskRemoveStrategy taskRemoveStrategy) Register the task removal strategy.voidsetTimeoutGuardTaskRemoveStrategy(TaskRemoveStrategy timeoutGuardTaskRemoveStrategy) Register the timeout guard task removal strategy.voidSignal the start of the task's execution.voidtimeout()Remove the guarded task from the queue, or else abort the running guarded task.
-
Constructor Details
-
SharedTaskContext
public SharedTaskContext(String taskName, ExecutorConfigurationProperties executorConfigurationProperties, ExecutorStatistics executorStatistics, List<TaskListener> taskListeners) Construct an instance.- Parameters:
taskName- the task nameexecutorConfigurationProperties- the executor configuration propertiesexecutorStatistics- executor statisctics.taskListeners- task listeners.
-
-
Method Details
-
setTaskRemoveStrategy
Register the task removal strategy.- Parameters:
taskRemoveStrategy- TheTaskRemoveStrategyto share.
-
setTimeoutGuardTaskRemoveStrategy
Register the timeout guard task removal strategy.- Parameters:
timeoutGuardTaskRemoveStrategy- theTaskRemoveStrategyto set.
-
setTaskAbortStrategy
Register the task abort strategy.- Parameters:
taskAbortStrategy- TheTaskAbortStrategyto share.
-
abortBusinessTask
public void abortBusinessTask()Invoke thetaskAbortStrategy. -
getTimeout
Get the timeout for the task this strategy is for.- Returns:
- the timeout
- See Also:
-
getTaskId
Get the task's id.- Returns:
- The task's id.
-
getTaskName
Retrieve the task's name.- Returns:
- The task's name.
-
isAborted
public boolean isAborted()Whether the task has been aborted or not..- Returns:
trueif the task has been aborted.
-
timeout
public void timeout()Remove the guarded task from the queue, or else abort the running guarded task. -
startExecution
public void startExecution()Signal the start of the task's execution. -
finish
public void finish()This method is invoked when the guarded task is finished.It will perform cleanups. The finish should always be invoked.
-
getTaskStatistics
Return the task's execution statistics.- Returns:
- The task statistics.
-