Transfer leadership in PreLeader state 24/60024/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 6 Jul 2017 13:21:16 +0000 (15:21 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 6 Jul 2017 13:21:16 +0000 (15:21 +0200)
Rather than dying when requested to shutdown in pre-leader state,
follow the same code path we perform in normal leader mode, i.e.
transfer leadership.

Change-Id: I2ca30d44626df05c5f8b5ff6984eea20c7bf0949
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java

index 9d970f1695ddb422c9a364428f5f9214387282de..7ec9f2743c7b6472af4e6ccf521e7c5b4f030e02 100644 (file)
@@ -367,10 +367,15 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
         shuttingDown = true;
 
         final RaftActorBehavior currentBehavior = context.getCurrentBehavior();
         shuttingDown = true;
 
         final RaftActorBehavior currentBehavior = context.getCurrentBehavior();
-        if (currentBehavior.state() != RaftState.Leader) {
-            // For non-leaders shutdown is a no-op
-            self().tell(PoisonPill.getInstance(), self());
-            return;
+        switch (currentBehavior.state()) {
+            case Leader:
+            case PreLeader:
+                // Fall-through to more work
+                break;
+            default:
+                // For non-leaders shutdown is a no-op
+                self().tell(PoisonPill.getInstance(), self());
+                return;
         }
 
         if (context.hasFollowers()) {
         }
 
         if (context.hasFollowers()) {