Bug 6587: Retain state when transitioning between Leader and IsolatedLeader
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / behaviors / IsolatedLeader.java
index c969586..a02e400 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.raft.behaviors;
 
 import akka.actor.ActorRef;
+import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.raft.RaftActorContext;
 import org.opendaylight.controller.cluster.raft.RaftState;
 import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply;
@@ -26,8 +27,12 @@ import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply;
  *
  */
 public class IsolatedLeader extends AbstractLeader {
+    IsolatedLeader(RaftActorContext context, @Nullable AbstractLeader initializeFromLeader) {
+        super(context, RaftState.IsolatedLeader, initializeFromLeader);
+    }
+
     public IsolatedLeader(RaftActorContext context) {
-        super(context, RaftState.IsolatedLeader);
+        this(context, null);
     }
 
     // we received an Append Entries reply, we should switch the Behavior to Leader
@@ -40,7 +45,7 @@ public class IsolatedLeader extends AbstractLeader {
         // changes its state to Follower, hence we only need to switch to Leader if the state is still Isolated
         if (ret.state() == RaftState.IsolatedLeader && !isLeaderIsolated()) {
             LOG.info("IsolatedLeader {} switching from IsolatedLeader to Leader", getLeaderId());
-            return internalSwitchBehavior(RaftState.Leader);
+            return internalSwitchBehavior(new Leader(context, this));
         }
         return ret;
     }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.