Class AbstractActor

java.lang.Object
net.sodacan.core.actor.AbstractActor
All Implemented Interfaces:
Actor
Direct Known Subclasses:
ActorGroupSender, ActorGroupStats, JournalWriter, TimeActor, WorkerActor

public abstract class AbstractActor extends Object implements Actor
  • Field Details

    • emptyStage

      public static Stage emptyStage
    • inbound

      protected Message inbound
  • Constructor Details

    • AbstractActor

      public AbstractActor(Config config, ActorId actorId)
  • Method Details

    • evictionProbability

      public float evictionProbability()
      An actor is subject to eviction at any time. However, the lower this value, the less likely is will be chosen for eviction.
      Specified by:
      evictionProbability in interface Actor
      Returns:
    • nextRoute

      protected Stage nextRoute()
      Convenience method to continue processing the next route in the inbound message with no other messages in the stage.
      Returns:
    • callProcessMessage

      public void callProcessMessage(NormalMessage nm)
      Process one message in the actor which has already been realized, if needed. This is where we deserialize the jug to a message object.
      Specified by:
      callProcessMessage in interface Actor
    • validateRoute

      protected void validateRoute(Message message, Stage stage)
    • handleStage

      protected void handleStage(Stage stage)
      Send each message in the stage - we're still in the Actor's run thread.
      Parameters:
      stage -
    • send

      public void send(Message m)
      If there are any more routes left in the message, the message will be sent to the Host (not directly to target) in case the target ActorGroup has changed to a different Host.
      Specified by:
      send in interface Actor
      Parameters:
      m -
    • processMessage

      public Stage processMessage()
      Default behavior for an actor is to throw an exception
      Specified by:
      processMessage in interface Actor
      Returns:
      A Stage object containing messages to be processed during Commit
    • getLiveActorGroupStatistics

      public Map<Integer,Statistics> getLiveActorGroupStatistics()
      Make a map of actorGroup statistics. We have to ask the host for this.
      Returns:
    • save

      public void save()
      Save state of the save fields of an actor in two steps: Serialize a field content and then persist the resulting serialized byte array
      Specified by:
      save in interface Actor
    • restore

      public void restore()
      Restore each of the @Save fields of an actor
      Specified by:
      restore in interface Actor
    • exitingThread

      public void exitingThread()
      The default saves the state of the actor
      Specified by:
      exitingThread in interface Actor
    • rollback

      protected void rollback()

      Empty the list of staged messages and restore the state of the actor.

    • getActorId

      public ActorId getActorId()
      Specified by:
      getActorId in interface Actor
    • getConfig

      public Config getConfig()
      Specified by:
      getConfig in interface Actor
    • getActorGroup

      public ActorGroup getActorGroup()
      Specified by:
      getActorGroup in interface Actor
    • setActorGroup

      public void setActorGroup(ActorGroup actorGroup)
      Specified by:
      setActorGroup in interface Actor
    • getEmptyStage

      public Stage getEmptyStage()
      Specified by:
      getEmptyStage in interface Actor