Class RaftActorContextImpl

  • All Implemented Interfaces:
    RaftActorContext

    public class RaftActorContextImpl
    extends Object
    implements RaftActorContext
    Implementation of the RaftActorContext interface.
    Author:
    Moiz Raja, Thomas Pantelis
    • Method Detail

      • setPayloadVersion

        public void setPayloadVersion​(short payloadVersion)
      • getPayloadVersion

        public short getPayloadVersion()
        Description copied from interface: RaftActorContext
        Returns the payload version to be used when replicating data.
        Specified by:
        getPayloadVersion in interface RaftActorContext
        Returns:
        the payload version.
      • setConfigParams

        public void setConfigParams​(ConfigParams configParams)
      • actorOf

        public akka.actor.ActorRef actorOf​(akka.actor.Props props)
        Description copied from interface: RaftActorContext
        Creates a new local actor.
        Specified by:
        actorOf in interface RaftActorContext
        Parameters:
        props - the Props used to create the actor.
        Returns:
        a reference to the newly created actor.
      • actorSelection

        public akka.actor.ActorSelection actorSelection​(String path)
        Description copied from interface: RaftActorContext
        Creates an actor selection.
        Specified by:
        actorSelection in interface RaftActorContext
        Parameters:
        path - the path.
        Returns:
        an actor selection for the given actor path.
      • getId

        public String getId()
        Description copied from interface: RaftActorContext
        Returns the identifier for the RaftActor. This identifier represents the name of the actor whose common state is being shared.
        Specified by:
        getId in interface RaftActorContext
        Returns:
        the identifier
      • getActor

        public akka.actor.ActorRef getActor()
        Description copied from interface: RaftActorContext
        Returns the reference to the RaftActor.
        Specified by:
        getActor in interface RaftActorContext
        Returns:
        the reference to the RaftActor itself. This can be used to send messages to the RaftActor
      • getCluster

        public Optional<akka.cluster.Cluster> getCluster()
        Description copied from interface: RaftActorContext
        The akka Cluster singleton for the actor system if one is configured.
        Specified by:
        getCluster in interface RaftActorContext
        Returns:
        an Optional containing the Cluster instance is present.
      • getCommitIndex

        public long getCommitIndex()
        Description copied from interface: RaftActorContext
        Returns the index of highest log entry known to be committed.
        Specified by:
        getCommitIndex in interface RaftActorContext
        Returns:
        index of highest log entry known to be committed.
      • setCommitIndex

        public void setCommitIndex​(long commitIndex)
        Description copied from interface: RaftActorContext
        Sets the index of highest log entry known to be committed.
        Specified by:
        setCommitIndex in interface RaftActorContext
        Parameters:
        commitIndex - new commit index
      • getLastApplied

        public long getLastApplied()
        Description copied from interface: RaftActorContext
        Returns index of highest log entry applied to state machine.
        Specified by:
        getLastApplied in interface RaftActorContext
        Returns:
        index of highest log entry applied to state machine.
      • setLastApplied

        public void setLastApplied​(long lastApplied)
        Description copied from interface: RaftActorContext
        Sets index of highest log entry applied to state machine.
        Specified by:
        setLastApplied in interface RaftActorContext
        Parameters:
        lastApplied - the new applied index.
      • getActorSystem

        public akka.actor.ActorSystem getActorSystem()
        Description copied from interface: RaftActorContext
        Returns the The ActorSystem associated with this context.
        Specified by:
        getActorSystem in interface RaftActorContext
        Returns:
        the ActorSystem.
      • getPeerInfo

        public PeerInfo getPeerInfo​(String peerId)
        Description copied from interface: RaftActorContext
        Returns the PeerInfo for the given peer.
        Specified by:
        getPeerInfo in interface RaftActorContext
        Parameters:
        peerId - the id of the peer
        Returns:
        the PeerInfo or null if not found
      • getPeerAddress

        public String getPeerAddress​(String peerId)
        Description copied from interface: RaftActorContext
        Gets the address of a peer as a String. This is the same format in which a consumer would provide the address.
        Specified by:
        getPeerAddress in interface RaftActorContext
        Parameters:
        peerId - the id of the peer.
        Returns:
        the address of the peer or null if the address has not yet been resolved.
      • addToPeers

        public void addToPeers​(String peerId,
                               String address,
                               VotingState votingState)
        Description copied from interface: RaftActorContext
        Adds a new peer.
        Specified by:
        addToPeers in interface RaftActorContext
        Parameters:
        peerId - the id of the new peer.
        address - the address of the new peer.
        votingState - the VotingState of the new peer.
      • getPeerActorSelection

        public akka.actor.ActorSelection getPeerActorSelection​(String peerId)
        Description copied from interface: RaftActorContext
        Returns an ActorSelection for a peer.
        Specified by:
        getPeerActorSelection in interface RaftActorContext
        Parameters:
        peerId - the id of the peer.
        Returns:
        the actorSelection corresponding to the peer or null if the address has not yet been resolved.
      • setPeerAddress

        public void setPeerAddress​(String peerId,
                                   String peerAddress)
        Description copied from interface: RaftActorContext
        Sets the address of a peer.
        Specified by:
        setPeerAddress in interface RaftActorContext
        Parameters:
        peerId - the id of the peer.
        peerAddress - the address of the peer.
      • getTotalMemory

        public long getTotalMemory()
        Description copied from interface: RaftActorContext
        Returns the total available memory for use in calculations. Normally this returns JVM's max memory but can be overridden for unit tests.
        Specified by:
        getTotalMemory in interface RaftActorContext
        Returns:
        the total memory.
      • hasFollowers

        public boolean hasFollowers()
        Description copied from interface: RaftActorContext
        Determines if there are any peer followers.
        Specified by:
        hasFollowers in interface RaftActorContext
        Returns:
        true if there are followers otherwise false.
      • isDynamicServerConfigurationInUse

        public boolean isDynamicServerConfigurationInUse()
        Description copied from interface: RaftActorContext
        Determines if there have been any dynamic server configuration changes applied.
        Specified by:
        isDynamicServerConfigurationInUse in interface RaftActorContext
        Returns:
        true if dynamic server configuration changes have been applied, false otherwise, meaning that static peer configuration is still in use.
      • getPeerServerInfo

        public ServerConfigurationPayload getPeerServerInfo​(boolean includeSelf)
        Description copied from interface: RaftActorContext
        Returns the peer information as a ServerConfigurationPayload if dynamic server configurations have been applied.
        Specified by:
        getPeerServerInfo in interface RaftActorContext
        Parameters:
        includeSelf - include this peer's info.
        Returns:
        the peer information as a ServerConfigurationPayload or null if no dynamic server configurations have been applied.
      • isVotingMember

        public boolean isVotingMember()
        Description copied from interface: RaftActorContext
        Determines if this peer is a voting member of the cluster.
        Specified by:
        isVotingMember in interface RaftActorContext
        Returns:
        true if this peer is a voting member, false otherwise.
      • anyVotingPeers

        public boolean anyVotingPeers()
        Description copied from interface: RaftActorContext
        Determines if there are any voting peers.
        Specified by:
        anyVotingPeers in interface RaftActorContext
        Returns:
        true if there are any voting peers, false otherwise.