BUG 2187 - Creating ShardReplica
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / RaftActor.java
index efcf27da20283bda77cb6b2ac2fa8bc3bbd700ad..0154c890b6665b77cec8607dce9d344db592e02b 100644 (file)
@@ -486,7 +486,20 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
     }
 
     protected void updateConfigParams(ConfigParams configParams) {
+
+        // obtain the RaftPolicy for oldConfigParams and the updated one.
+        String oldRaftPolicy = context.getConfigParams().
+            getCustomRaftPolicyImplementationClass();
+        String newRaftPolicy = configParams.
+            getCustomRaftPolicyImplementationClass();
+
+        LOG.debug ("RaftPolicy used with prev.config {}, RaftPolicy used with newConfig {}",
+            oldRaftPolicy, newRaftPolicy);
         context.setConfigParams(configParams);
+        if (!Objects.equal(oldRaftPolicy, newRaftPolicy)) {
+            //RaftPolicy is modifed for the Actor. Re-initialize its current behaviour
+            initializeBehavior();
+        }
     }
 
     public final DataPersistenceProvider persistence() {