Merge "Fixed discard-changes for mdsal netconf, mapping code cleanup."
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / DefaultConfigParamsImpl.java
index 3e6742c17d37c178d30c7d570490ff993c068806..d4d13899eb770e4ee8bb88a634dd85ec2cfb7bbc 100644 (file)
@@ -43,6 +43,7 @@ public class DefaultConfigParamsImpl implements ConfigParams {
     private long snapshotBatchCount = SNAPSHOT_BATCH_COUNT;
     private int journalRecoveryLogBatchSize = JOURNAL_RECOVERY_LOG_BATCH_SIZE;
     private long isolatedLeaderCheckInterval = HEART_BEAT_INTERVAL.$times(1000).toMillis();
+    private FiniteDuration electionTimeOutInterval;
 
     // 12 is just an arbitrary percentage. This is the amount of the total memory that a raft actor's
     // in-memory journal can use before it needs to snapshot
@@ -52,6 +53,7 @@ public class DefaultConfigParamsImpl implements ConfigParams {
 
     public void setHeartBeatInterval(FiniteDuration heartBeatInterval) {
         this.heartBeatInterval = heartBeatInterval;
+        electionTimeOutInterval = null;
     }
 
     public void setSnapshotBatchCount(long snapshotBatchCount) {
@@ -72,6 +74,7 @@ public class DefaultConfigParamsImpl implements ConfigParams {
 
     public void setElectionTimeoutFactor(long electionTimeoutFactor){
         this.electionTimeoutFactor = electionTimeoutFactor;
+        electionTimeOutInterval = null;
     }
 
     @Override
@@ -92,7 +95,11 @@ public class DefaultConfigParamsImpl implements ConfigParams {
 
     @Override
     public FiniteDuration getElectionTimeOutInterval() {
-        return getHeartBeatInterval().$times(electionTimeoutFactor);
+        if(electionTimeOutInterval == null) {
+            electionTimeOutInterval = getHeartBeatInterval().$times(electionTimeoutFactor);
+        }
+
+        return electionTimeOutInterval;
     }
 
     @Override