Class NonBlockingFiniteStateMachine.Task
- java.lang.Object
-
- com.tangosol.util.fsm.NonBlockingFiniteStateMachine.Task
-
- All Implemented Interfaces:
Associated
,KeyAssociation
,PriorityTask
,Runnable
- Enclosing class:
- NonBlockingFiniteStateMachine<S extends Enum<S>>
protected class NonBlockingFiniteStateMachine.Task extends Object implements Runnable, PriorityTask, KeyAssociation
A PriorityTask implementation to process a requested event.
-
-
Field Summary
-
Fields inherited from interface com.tangosol.net.PriorityTask
SCHEDULE_FIRST, SCHEDULE_IMMEDIATE, SCHEDULE_STANDARD, TIMEOUT_DEFAULT, TIMEOUT_NONE
-
-
Constructor Summary
Constructors Constructor Description Task(Event<S> event, NonBlockingFiniteStateMachine.TaskDependencies deps)
Create a Task with given event.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getAssociatedKey()
Determine the host key (or base) object to which this object is associated.long
getExecutionTimeoutMillis()
Obtain the maximum amount of time this task is allowed to run before the corresponding service will attempt to stop it.long
getRequestTimeoutMillis()
Obtain the maximum amount of time a calling thread is willing to wait for a result of the request execution.int
getSchedulingPriority()
Obtain this task's scheduling priority.void
run()
void
runCanceled(boolean fAbandoned)
This method will be called if and only if all attempts to interrupt this task were unsuccessful in stopping the execution or if the execution was canceled before it had a chance to run at all.
-
-
-
Constructor Detail
-
Task
public Task(Event<S> event, NonBlockingFiniteStateMachine.TaskDependencies deps)
Create a Task with given event.- Parameters:
event
- the event that needs to be processeddeps
- the task dependencies
-
-
Method Detail
-
getAssociatedKey
public Object getAssociatedKey()
Determine the host key (or base) object to which this object is associated.Note: It's expected that the returned object is suitable to be used as an immutable identity (e.g. a key in a Map).
Note 2: Circular associations are not permitted.- Specified by:
getAssociatedKey
in interfaceAssociated
- Returns:
- the host key that for this object, or null if this object has no association
-
getSchedulingPriority
public int getSchedulingPriority()
Obtain this task's scheduling priority. Valid values are one of the SCHEDULE_* constants.- Specified by:
getSchedulingPriority
in interfacePriorityTask
- Returns:
- this task's scheduling priority
-
getExecutionTimeoutMillis
public long getExecutionTimeoutMillis()
Obtain the maximum amount of time this task is allowed to run before the corresponding service will attempt to stop it.The value of
TIMEOUT_DEFAULT
indicates a default timeout value configured for the corresponding service; the value ofTIMEOUT_NONE
indicates that this task can execute indefinitely.If, by the time the specified amount of time passed, the task has not finished, the service will attempt to stop the execution by using the
Thread.interrupt()
method. In the case that interrupting the thread does not result in the task's termination, thePriorityTask.runCanceled(boolean)
method will be called.- Specified by:
getExecutionTimeoutMillis
in interfacePriorityTask
- Returns:
- the execution timeout value in milliseconds or one of the special TIMEOUT_* values
-
getRequestTimeoutMillis
public long getRequestTimeoutMillis()
Obtain the maximum amount of time a calling thread is willing to wait for a result of the request execution. The request time is measured on the client side as the time elapsed from the moment a request is sent for execution to the corresponding server node(s) and includes:- the time it takes to deliver the request to the executing node(s);
- the interval between the time the task is received and placed into a service queue until the execution starts;
- the task execution time;
- the time it takes to deliver a result back to the client.
The value of
TIMEOUT_DEFAULT
indicates a default timeout value configured for the corresponding service; the value ofTIMEOUT_NONE
indicates that the client thread is willing to wait indefinitely until the task execution completes or is canceled by the service due to a task execution timeout specified by thePriorityTask.getExecutionTimeoutMillis()
value.If the specified amount of time elapsed and the client has not received any response from the server, an
RequestTimeoutException
will be thrown to the caller.- Specified by:
getRequestTimeoutMillis
in interfacePriorityTask
- Returns:
- the request timeout value in milliseconds or one of the special TIMEOUT_* values
-
runCanceled
public void runCanceled(boolean fAbandoned)
This method will be called if and only if all attempts to interrupt this task were unsuccessful in stopping the execution or if the execution was canceled before it had a chance to run at all.Since this method is usually called on a service thread, implementors must exercise extreme caution since any delay introduced by the implementation will cause a delay of the corresponding service.
- Specified by:
runCanceled
in interfacePriorityTask
- Parameters:
fAbandoned
- true if the task has timed-out, but all attempts to interrupt it were unsuccessful in stopping the execution; otherwise the task was never started
-
-