Class SharedTaskContext
- java.lang.Object
-
- org.hawaiiframework.async.timeout.SharedTaskContext
-
public class SharedTaskContext extends Object
The strategy is used by theTimeoutGuardTask
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
- Author:
- Rutger Lubbers, Paul Klos
-
-
Constructor Summary
Constructors Constructor Description SharedTaskContext(String taskName, ExecutorConfigurationProperties executorConfigurationProperties, ExecutorStatistics executorStatistics, KibanaLogContext logContext)
Construct an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abortBusinessTask()
Invoke thetaskAbortStrategy
.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
registerLogFields()
Registers log fields using the current log context.void
removeLogFields()
Clears the kibana log fields.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.
-
-
-
Constructor Detail
-
SharedTaskContext
public SharedTaskContext(String taskName, ExecutorConfigurationProperties executorConfigurationProperties, ExecutorStatistics executorStatistics, KibanaLogContext logContext)
Construct an instance.- Parameters:
taskName
- the task nameexecutorConfigurationProperties
- the executor configuration properties
-
-
Method Detail
-
setTaskRemoveStrategy
public void setTaskRemoveStrategy(TaskRemoveStrategy taskRemoveStrategy)
Register the task removal strategy.- Parameters:
taskRemoveStrategy
- TheTaskRemoveStrategy
to share.
-
setTimeoutGuardTaskRemoveStrategy
public void setTimeoutGuardTaskRemoveStrategy(TaskRemoveStrategy timeoutGuardTaskRemoveStrategy)
Register the timeout guard task removal strategy.- Parameters:
timeoutGuardTaskRemoveStrategy
- theTaskRemoveStrategy
to set.
-
setTaskAbortStrategy
public void setTaskAbortStrategy(TaskAbortStrategy taskAbortStrategy)
Register the task abort strategy.- Parameters:
taskAbortStrategy
- TheTaskAbortStrategy
to share.
-
abortBusinessTask
public void abortBusinessTask()
Invoke thetaskAbortStrategy
.
-
getTimeout
public Integer getTimeout()
Get the timeout for the task this strategy is for.- Returns:
- the timeout
- See Also:
ExecutorConfigurationProperties.getTaskTimeout(String)
-
getTaskId
public String getTaskId()
Get the task's id.- Returns:
- The task's id.
-
getTaskName
public String getTaskName()
Retrieve the task's name.- Returns:
- The task's name.
-
isAborted
public boolean isAborted()
Has the task been aborted?
-
timeout
public void timeout()
Remove the guarded task from the queue, or else abort the running guarded task.
-
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
public TaskStatistics getTaskStatistics()
Return the task's execution statistics.
-
startExecution
public void startExecution()
Signal the start of the task's execution.
-
registerLogFields
public void registerLogFields()
Registers log fields using the current log context.
-
removeLogFields
public void removeLogFields()
Clears the kibana log fields.
-
-