Class Shard

  • All Implemented Interfaces:
    akka.actor.Actor, akka.actor.Stash, akka.actor.StashFactory, akka.actor.StashSupport, akka.actor.UnrestrictedStash, akka.dispatch.RequiresMessageQueue<akka.dispatch.DequeBasedMessageQueueSemantics>, akka.persistence.AbstractPersistentActorLike, akka.persistence.Eventsourced, akka.persistence.PersistenceIdentity, akka.persistence.PersistenceRecovery, akka.persistence.PersistenceStash, akka.persistence.Snapshotter, ExecuteInSelfActor

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

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

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Shard.AbstractBuilder<T extends Shard.AbstractBuilder<T,​S>,​S extends Shard>  
      static class  Shard.Builder  
      • Nested classes/interfaces inherited from class akka.actor.AbstractActor

        akka.actor.AbstractActor.ActorContext, akka.actor.AbstractActor.Receive
      • Nested classes/interfaces inherited from interface akka.actor.Actor

        akka.actor.Actor.emptyBehavior$, akka.actor.Actor.ignoringBehavior$
      • Nested classes/interfaces inherited from interface akka.persistence.Eventsourced

        akka.persistence.Eventsourced.AsyncHandlerInvocation, akka.persistence.Eventsourced.AsyncHandlerInvocation$, akka.persistence.Eventsourced.PendingHandlerInvocation, akka.persistence.Eventsourced.RecoveryTick, akka.persistence.Eventsourced.RecoveryTick$, akka.persistence.Eventsourced.StashingHandlerInvocation, akka.persistence.Eventsourced.StashingHandlerInvocation$
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void applyState​(akka.actor.ActorRef clientActor, Identifier identifier, Object data)
      The applyState method will be called by the RaftActor when some data needs to be applied to the actor's state.
      static Shard.Builder builder()  
      Collection<?> convertPendingTransactionsToMessages()
      Clears all pending transactions and converts them to messages to be forwarded to a new leader.
      int getCohortCacheSize()  
      ShardDataTree getDataStore()  
      DatastoreContext getDatastoreContext()  
      int getPendingTxCommitQueueSize()  
      protected RaftActorRecoveryCohort getRaftActorRecoveryCohort()
      Returns the RaftActorRecoveryCohort to participate in persistence recovery.
      RaftActorSnapshotCohort getRaftActorSnapshotCohort()
      Returns the RaftActorSnapshotCohort to participate in snapshot captures.
      protected Optional<akka.actor.ActorRef> getRoleChangeNotifier()
      Notifier Actor for this RaftActor to notify when a role change happens.
      protected void handleBatchedModificationsLocal​(BatchedModifications batched, akka.actor.ActorRef sender)  
      protected void handleNonRaftCommand​(Object message)
      Method exposed for subclasses to plug-in their logic.
      protected void handleRecover​(Object message)  
      protected boolean isIsolatedLeader()  
      String journalPluginId()  
      protected LeaderStateChanged newLeaderStateChanged​(String memberId, String leaderId, short leaderPayloadVersion)  
      protected OnDemandRaftState.AbstractBuilder<?,​?> newOnDemandRaftStateBuilder()  
      protected void onDatastoreContext​(DatastoreContext context)  
      protected void onLeaderChanged​(String oldLeader, String newLeader)  
      protected void onRecoveryComplete()
      This method is called when recovery is complete.
      protected void onStateChanged()
      This method will be called by the RaftActor when the state of the RaftActor changes.
      protected void pauseLeader​(Runnable operation)
      This method is called prior to operations such as leadership transfer and actor shutdown when the leader must pause or stop its duties.
      String persistenceId()  
      void postStop()  
      protected void unpauseLeader()
      This method is invoked when the actions hooked to the leader becoming paused failed to execute and the leader should resume normal operations.
      • Methods inherited from class akka.persistence.AbstractPersistentActor

        akka$actor$StashSupport$_setter_$akka$actor$StashSupport$$capacity_$eq, akka$actor$StashSupport$_setter_$mailbox_$eq, akka$actor$StashSupport$$capacity, akka$actor$StashSupport$$theStash, akka$actor$StashSupport$$theStash_$eq, akka$persistence$Eventsourced$_setter_$akka$persistence$Eventsourced$$extension_$eq, akka$persistence$Eventsourced$_setter_$akka$persistence$Eventsourced$$instanceId_$eq, akka$persistence$Eventsourced$_setter_$akka$persistence$Eventsourced$$internalStash_$eq, akka$persistence$Eventsourced$_setter_$akka$persistence$Eventsourced$$maxMessageBatchSize_$eq, akka$persistence$Eventsourced$_setter_$akka$persistence$Eventsourced$$pendingInvocations_$eq, akka$persistence$Eventsourced$_setter_$akka$persistence$Eventsourced$$persistingEvents_$eq, akka$persistence$Eventsourced$_setter_$akka$persistence$Eventsourced$$processingCommands_$eq, akka$persistence$Eventsourced$_setter_$akka$persistence$Eventsourced$$unstashFilterPredicate_$eq, akka$persistence$Eventsourced$_setter_$akka$persistence$Eventsourced$$writerUuid_$eq, akka$persistence$Eventsourced$$_lastSequenceNr, akka$persistence$Eventsourced$$_lastSequenceNr_$eq, akka$persistence$Eventsourced$$currentState, akka$persistence$Eventsourced$$currentState_$eq, akka$persistence$Eventsourced$$eventBatch, akka$persistence$Eventsourced$$eventBatch_$eq, akka$persistence$Eventsourced$$extension, akka$persistence$Eventsourced$$instanceId, akka$persistence$Eventsourced$$internalStash, akka$persistence$Eventsourced$$journalBatch, akka$persistence$Eventsourced$$journalBatch_$eq, akka$persistence$Eventsourced$$maxMessageBatchSize, akka$persistence$Eventsourced$$pendingInvocations, akka$persistence$Eventsourced$$pendingStashingPersistInvocations, akka$persistence$Eventsourced$$pendingStashingPersistInvocations_$eq, akka$persistence$Eventsourced$$persistingEvents, akka$persistence$Eventsourced$$processingCommands, akka$persistence$Eventsourced$$sequenceNr, akka$persistence$Eventsourced$$sequenceNr_$eq, akka$persistence$Eventsourced$$unstashFilterPredicate, akka$persistence$Eventsourced$$writeInProgress, akka$persistence$Eventsourced$$writeInProgress_$eq, akka$persistence$Eventsourced$$writerUuid, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, clearStash, createStash, defer, deferAsync, deleteMessages, deleteSnapshot, deleteSnapshots, internalDefer, internalDeferAsync, internalDeleteMessagesBeforeSnapshot, internalPersist, internalPersistAll, internalPersistAllAsync, internalPersistAsync, internalStashOverflowStrategy, journal, lastSequenceNr, loadSnapshot, mailbox, onPersistFailure, onPersistRejected, onRecoveryFailure, onReplaySuccess, persist, persistAll, persistAllAsync, persistAsync, prepend, preRestart, receiveCommand, receiveRecover, recovery, recoveryFinished, recoveryRunning, saveSnapshot, snapshotPluginId, snapshotStore, snapshotterId, stash, unhandled, unstash, unstashAll, unstashAll
      • Methods inherited from class akka.actor.AbstractActor

        akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, context, emptyBehavior, getContext, getSelf, getSender, postRestart, preRestart, receive, receiveBuilder, self, sender, supervisorStrategy
      • Methods inherited from interface akka.actor.Actor

        akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, context, postRestart, receive, self, sender, supervisorStrategy
      • Methods inherited from interface akka.persistence.Eventsourced

        akka$persistence$Eventsourced$$changeState, akka$persistence$Eventsourced$$flushBatch, akka$persistence$Eventsourced$$flushJournalBatch, akka$persistence$Eventsourced$$log, akka$persistence$Eventsourced$$peekApplyHandler, akka$persistence$Eventsourced$$recovering, akka$persistence$Eventsourced$$setLastSequenceNr, akka$persistence$Eventsourced$$startRecovery, akka$persistence$Eventsourced$$stashInternally, akka$persistence$Eventsourced$$unstashInternally, akka$persistence$Eventsourced$$updateLastSequenceNr, akka$persistence$Eventsourced$$writeEventFailed, akka$persistence$Eventsourced$$writeEventRejected, akka$persistence$Eventsourced$$writeEventSucceeded
      • Methods inherited from interface akka.actor.StashSupport

        context, self
    • Method Detail

      • postStop

        public void postStop()
                      throws Exception
        Specified by:
        postStop in interface akka.actor.Actor
        Specified by:
        postStop in interface akka.actor.UnrestrictedStash
        Overrides:
        postStop in class RaftActor
        Throws:
        Exception
      • 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
      • getPendingTxCommitQueueSize

        public int getPendingTxCommitQueueSize()
      • getCohortCacheSize

        public int getCohortCacheSize()
      • getRoleChangeNotifier

        protected Optional<akka.actor.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.
      • onDatastoreContext

        protected void onDatastoreContext​(DatastoreContext context)
      • handleBatchedModificationsLocal

        protected void handleBatchedModificationsLocal​(BatchedModifications batched,
                                                       akka.actor.ActorRef sender)
      • isIsolatedLeader

        protected boolean isIsolatedLeader()
      • 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 void applyState​(akka.actor.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 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
      • convertPendingTransactionsToMessages

        public Collection<?> convertPendingTransactionsToMessages()
        Clears all pending transactions and converts them to messages to be forwarded to a new leader.
        Returns:
        the converted messages
      • pauseLeader

        protected 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 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
      • persistenceId

        public final String persistenceId()
      • journalPluginId

        public String journalPluginId()
        Specified by:
        journalPluginId in interface akka.persistence.PersistenceIdentity
        Overrides:
        journalPluginId in class akka.persistence.AbstractPersistentActor