Class AbstractInvocable
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.net.AbstractInvocable
-
- All Implemented Interfaces:
Invocable
,InvocableInOrder
,PriorityTask
,Serializable
,Runnable
public abstract class AbstractInvocable extends Base implements Invocable, InvocableInOrder, PriorityTask, Serializable
An abstract base for Invocable and PriorityTask implementations.- Since:
- Coherence 2.2
- Author:
- gg 2003.03.31, 2007.03.11
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Field Summary
-
Fields inherited from class com.tangosol.util.Base
LOG_ALWAYS, LOG_CONFIG, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
-
Fields inherited from interface com.tangosol.net.PriorityTask
SCHEDULE_FIRST, SCHEDULE_IMMEDIATE, SCHEDULE_STANDARD, TIMEOUT_DEFAULT, TIMEOUT_NONE
-
-
Constructor Summary
Constructors Constructor Description AbstractInvocable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.Object
getResult()
Determine the result from the invocation of this object.int
getSchedulingPriority()
Obtain this task's scheduling priority.InvocationService
getService()
Obtain the containing InvocationService.void
init(InvocationService service)
Called by the InvocationService exactly once on this Invocable object as part of its initialization.boolean
isRespondInOrder()
Determine whether this Invocable object has to preserve the order of responses according to the order of requests.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.protected void
setResult(Object oResult)
Set the result of the invocation.-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
-
-
-
Method Detail
-
init
public void init(InvocationService service)
Called by the InvocationService exactly once on this Invocable object as part of its initialization.
-
getResult
public Object getResult()
Determine the result from the invocation of this object. This method is called by the InvocationService after the run method returns.
-
isRespondInOrder
public boolean isRespondInOrder()
Determine whether this Invocable object has to preserve the order of responses according to the order of requests.This implementation returns "false".
- Specified by:
isRespondInOrder
in interfaceInvocableInOrder
- Returns:
- true if the response order must be preserved; false otherwise
-
getSchedulingPriority
public int getSchedulingPriority()
Obtain this task's scheduling priority. Valid values are one of the SCHEDULE_* constants.This implementation returns
SCHEDULE_STANDARD
.- 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.This implementation returns
TIMEOUT_DEFAULT
.- Specified by:
getExecutionTimeoutMillis
in interfacePriorityTask
- Returns:
- the execution 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.
This implementation is a no-op.
- 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
-
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.This implementation returns
TIMEOUT_DEFAULT
.- Specified by:
getRequestTimeoutMillis
in interfacePriorityTask
- Returns:
- the request timeout value in milliseconds or one of the special TIMEOUT_* values
-
getService
public InvocationService getService()
Obtain the containing InvocationService.- Returns:
- the containing InvocationService
-
setResult
protected void setResult(Object oResult)
Set the result of the invocation.- Parameters:
oResult
- the invocation result
-
-