Make AbstractRaftActorBehavior.state() final 66/36566/1
authorRobert Varga <rovarga@cisco.com>
Tue, 22 Mar 2016 17:38:46 +0000 (18:38 +0100)
committerRobert Varga <rovarga@cisco.com>
Tue, 22 Mar 2016 17:38:46 +0000 (18:38 +0100)
This removes the potential inconsistency in IsolatedLeader, where the internal
field (state) would be seen as Leader whereas the reported value (state()) would be
IsolatedLeader.

Change-Id: I079f934e31bb52b306ccc21e16b6c23442e87ce4
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/IsolatedLeader.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java

index 58eaaf5..83d0a52 100644 (file)
@@ -92,8 +92,8 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior {
 
     private Optional<SnapshotHolder> snapshot;
 
-    public AbstractLeader(RaftActorContext context) {
-        super(context, RaftState.Leader);
+    protected AbstractLeader(RaftActorContext context, RaftState state) {
+        super(context, state);
 
         setLeaderPayloadVersion(context.getPayloadVersion());
 
index 8f544dc..a623660 100644 (file)
@@ -27,7 +27,7 @@ import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply;
  */
 public class IsolatedLeader extends AbstractLeader {
     public IsolatedLeader(RaftActorContext context) {
-        super(context);
+        super(context, RaftState.IsolatedLeader);
     }
 
     // we received an Append Entries reply, we should switch the Behavior to Leader
@@ -44,9 +44,4 @@ public class IsolatedLeader extends AbstractLeader {
         }
         return ret;
     }
-
-    @Override
-    public RaftState state() {
-        return RaftState.IsolatedLeader;
-    }
 }
index b941cfc..380e22a 100644 (file)
@@ -56,7 +56,7 @@ public class Leader extends AbstractLeader {
     private @Nullable LeadershipTransferContext leadershipTransferContext;
 
     public Leader(RaftActorContext context) {
-        super(context);
+        super(context, RaftState.Leader);
         isolatedLeaderCheck = Stopwatch.createStarted();
     }