BUG-8618: introduce RaftActor.unpauseLeader() 19/60419/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 6 Jul 2017 15:15:21 +0000 (17:15 +0200)
committerRobert Varga <nite@hq.sk>
Sat, 15 Jul 2017 08:47:58 +0000 (08:47 +0000)
This is a preparatory patch, which notifies RaftActor when
the operation hooked to pauseLeader() fails to complete and the
leader should resume its normal operation.

This is needed to correctly resume operations of tell-based protocol
after a pauseLeader() completes without actually changing the leader.

Change-Id: Ia00e52ebb327575a484af62bf0c31131a33303b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3a10a45e0f78337435c8bc84015c4724a9fa7741)

opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java

index 7ec9f2743c7b6472af4e6ccf521e7c5b4f030e02..6d01752a95e17b4c45b4e62f7b96fc85ee730f3c 100644 (file)
@@ -856,6 +856,17 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
         operation.run();
     }
 
+    /**
+     * This method is invoked when the actions hooked to the leader becoming paused failed to execute and the leader
+     * should resume normal operations.
+     *
+     * <p>
+     * Note this method can be invoked even before the operation supplied to {@link #pauseLeader(Runnable)} is invoked.
+     */
+    protected void unpauseLeader() {
+
+    }
+
     protected void onLeaderChanged(String oldLeader, String newLeader) {
     }
 
index 0a22abb9657ff5813ce27a34736e78e5b7e3bc3a..5b27d50130a980891dbbbc2f072d0705fa3b8c9b 100644 (file)
@@ -178,6 +178,7 @@ public class RaftActorLeadershipTransferCohort {
                         raftActor.getLeaderId(), transferTimer);
             } else {
                 LOG.warn("{}: Failed to transfer leadership in {}", raftActor.persistenceId(), transferTimer);
+                raftActor.unpauseLeader();
             }
         }
 
index de6c9dea696e6a737bf6fd44b6db9cf601aa14fb..10cef862fce2e42f731ebe01ff6775348c65476a 100644 (file)
@@ -883,6 +883,12 @@ public class Shard extends RaftActor {
         store.setRunOnPendingTransactionsComplete(operation);
     }
 
+    @Override
+    protected void unpauseLeader() {
+        LOG.debug("{}: In unpauseLeader", persistenceId());
+        store.setRunOnPendingTransactionsComplete(null);
+    }
+
     @Override
     protected OnDemandRaftState.AbstractBuilder<?> newOnDemandRaftStateBuilder() {
         return OnDemandShardState.newBuilder().treeChangeListenerActors(treeChangeSupport.getListenerActors())