public class RaftActorContextImpl extends Object implements RaftActorContext
Constructor and Description |
---|
RaftActorContextImpl(akka.actor.ActorRef actor,
akka.actor.ActorContext context,
String id,
@NonNull ElectionTerm termInformation,
long commitIndex,
long lastApplied,
@NonNull Map<String,String> peerAddresses,
@NonNull ConfigParams configParams,
@NonNull DataPersistenceProvider persistenceProvider,
@NonNull Consumer<ApplyState> applyStateConsumer,
@NonNull org.slf4j.Logger logger,
@NonNull Executor executor) |
Modifier and Type | Method and Description |
---|---|
akka.actor.ActorRef |
actorOf(akka.actor.Props props)
Creates a new local actor.
|
akka.actor.ActorSelection |
actorSelection(String path)
Creates an actor selection.
|
void |
addToPeers(String peerId,
String address,
VotingState votingState)
Adds a new peer.
|
boolean |
anyVotingPeers()
Determines if there are any voting peers.
|
akka.actor.ActorRef |
getActor()
Returns the reference to the RaftActor.
|
akka.actor.ActorSystem |
getActorSystem()
Returns the The ActorSystem associated with this context.
|
Consumer<ApplyState> |
getApplyStateConsumer()
Returns the consumer of ApplyState operations.
|
Optional<akka.cluster.Cluster> |
getCluster()
The akka Cluster singleton for the actor system if one is configured.
|
long |
getCommitIndex()
Returns the index of highest log entry known to be committed.
|
ConfigParams |
getConfigParams()
Returns the ConfigParams instance.
|
RaftActorBehavior |
getCurrentBehavior()
Returns the current behavior attached to the RaftActor.
|
Executor |
getExecutor()
Return an Executor which is guaranteed to run tasks in the context of
RaftActorContext.getActor() . |
FileBackedOutputStreamFactory |
getFileBackedOutputStreamFactory()
Returns the
FileBackedOutputStreamFactory instance with a common configuration. |
String |
getId()
Returns the identifier for the RaftActor.
|
long |
getLastApplied()
Returns index of highest log entry applied to state machine.
|
org.slf4j.Logger |
getLogger()
Returns the logger to be used for logging messages.
|
short |
getPayloadVersion()
Returns the payload version to be used when replicating data.
|
akka.actor.ActorSelection |
getPeerActorSelection(String peerId)
Returns an ActorSelection for a peer.
|
String |
getPeerAddress(String peerId)
Gets the address of a peer as a String.
|
Collection<String> |
getPeerIds()
Returns the id's for each peer.
|
PeerInfo |
getPeerInfo(String peerId)
Returns the PeerInfo for the given peer.
|
Collection<PeerInfo> |
getPeers()
Returns the PeerInfo instances for each peer.
|
ServerConfigurationPayload |
getPeerServerInfo(boolean includeSelf)
Returns the peer information as a ServerConfigurationPayload if dynamic server configurations have been applied.
|
DataPersistenceProvider |
getPersistenceProvider()
Returns the DataPersistenceProvider instance.
|
RaftActorLeadershipTransferCohort |
getRaftActorLeadershipTransferCohort()
Returns the RaftActorLeadershipTransferCohort if leadership transfer is in progress.
|
RaftPolicy |
getRaftPolicy()
Returns the RaftPolicy used to determine certain Raft behaviors.
|
ReplicatedLog |
getReplicatedLog()
Returns the ReplicatedLog instance.
|
SnapshotManager |
getSnapshotManager()
Returns the SnapshotManager instance.
|
ElectionTerm |
getTermInformation()
Returns the current ElectionTerm information.
|
long |
getTotalMemory()
Returns the total available memory for use in calculations.
|
boolean |
hasFollowers()
Determines if there are any peer followers.
|
boolean |
isDynamicServerConfigurationInUse()
Determines if there have been any dynamic server configuration changes applied.
|
boolean |
isVotingMember()
Determines if this peer is a voting member of the cluster.
|
void |
removePeer(String name)
Removes a peer.
|
void |
setCommitIndex(long commitIndex)
Sets the index of highest log entry known to be committed.
|
void |
setConfigParams(ConfigParams configParams) |
void |
setDynamicServerConfigurationInUse()
Sets that dynamic server configuration changes have been applied.
|
void |
setLastApplied(long lastApplied)
Sets index of highest log entry applied to state machine.
|
void |
setPayloadVersion(short payloadVersion) |
void |
setPeerAddress(String peerId,
String peerAddress)
Sets the address of a peer.
|
void |
setRaftActorLeadershipTransferCohort(RaftActorLeadershipTransferCohort leadershipTransferCohort)
Sets the RaftActorLeadershipTransferCohort for transferring leadership.
|
void |
setReplicatedLog(ReplicatedLog replicatedLog)
Sets the ReplicatedLog instance.
|
void |
setTotalMemoryRetriever(LongSupplier retriever)
Sets the retriever of the total memory metric.
|
void |
updatePeerIds(ServerConfigurationPayload serverConfig)
Updates the peers and information to match the given ServerConfigurationPayload.
|
public RaftActorContextImpl(akka.actor.ActorRef actor, akka.actor.ActorContext context, String id, @NonNull ElectionTerm termInformation, long commitIndex, long lastApplied, @NonNull Map<String,String> peerAddresses, @NonNull ConfigParams configParams, @NonNull DataPersistenceProvider persistenceProvider, @NonNull Consumer<ApplyState> applyStateConsumer, @NonNull org.slf4j.Logger logger, @NonNull Executor executor)
public void setPayloadVersion(short payloadVersion)
public short getPayloadVersion()
RaftActorContext
getPayloadVersion
in interface RaftActorContext
public void setConfigParams(ConfigParams configParams)
public akka.actor.ActorRef actorOf(akka.actor.Props props)
RaftActorContext
actorOf
in interface RaftActorContext
props
- the Props used to create the actor.public akka.actor.ActorSelection actorSelection(String path)
RaftActorContext
actorSelection
in interface RaftActorContext
path
- the path.public String getId()
RaftActorContext
getId
in interface RaftActorContext
public akka.actor.ActorRef getActor()
RaftActorContext
getActor
in interface RaftActorContext
public final Executor getExecutor()
RaftActorContext
RaftActorContext.getActor()
.getExecutor
in interface RaftActorContext
public Optional<akka.cluster.Cluster> getCluster()
RaftActorContext
getCluster
in interface RaftActorContext
public ElectionTerm getTermInformation()
RaftActorContext
getTermInformation
in interface RaftActorContext
public long getCommitIndex()
RaftActorContext
getCommitIndex
in interface RaftActorContext
public void setCommitIndex(long commitIndex)
RaftActorContext
setCommitIndex
in interface RaftActorContext
commitIndex
- new commit indexpublic long getLastApplied()
RaftActorContext
getLastApplied
in interface RaftActorContext
public void setLastApplied(long lastApplied)
RaftActorContext
setLastApplied
in interface RaftActorContext
lastApplied
- the new applied index.public void setReplicatedLog(ReplicatedLog replicatedLog)
RaftActorContext
setReplicatedLog
in interface RaftActorContext
replicatedLog
- the ReplicatedLog instance.public ReplicatedLog getReplicatedLog()
RaftActorContext
getReplicatedLog
in interface RaftActorContext
public akka.actor.ActorSystem getActorSystem()
RaftActorContext
getActorSystem
in interface RaftActorContext
public org.slf4j.Logger getLogger()
RaftActorContext
getLogger
in interface RaftActorContext
public Collection<String> getPeerIds()
RaftActorContext
getPeerIds
in interface RaftActorContext
public Collection<PeerInfo> getPeers()
RaftActorContext
getPeers
in interface RaftActorContext
public PeerInfo getPeerInfo(String peerId)
RaftActorContext
getPeerInfo
in interface RaftActorContext
peerId
- the id of the peerpublic String getPeerAddress(String peerId)
RaftActorContext
getPeerAddress
in interface RaftActorContext
peerId
- the id of the peer.public void updatePeerIds(ServerConfigurationPayload serverConfig)
RaftActorContext
updatePeerIds
in interface RaftActorContext
serverConfig
- the ServerConfigurationPayload.public ConfigParams getConfigParams()
RaftActorContext
getConfigParams
in interface RaftActorContext
public void addToPeers(String peerId, String address, VotingState votingState)
RaftActorContext
addToPeers
in interface RaftActorContext
peerId
- the id of the new peer.address
- the address of the new peer.votingState
- the VotingState of the new peer.public void removePeer(String name)
RaftActorContext
removePeer
in interface RaftActorContext
name
- the id of the peer to remove.public akka.actor.ActorSelection getPeerActorSelection(String peerId)
RaftActorContext
getPeerActorSelection
in interface RaftActorContext
peerId
- the id of the peer.public void setPeerAddress(String peerId, String peerAddress)
RaftActorContext
setPeerAddress
in interface RaftActorContext
peerId
- the id of the peer.peerAddress
- the address of the peer.public SnapshotManager getSnapshotManager()
RaftActorContext
getSnapshotManager
in interface RaftActorContext
public long getTotalMemory()
RaftActorContext
getTotalMemory
in interface RaftActorContext
public void setTotalMemoryRetriever(LongSupplier retriever)
RaftActorContext
setTotalMemoryRetriever
in interface RaftActorContext
retriever
- a supplier of the total memory metric.public boolean hasFollowers()
RaftActorContext
hasFollowers
in interface RaftActorContext
public DataPersistenceProvider getPersistenceProvider()
RaftActorContext
getPersistenceProvider
in interface RaftActorContext
public RaftPolicy getRaftPolicy()
RaftActorContext
getRaftPolicy
in interface RaftActorContext
public boolean isDynamicServerConfigurationInUse()
RaftActorContext
isDynamicServerConfigurationInUse
in interface RaftActorContext
public void setDynamicServerConfigurationInUse()
RaftActorContext
setDynamicServerConfigurationInUse
in interface RaftActorContext
public ServerConfigurationPayload getPeerServerInfo(boolean includeSelf)
RaftActorContext
getPeerServerInfo
in interface RaftActorContext
includeSelf
- include this peer's info.public boolean isVotingMember()
RaftActorContext
isVotingMember
in interface RaftActorContext
public boolean anyVotingPeers()
RaftActorContext
anyVotingPeers
in interface RaftActorContext
public RaftActorBehavior getCurrentBehavior()
RaftActorContext
getCurrentBehavior
in interface RaftActorContext
public Consumer<ApplyState> getApplyStateConsumer()
RaftActorContext
getApplyStateConsumer
in interface RaftActorContext
public FileBackedOutputStreamFactory getFileBackedOutputStreamFactory()
RaftActorContext
FileBackedOutputStreamFactory
instance with a common configuration.getFileBackedOutputStreamFactory
in interface RaftActorContext
FileBackedOutputStreamFactory
;public RaftActorLeadershipTransferCohort getRaftActorLeadershipTransferCohort()
RaftActorContext
getRaftActorLeadershipTransferCohort
in interface RaftActorContext
public void setRaftActorLeadershipTransferCohort(RaftActorLeadershipTransferCohort leadershipTransferCohort)
RaftActorContext
setRaftActorLeadershipTransferCohort
in interface RaftActorContext
leadershipTransferCohort
- the RaftActorLeadershipTransferCohort or null to clear the existing oneCopyright © 2019 OpenDaylight. All rights reserved.