Fix raw type warnings
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / DefaultConfigParamsImpl.java
index 35dee10ba45d4b3862c366787905fb0db10b4f12..f5f410c75b5f6117bd1f3fea6371d521a971517a 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.controller.cluster.raft;
 
+import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.base.Supplier;
 import com.google.common.base.Suppliers;
 import java.util.concurrent.TimeUnit;
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.cluster.raft.policy.DefaultRaftPolicy;
 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
 import org.slf4j.Logger;
@@ -58,12 +60,14 @@ public class DefaultConfigParamsImpl implements ConfigParams {
     // in-memory journal can use before it needs to snapshot
     private int snapshotDataThresholdPercentage = 12;
 
-    private int snaphotChunkSize = SNAPSHOT_CHUNK_SIZE;
+    private int snapshotChunkSize = SNAPSHOT_CHUNK_SIZE;
 
     private long electionTimeoutFactor = 2;
     private String customRaftPolicyImplementationClass;
 
-    Supplier<RaftPolicy> policySupplier = Suppliers.memoize(new PolicySupplier());
+    private final Supplier<RaftPolicy> policySupplier = Suppliers.memoize(new PolicySupplier());
+
+    private PeerAddressResolver peerAddressResolver = NoopPeerAddressResolver.INSTANCE;
 
     public void setHeartBeatInterval(FiniteDuration heartBeatInterval) {
         this.heartBeatInterval = heartBeatInterval;
@@ -78,8 +82,8 @@ public class DefaultConfigParamsImpl implements ConfigParams {
         this.snapshotDataThresholdPercentage = snapshotDataThresholdPercentage;
     }
 
-    public void setSnaphotChunkSize(int snaphotChunkSize) {
-        this.snaphotChunkSize = snaphotChunkSize;
+    public void setSnapshotChunkSize(int snapshotChunkSize) {
+        this.snapshotChunkSize = snapshotChunkSize;
     }
 
     public void setJournalRecoveryLogBatchSize(int journalRecoveryLogBatchSize) {
@@ -99,6 +103,11 @@ public class DefaultConfigParamsImpl implements ConfigParams {
         this.customRaftPolicyImplementationClass = customRaftPolicyImplementationClass;
     }
 
+    @Override
+    public String getCustomRaftPolicyImplementationClass() {
+        return customRaftPolicyImplementationClass;
+    }
+
     @Override
     public long getSnapshotBatchCount() {
         return snapshotBatchCount;
@@ -131,7 +140,7 @@ public class DefaultConfigParamsImpl implements ConfigParams {
 
     @Override
     public int getSnapshotChunkSize() {
-        return snaphotChunkSize;
+        return snapshotChunkSize;
     }
 
     @Override
@@ -158,11 +167,13 @@ public class DefaultConfigParamsImpl implements ConfigParams {
         @Override
         public RaftPolicy get() {
             if(Strings.isNullOrEmpty(DefaultConfigParamsImpl.this.customRaftPolicyImplementationClass)){
+                LOG.debug("No custom RaftPolicy specified. Using DefaultRaftPolicy");
                 return DefaultRaftPolicy.INSTANCE;
             }
             try {
                 String className = DefaultConfigParamsImpl.this.customRaftPolicyImplementationClass;
-                Class c = Class.forName(className);
+                LOG.info("Trying to use custom RaftPolicy {}", className);
+                Class<?> c = Class.forName(className);
                 RaftPolicy obj = (RaftPolicy)c.newInstance();
                 return obj;
             } catch (Exception e) {
@@ -175,4 +186,13 @@ public class DefaultConfigParamsImpl implements ConfigParams {
             return DefaultRaftPolicy.INSTANCE;
         }
     }
+
+    @Override
+    public PeerAddressResolver getPeerAddressResolver() {
+        return peerAddressResolver;
+    }
+
+    public void setPeerAddressResolver(@Nonnull PeerAddressResolver peerAddressResolver) {
+        this.peerAddressResolver = Preconditions.checkNotNull(peerAddressResolver);
+    }
 }