Class ActorControl
- All Implemented Interfaces:
ConcurrencyControl,Executor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCallables actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED<T> ActorFuture<T> Callables actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTEDclose()static ActorControlcurrent()voidMark actor as failed.booleanbooleanisClosed()booleanonCondition(String conditionName, Runnable conditionAction) Conditional actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTEDvoidRunnables submitted by the actor itself are executed while the actor is in any of its lifecycle phases.Schedule a timer task at (or after) a timestamp.runAtFixedRate(Duration delay, Runnable runnable) Scheduled a repeating timer<T> voidrunOnCompletion(ActorFuture<T> future, BiConsumer<T, Throwable> callback) Invoke the callback when the given future is completed (successfully or exceptionally).<T> voidrunOnCompletion(Collection<ActorFuture<T>> futures, Consumer<Throwable> callback) Invoke the callback when the given futures are completed (successfully or exceptionally).<T> voidrunOnCompletionBlockingCurrentPhase(ActorFuture<T> future, BiConsumer<T, Throwable> callback) Invoke the callback when the given future is completed (successfully or exceptionally).The runnable is executed while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTEDvoidLikerun(Runnable)but submits the runnable to the end of the actor's queue such that other actions may be executed before this.voidcan be called by the actor to yield the threadMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.camunda.zeebe.scheduler.ConcurrencyControl
createCompletedFuture, createFuture, execute
-
Constructor Details
-
ActorControl
-
-
Method Details
-
current
-
onCondition
Conditional actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED- Parameters:
conditionName-conditionAction-- Returns:
-
call
Callables actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED- Parameters:
action-- Returns:
-
runAtFixedRate
Scheduled a repeating timerThe runnable is executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Parameters:
delay-runnable-- Returns:
-
runAt
Schedule a timer task at (or after) a timestamp.The runnable is executed while the actor is in the following actor lifecycle phases: invalid input: '{@link *' ActorLifecyclePhase#STARTED}
This provides no guarantees that the timer task is run at the timestamp. It's likely that the timer task is run shortly after the timestamp. We guarantee that the runnable won't run before the timestamp.
- Parameters:
timestamp- A unix epoch timestamp in millisecondsrunnable- The runnable to run at (or after) the timestamp- Returns:
- A handle to the scheduled timer task
-
runOnCompletion
Invoke the callback when the given future is completed (successfully or exceptionally). This call does not block the actor. If close is requested the actor will not wait on this future, in this case the callback is never called.The callback is executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Specified by:
runOnCompletionin interfaceConcurrencyControl- Type Parameters:
T- result type of the future- Parameters:
future- the future to wait oncallback- the callback that handle the future's result. The throwable isnullwhen the future is completed successfully.
-
run
Runnables submitted by the actor itself are executed while the actor is in any of its lifecycle phases.Runnables submitted externally are executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Specified by:
runin interfaceConcurrencyControl- Parameters:
action-
-
call
Callables actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED- Specified by:
callin interfaceConcurrencyControl- Type Parameters:
T- type of the result- Parameters:
callable-- Returns:
-
schedule
The runnable is executed while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED- Specified by:
schedulein interfaceConcurrencyControl- Parameters:
delay-runnable-- Returns:
-
submit
Likerun(Runnable)but submits the runnable to the end of the actor's queue such that other actions may be executed before this. This method is useful in case an actor is in a (potentially endless) loop, and it should be able to interrupt it.The runnable is executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Parameters:
action- the action to run.
-
runOnCompletionBlockingCurrentPhase
public <T> void runOnCompletionBlockingCurrentPhase(ActorFuture<T> future, BiConsumer<T, Throwable> callback) Invoke the callback when the given future is completed (successfully or exceptionally). This call does not block the actor. If close is requested the actor will wait on this future and not change the phase, in this case the callback will eventually be called.The callback is executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Parameters:
future- the future to wait oncallback- the callback that handle the future's result. The throwable isnullwhen the future is completed successfully.
-
runOnCompletion
Invoke the callback when the given futures are completed (successfully or exceptionally). This call does not block the actor.The callback is executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Specified by:
runOnCompletionin interfaceConcurrencyControl- Parameters:
futures- the futures to wait oncallback- The throwable isnullwhen all futures are completed successfully. Otherwise, it holds the exception of the last completed future.
-
yieldThread
public void yieldThread()can be called by the actor to yield the thread -
close
-
isClosing
public boolean isClosing() -
isClosed
public boolean isClosed() -
getLifecyclePhase
-
isCalledFromWithinActor
-
fail
Mark actor as failed. This sets the lifecycle phase to 'FAILED' and discards all jobs.
-