Bug 5450: Query akka cluster state on Follower ElectionTimeout
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / RaftActorContext.java
index 267a4d2b7e995894d8feb7a36261f24653d59e74..ba6645f2407c55afdbbdae8cffd524dfbcc466a7 100644 (file)
@@ -12,12 +12,15 @@ import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
 import akka.actor.Props;
+import akka.cluster.Cluster;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Supplier;
 import java.util.Collection;
+import java.util.Optional;
+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.persisted.ServerConfigurationPayload;
 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
 import org.slf4j.Logger;
 
@@ -56,6 +59,13 @@ public interface RaftActorContext {
      */
     ActorRef getActor();
 
+    /**
+     * The akka Cluster singleton for the actor system if one is configured.
+     *
+     * @return an Optional containing the CLuster instance is present.
+     */
+    Optional<Cluster> getCluster();
+
     /**
      * @return the ElectionTerm information
      */
@@ -208,7 +218,7 @@ public interface RaftActorContext {
      * @param retriever a supplier of the total memory metric
      */
     @VisibleForTesting
-    void setTotalMemoryRetriever(Supplier<Long> retriever);
+    void setTotalMemoryRetriever(LongSupplier retriever);
 
     /**
      *
@@ -243,6 +253,11 @@ public interface RaftActorContext {
      */
     boolean isVotingMember();
 
+    /**
+     * @return true if there are any voting peers, false otherwise.
+     */
+    boolean anyVotingPeers();
+
     /**
      * @return current behavior attached to the raft actor.
      */