Package io.camunda.zeebe.util.sched
Class Actor
java.lang.Object
io.camunda.zeebe.util.sched.Actor
- All Implemented Interfaces:
CloseableSilently,AsyncClosable,ConcurrencyControl,AutoCloseable
public abstract class Actor
extends Object
implements CloseableSilently, AsyncClosable, ConcurrencyControl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ActorControlstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildActorName(int nodeId, String name) static StringbuildActorName(int nodeId, String name, int partitionId) voidclose()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'.booleanprotected 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 completedstatic 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.util.sched.ConcurrencyControl
createCompletedFuture, createFuture
-
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- Specified by:
closein interfaceCloseableSilently
-
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
-
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
-
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
-