BUG-8618: introduce RaftActor.unpauseLeader() 32/60032/4
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 6 Jul 2017 15:15:21 +0000 (17:15 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 14 Jul 2017 17:16:31 +0000 (17:16 +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>
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 9d970f1695ddb422c9a364428f5f9214387282de..fecf223346dcda3a8d2ab01b726506de0fe58b29 100644 (file)
@@ -851,6 +851,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 4440c8972db91fca202262ec6a0d8f0b0e5b7752..df9753e063b1c18a619ccd08b8bbfcf8d3b9c554 100644 (file)
@@ -857,6 +857,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())