All Implemented Interfaces:
Actor, Stash, StashFactory, StashSupport, UnrestrictedStash, RequiresMessageQueue<DequeBasedMessageQueueSemantics>, AbstractPersistentActorLike, Eventsourced, PersistenceIdentity, PersistenceRecovery, PersistenceStash, Snapshotter, ExecuteInSelfActor

public class Shard extends RaftActor
A Shard represents a portion of the logical data tree.

Our Shard uses InMemoryDataTree as its internal representation and delegates all requests it

  • Field Details

  • Method Details

    • postStop

      public final void postStop() throws Exception
      Specified by:
      postStop in interface Actor
      Specified by:
      postStop in interface UnrestrictedStash
      Overrides:
      postStop in class RaftActor
      Throws:
      Exception
    • handleRecover

      protected final void handleRecover(Object message)
      Overrides:
      handleRecover in class RaftActor
    • handleNonRaftCommand

      protected void handleNonRaftCommand(Object message)
      Description copied from class: RaftActor
      Method exposed for subclasses to plug-in their logic. This method is invoked by RaftActor.handleCommand(Object) for messages which are not handled by this class. Subclasses overriding this class should fall back to this implementation for messages which they do not handle
      Overrides:
      handleNonRaftCommand in class RaftActor
      Parameters:
      message - Incoming command message
    • getRoleChangeNotifier

      protected final Optional<ActorRef> getRoleChangeNotifier()
      Description copied from class: RaftActor
      Notifier Actor for this RaftActor to notify when a role change happens.
      Specified by:
      getRoleChangeNotifier in class RaftActor
      Returns:
      ActorRef - ActorRef of the notifier or Optional.absent if none.
    • newLeaderStateChanged

      protected final LeaderStateChanged newLeaderStateChanged(String memberId, String leaderId, short leaderPayloadVersion)
      Overrides:
      newLeaderStateChanged in class RaftActor
    • isIsolatedLeader

      protected boolean isIsolatedLeader()
    • getRaftActorSnapshotCohort

      protected final RaftActorSnapshotCohort getRaftActorSnapshotCohort()
      Description copied from class: RaftActor
      Returns the RaftActorSnapshotCohort to participate in snapshot captures.
      Specified by:
      getRaftActorSnapshotCohort in class RaftActor
    • getRaftActorRecoveryCohort

      protected final RaftActorRecoveryCohort getRaftActorRecoveryCohort()
      Description copied from class: RaftActor
      Returns the RaftActorRecoveryCohort to participate in persistence recovery.
      Specified by:
      getRaftActorRecoveryCohort in class RaftActor
    • onRecoveryComplete

      protected void onRecoveryComplete()
      Description copied from class: RaftActor
      This method is called when recovery is complete.
      Specified by:
      onRecoveryComplete in class RaftActor
    • applyState

      protected final void applyState(ActorRef clientActor, Identifier identifier, Object data)
      Description copied from class: RaftActor
      The applyState method will be called by the RaftActor when some data needs to be applied to the actor's state.
      Specified by:
      applyState in class RaftActor
      Parameters:
      clientActor - A reference to the client who sent this message. This is the same reference that was passed to persistData by the derived actor. clientActor may be null when the RaftActor is behaving as a follower or during recovery.
      identifier - The identifier of the persisted data. This is also the same identifier that was passed to persistData by the derived actor. identifier may be null when the RaftActor is behaving as a follower or during recovery
      data - A piece of data that was persisted by the persistData call. This should NEVER be null.
    • onStateChanged

      protected final void onStateChanged()
      Description copied from class: RaftActor
      This method will be called by the RaftActor when the state of the RaftActor changes. The derived actor can then use methods like isLeader or getLeader to do something useful
      Specified by:
      onStateChanged in class RaftActor
    • onLeaderChanged

      protected final void onLeaderChanged(String oldLeader, String newLeader)
      Overrides:
      onLeaderChanged in class RaftActor
    • pauseLeader

      protected final void pauseLeader(Runnable operation)
      Description copied from class: RaftActor
      This method is called prior to operations such as leadership transfer and actor shutdown when the leader must pause or stop its duties. This method allows derived classes to gracefully pause or finish current work prior to performing the operation. On completion of any work, the run method must be called on the given Runnable to proceed with the given operation. Important: the run method must be called on this actor's thread dispatcher as as it modifies internal state.

      The default implementation immediately runs the operation.

      Overrides:
      pauseLeader in class RaftActor
      Parameters:
      operation - the operation to run
    • unpauseLeader

      protected final void unpauseLeader()
      Description copied from class: RaftActor
      This method is invoked when the actions hooked to the leader becoming paused failed to execute and the leader should resume normal operations.

      Note this method can be invoked even before the operation supplied to RaftActor.pauseLeader(Runnable) is invoked.

      Overrides:
      unpauseLeader in class RaftActor
    • newOnDemandRaftStateBuilder

      protected final OnDemandRaftState.AbstractBuilder<?,?> newOnDemandRaftStateBuilder()
      Overrides:
      newOnDemandRaftStateBuilder in class RaftActor
    • persistenceId

      public final String persistenceId()
    • journalPluginId

      public final String journalPluginId()
      Specified by:
      journalPluginId in interface PersistenceIdentity
      Overrides:
      journalPluginId in class AbstractPersistentActor
    • builder

      public static Shard.Builder builder()