Package io.camunda.zeebe.scheduler
Class Actor
java.lang.Object
io.camunda.zeebe.scheduler.Actor
- All Implemented Interfaces:
AsyncClosable,ConcurrencyControl,AutoCloseable,Executor
public abstract class Actor
extends Object
implements AutoCloseable, AsyncClosable, ConcurrencyControl
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ActorControlstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildActorName(String name, int partitionId) <T> ActorFuture<T> Schedules a callable to be executedvoidclose()Asynchronous closing.Should be overwritten by sub classes to add more context where the actor is run.getName()protected voidhandleFailure(Throwable failure) Invoked when a task throws and the actor phase is not 'STARTING' and 'CLOSING'.booleanstatic Actor.ActorBuildernewActor()protected voidprotected voidprotected voidvoidprotected voidprotected voidvoidSchedules an action to be invoked (must be called from an actor thread)<T> voidrunOnCompletion(ActorFuture<T> future, BiConsumer<T, Throwable> callback) Schedules a callback to be invoked after the future has completed<T> voidrunOnCompletion(Collection<ActorFuture<T>> actorFutures, Consumer<Throwable> callback) Invoke the callback when the given futures are completed (successfully or exceptionally).Schedule a task to be executed after a delaystatic Actorwrap(Consumer<ActorControl> r) Methods 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
-
Field Details
-
ACTOR_PROP_NAME
- See Also:
-
ACTOR_PROP_PARTITION_ID
- See Also:
-
actor
-
-
Constructor Details
-
Actor
public Actor()
-
-
Method Details
-
createContext
Should be overwritten by sub classes to add more context where the actor is run.- Returns:
- the context of the actor
-
getName
-
getContext
- Returns:
- a map which defines the context where the actor is run. Per default it just returns a map with the actor name. Ideally sub classes add more context, like the partition id etc.
-
isActorClosed
public boolean isActorClosed() -
onActorStarting
protected void onActorStarting() -
onActorStarted
protected void onActorStarted() -
onActorClosing
protected void onActorClosing() -
onActorClosed
protected void onActorClosed() -
onActorCloseRequested
protected void onActorCloseRequested() -
wrap
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
closeAsync
Description copied from interface:AsyncClosableAsynchronous closing. The implementation should close related resources and return a future, which is complete when closing is done.- Specified by:
closeAsyncin interfaceAsyncClosable- Returns:
- the future, which is completed when resources are closed
-
buildActorName
-
handleFailure
Invoked when a task throws and the actor phase is not 'STARTING' and 'CLOSING'. -
onActorFailed
public void onActorFailed() -
runOnCompletion
Description copied from interface:ConcurrencyControlSchedules a callback to be invoked after the future has completed- Specified by:
runOnCompletionin interfaceConcurrencyControl- Type Parameters:
T- result type of the future- Parameters:
future- the future whose completion is awaitedcallback- the callback to call after the future has completed
-
runOnCompletion
public <T> void runOnCompletion(Collection<ActorFuture<T>> actorFutures, Consumer<Throwable> callback) Description copied from interface:ConcurrencyControlInvoke 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:
actorFutures- the futures to wait oncallback- The throwable isnullwhen all futures are completed successfully. Otherwise, it holds the exception of the last completed future.
-
run
Description copied from interface:ConcurrencyControlSchedules an action to be invoked (must be called from an actor thread)- Specified by:
runin interfaceConcurrencyControl- Parameters:
action- action to be invoked
-
call
Description copied from interface:ConcurrencyControlSchedules a callable to be executed- Specified by:
callin interfaceConcurrencyControl- Type Parameters:
T- type of the result- Parameters:
callable- callable to be executed- Returns:
- a future with the result
-
schedule
Description copied from interface:ConcurrencyControlSchedule a task to be executed after a delay- Specified by:
schedulein interfaceConcurrencyControl
-
newActor
-