Fix sporadic failures in ClusterAdminRpcServiceTest 85/35285/2
authorTom Pantelis <tpanteli@brocade.com>
Tue, 23 Feb 2016 18:10:21 +0000 (13:10 -0500)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 23 Feb 2016 21:06:38 +0000 (21:06 +0000)
The testAddShardReplica is failing sporadically indirectly due to
https://git.opendaylight.org/gerrit/#/c/35097/. The leader's payload
version was -1 so a transaction's BatchedModifications instance was
serialized to the legacy protobuf message type and thus wasn't delivered.

The underlying problem is that RaftActor.updateConfigParams
needs to pass the previous leader's payload version when re-constructing
the Follower instance on RaftPolicy change.

Change-Id: Id6b8da98c145f2e265dddbc1b27384d54e400370
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
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/behaviors/Follower.java

index 2bd7592..aea1e9f 100644 (file)
@@ -612,10 +612,11 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
             RaftActorBehavior behavior = currentBehavior.getDelegate();
             if(behavior instanceof Follower) {
                 String previousLeaderId = ((Follower)behavior).getLeaderId();
+                short previousLeaderPayloadVersion = behavior.getLeaderPayloadVersion();
 
                 LOG.debug("{}: Re-initializing to Follower with previous leaderId {}", persistenceId(), previousLeaderId);
 
-                changeCurrentBehavior(new Follower(context, previousLeaderId));
+                changeCurrentBehavior(new Follower(context, previousLeaderId, previousLeaderPayloadVersion));
             } else {
                 initializeBehavior();
             }
index 0a9f3eb..afb8f29 100644 (file)
@@ -45,12 +45,13 @@ public class Follower extends AbstractRaftActorBehavior {
     private static final int SYNC_THRESHOLD = 10;
 
     public Follower(RaftActorContext context) {
-        this(context, null);
+        this(context, null, (short)-1);
     }
 
-    public Follower(RaftActorContext context, String initialLeaderId) {
+    public Follower(RaftActorContext context, String initialLeaderId, short initialLeaderPayloadVersion) {
         super(context, RaftState.Follower);
         leaderId = initialLeaderId;
+        setLeaderPayloadVersion(initialLeaderPayloadVersion);
 
         initialSyncStatusTracker = new SyncStatusTracker(context.getActor(), getId(), SYNC_THRESHOLD);