X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FRaftActorContext.java;h=6b5fffe33103f4626c17b6b3587dadd37d1a7ad8;hp=9d391a1588ba31c575125572db2ef642e3e14e58;hb=b8c6400766f7324dd57d059bd48e435569fe1a27;hpb=10d39810f724474b84d0e6d3f5676a5154593ca2 diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java index 9d391a1588..6b5fffe331 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java @@ -12,7 +12,13 @@ import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.ActorSystem; import akka.actor.Props; -import java.util.Map; +import com.google.common.annotations.VisibleForTesting; +import java.util.Collection; +import java.util.function.LongSupplier; +import javax.annotation.Nullable; +import org.opendaylight.controller.cluster.DataPersistenceProvider; +import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior; +import org.opendaylight.controller.cluster.raft.policy.RaftPolicy; import org.slf4j.Logger; /** @@ -23,15 +29,15 @@ import org.slf4j.Logger; public interface RaftActorContext { /** * Create a new local actor - * @param props - * @return + * @param props + * @return a reference to the newly created actor */ ActorRef actorOf(Props props); /** * Create a actor selection * @param path - * @return + * @return an actor selection for the given actor path */ ActorSelection actorSelection(String path); @@ -39,54 +45,47 @@ public interface RaftActorContext { * Get the identifier for the RaftActor. This identifier represents the * name of the actor whose common state is being shared. For example the * id could be 'inventory' + * * @return the identifier */ String getId(); /** - * A reference to the RaftActor itself. This could be used to send messages + * @return A reference to the RaftActor itself. This could be used to send messages * to the RaftActor - * @return */ ActorRef getActor(); /** - * Get the ElectionTerm information - * @return + * @return the ElectionTerm information */ ElectionTerm getTermInformation(); /** - * index of highest log entry known to be - * committed (initialized to 0, increases - * monotonically) - * @return + * @return index of highest log entry known to be committed (initialized to 0, increases monotonically) */ long getCommitIndex(); /** - * + * @param commitIndex new commit index */ void setCommitIndex(long commitIndex); /** - * index of highest log entry applied to state - * machine (initialized to 0, increases - * monotonically) - * @return + * @return index of highest log entry applied to state machine (initialized to 0, increases monotonically) */ long getLastApplied(); /** - * + * @param lastApplied the index of the last log entry that was applied to the state */ void setLastApplied(long lastApplied); /** * - * @param replicatedLog + * @param replicatedLog the replicated log of the current RaftActor */ void setReplicatedLog(ReplicatedLog replicatedLog); @@ -101,20 +100,10 @@ public interface RaftActorContext { ActorSystem getActorSystem(); /** - * Get the logger to be used for logging messages - * - * @return + * @return the logger to be used for logging messages to a log file */ Logger getLogger(); - /** - * Get a mapping of peerId's to their addresses - * - * @return - * - */ - Map getPeerAddresses(); - /** * Get the address of the peer as a String. This is the same format in * which a consumer would provide the address @@ -125,12 +114,36 @@ public interface RaftActorContext { */ String getPeerAddress(String peerId); + /** + * @param serverCfgPayload + */ + void updatePeerIds(ServerConfigurationPayload serverCfgPayload); + + /** + * @return list of PeerInfo + */ + Collection getPeers(); + + /** + * @return the list of peer IDs. + */ + Collection getPeerIds(); + + /** + * Get the PeerInfo for the given peer. + * + * @param peerId + * @return the PeerInfo + */ + PeerInfo getPeerInfo(String peerId); + /** * Add to actor peers + * * @param name * @param address */ - void addToPeers(String name, String address); + void addToPeers(String name, String address, VotingState votingState); /** * @@ -166,8 +179,72 @@ public interface RaftActorContext { */ ConfigParams getConfigParams(); - void setSnapshotCaptureInitiated(boolean snapshotCaptureInitiated); + /** + * + * @return the SnapshotManager for this RaftActor + */ + SnapshotManager getSnapshotManager(); - boolean isSnapshotCaptureInitiated(); + /** + * + * @return the DataPersistenceProvider for this RaftActor + */ + DataPersistenceProvider getPersistenceProvider(); + /** + * + * @return true if the RaftActor has followers else false + */ + boolean hasFollowers(); + + /** + * + * @return the total memory used by the ReplicatedLog + */ + long getTotalMemory(); + + /** + * + * @param retriever a supplier of the total memory metric + */ + @VisibleForTesting + void setTotalMemoryRetriever(LongSupplier retriever); + + /** + * + * @return the payload version to be used when replicating data + */ + short getPayloadVersion(); + + /** + * @return an implementation of the RaftPolicy so that the Raft code can be adapted + */ + RaftPolicy getRaftPolicy(); + + /** + * @return true if there are any dynamic server configuration changes available, + * false if static peer configurations are still in use + */ + boolean isDynamicServerConfigurationInUse(); + + /** + * Configures the dynamic server configurations are avaialble for the RaftActor + */ + void setDynamicServerConfigurationInUse(); + + /** + * @return the RaftActor's peer information as a ServerConfigurationPayload if the + * dynamic server configurations are available, otherwise returns null + */ + @Nullable ServerConfigurationPayload getPeerServerInfo(boolean includeSelf); + + /** + * @return true if this RaftActor is a voting member of the cluster, false otherwise. + */ + boolean isVotingMember(); + + /** + * @return current behavior attached to the raft actor. + */ + RaftActorBehavior getCurrentBehavior(); }