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 Details

  • Constructor Details

    • Actor

      public Actor()
  • Method Details

    • createContext

      protected Map<String,String> createContext()
      Should be overwritten by sub classes to add more context where the actor is run.
      Returns:
      the context of the actor
    • getName

      public String getName()
    • getContext

      public Map<String,String> 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

      public static Actor wrap(Consumer<ActorControl> r)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface CloseableSilently
    • closeAsync

      public ActorFuture<Void> closeAsync()
      Description copied from interface: AsyncClosable
      Asynchronous closing. The implementation should close related resources and return a future, which is complete when closing is done.
      Specified by:
      closeAsync in interface AsyncClosable
      Returns:
      the future, which is completed when resources are closed
    • buildActorName

      public static String buildActorName(int nodeId, String name)
    • buildActorName

      public static String buildActorName(int nodeId, String name, int partitionId)
    • handleFailure

      protected void handleFailure(Throwable failure)
      Invoked when a task throws and the actor phase is not 'STARTING' and 'CLOSING'.
    • onActorFailed

      public void onActorFailed()
    • runOnCompletion

      public <T> void runOnCompletion(ActorFuture<T> future, BiConsumer<T,Throwable> callback)
      Description copied from interface: ConcurrencyControl
      Schedules a callback to be invoked after the future has completed
      Specified by:
      runOnCompletion in interface ConcurrencyControl
      Type Parameters:
      T - result type of the future
      Parameters:
      future - the future whose completion is awaited
      callback - the callback to call after the future has completed
    • run

      public void run(Runnable action)
      Description copied from interface: ConcurrencyControl
      Schedules an action to be invoked (must be called from an actor thread)
      Specified by:
      run in interface ConcurrencyControl
      Parameters:
      action - action to be invoked