Package org.voltdb.task
Class ScheduledAction
java.lang.Object
org.voltdb.task.ScheduledAction
Class which describes an interval, an action to perform after that interval and a callback which should be invoked
after the action has been performed.
This class also has an optional attachment which can be used to pass state between the initiating class and the callback.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ScheduledAction
callback
(long interval, TimeUnit timeUnit, Function<ActionResult, ScheduledAction> callback) static ScheduledAction
Create aScheduledAction
which indicates that an unrecoverable error has occurred and the scheduler must exit.static ScheduledAction
Create aScheduledAction
which indicates that the scheduler has reached the end of its life cycle gracefully<T> T
Retrieve the optional attachment associated with this scheduled actionlong
getInterval
(TimeUnit timeUnit) Object[]
getType()
static ScheduledAction
Create aScheduledAction
from aAction
which is of type stop.static ScheduledAction
static ScheduledAction
procedureCall
(long interval, TimeUnit timeUnit, Function<ActionResult, ScheduledAction> callback, String procedure, Object... procedureParameters) Create aScheduledAction
which executes a procedure with given parameters afterinterval
setAttachment
(Object attachment) Add an arbitrary attachment to this instance so that it can be retrieved from theActionResult
setStatusMessage
(String statusMessage) Set the optional status message which will be reported in the statistics for a task and if this is anActionType.ERROR
orActionType.EXIT
action then it will also be logged.toString()
-
Method Details
-
of
Create aScheduledAction
from aAction
which is of type stop.- Parameters:
action
- BaseAction
to get type and message from- Returns:
- A new
ScheduledAction
derived fromaction
-
of
- Parameters:
interval
- To wait until performingaction
action
- To be performed afterinterval
- Returns:
- A new
ScheduledAction
from combininginterval
andaction
-
error
Create aScheduledAction
which indicates that an unrecoverable error has occurred and the scheduler must exit.statusMessage
is the same status message which is set by callingsetStatusMessage(String)
- Parameters:
statusMessage
- To log indicating the details of the error. May benull
- Returns:
- A new
ActionType.ERROR
instance ofScheduledAction
-
exit
Create aScheduledAction
which indicates that the scheduler has reached the end of its life cycle gracefullystatusMessage
is the same status message which is set by callingsetStatusMessage(String)
- Parameters:
statusMessage
- To log indicating the details of the error. May benull
- Returns:
- A new
ActionType.EXIT
instance ofScheduledAction
-
procedureCall
public static ScheduledAction procedureCall(long interval, TimeUnit timeUnit, Function<ActionResult, ScheduledAction> callback, String procedure, Object... procedureParameters) Create aScheduledAction
which executes a procedure with given parameters afterinterval
- Parameters:
interval
- Interval after which the procedure is to be executedtimeUnit
- {#link TimeUnit} ofinterval
callback
- That is invoked afterprocedure
completes executionprocedure
- Name of procedure to executeprocedureParameters
- To pass to procedure during execution- Returns:
- A new
ActionType.PROCEDURE
instance ofScheduledAction
-
callback
public static ScheduledAction callback(long interval, TimeUnit timeUnit, Function<ActionResult, ScheduledAction> callback) Create aScheduledAction
which causes thecallback
to be invoked afterinterval
. AActionResult
will be associated with this call however it will have anull
procedure
andresult
but anattachment
can be used.- Parameters:
interval
- Interval until thecallback
is invokedtimeUnit
-TimeUnit
ofinterval
callback
- That is invoked afterinterval
has passed- Returns:
- A new
ActionType.CALLBACK
instance ofScheduledAction
-
getInterval
- Parameters:
timeUnit
- Of the returned interval- Returns:
- The time interval until this action should be performed
-
getType
- Returns:
- The
ActionType
of this action
-
getStatusMessage
- Returns:
- Optional status message provided with any action
-
setStatusMessage
Set the optional status message which will be reported in the statistics for a task and if this is anActionType.ERROR
orActionType.EXIT
action then it will also be logged. ForActionType.ERROR
orActionType.EXIT
actions this can be provided as part of the factory method.- Parameters:
statusMessage
- To be reported- Returns:
this
-
getProcedure
- Returns:
- Name of procedure to execute. Will be
null
if this is not aActionType.PROCEDURE
-
getProcedureParameters
- Returns:
- The parameters that are to be passed the the procedure returned by
getProcedure()
-
getCallback
- Returns:
- The callback to invoke after the
action
has been performed
-
setAttachment
Add an arbitrary attachment to this instance so that it can be retrieved from theActionResult
- Parameters:
attachment
- Object to attach. May benull
- Returns:
this
-
getAttachment
public <T> T getAttachment()Retrieve the optional attachment associated with this scheduled action- Type Parameters:
T
- Type of attachment- Returns:
- The attachment or
null
of there was no attachment
-
toString
-