BUG-3128: rework sal-remoterpc-connector
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / main / java / org / opendaylight / controller / remote / rpc / RemoteRpcProviderConfig.java
index 995b1d5172553f234e6602a11ccb236c19bf0d50..c1846b8e69a034678d1ee1c0ad63ee3f2dd6ea15 100644 (file)
@@ -9,15 +9,15 @@ package org.opendaylight.controller.remote.rpc;
 
 import akka.util.Timeout;
 import com.typesafe.config.Config;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.concurrent.TimeUnit;
 import org.opendaylight.controller.cluster.common.actor.CommonConfig;
 import scala.concurrent.duration.FiniteDuration;
 
-/**
- */
 public class RemoteRpcProviderConfig extends CommonConfig {
 
     protected static final String TAG_RPC_BROKER_NAME = "rpc-broker-name";
+    protected static final String TAG_RPC_REGISTRAR_NAME = "rpc-registrar-name";
     protected static final String TAG_RPC_REGISTRY_NAME = "registry-name";
     protected static final String TAG_RPC_MGR_NAME = "rpc-manager-name";
     protected static final String TAG_RPC_BROKER_PATH = "rpc-broker-path";
@@ -30,38 +30,41 @@ public class RemoteRpcProviderConfig extends CommonConfig {
     private Timeout cachedAskDuration;
     private FiniteDuration cachedGossipTickInterval;
 
-    public RemoteRpcProviderConfig(Config config){
+    public RemoteRpcProviderConfig(final Config config) {
         super(config);
     }
 
-    public String getRpcBrokerName(){
+    public String getRpcBrokerName() {
         return get().getString(TAG_RPC_BROKER_NAME);
     }
 
-    public String getRpcRegistryName(){
+    public String getRpcRegistrarName() {
+        return get().getString(TAG_RPC_REGISTRAR_NAME);
+    }
+
+    public String getRpcRegistryName() {
         return get().getString(TAG_RPC_REGISTRY_NAME);
     }
 
-    public String getRpcManagerName(){
+    public String getRpcManagerName() {
         return get().getString(TAG_RPC_MGR_NAME);
     }
 
-    public String getRpcBrokerPath(){
+    public String getRpcBrokerPath() {
         return get().getString(TAG_RPC_BROKER_PATH);
     }
 
-    public String getRpcRegistryPath(){
+    public String getRpcRegistryPath() {
         return get().getString(TAG_RPC_REGISTRY_PATH);
 
     }
 
-    public String getRpcManagerPath(){
+    public String getRpcManagerPath() {
         return get().getString(TAG_RPC_MGR_PATH);
     }
 
-
-    public Timeout getAskDuration(){
-        if (cachedAskDuration != null){
+    public Timeout getAskDuration() {
+        if (cachedAskDuration != null) {
             return cachedAskDuration;
         }
 
@@ -71,7 +74,7 @@ public class RemoteRpcProviderConfig extends CommonConfig {
         return cachedAskDuration;
     }
 
-    public FiniteDuration getGossipTickInterval(){
+    public FiniteDuration getGossipTickInterval() {
         if (cachedGossipTickInterval != null) {
             return cachedGossipTickInterval;
         }
@@ -82,13 +85,27 @@ public class RemoteRpcProviderConfig extends CommonConfig {
         return cachedGossipTickInterval;
     }
 
-    public static class Builder extends CommonConfig.Builder<Builder>{
+    /**
+     * This is called via blueprint xml as the builder pattern can't be used.
+     */
+    @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE",
+            justification = "Findbugs flags this as an unconfirmed cast of return value but the build method clearly "
+                + "returns RemoteRpcProviderConfig. Perhaps it's confused b/c the build method is overloaded and "
+                + "and differs in return type from the base class.")
+    public static RemoteRpcProviderConfig newInstance(final String actorSystemName, final boolean metricCaptureEnabled,
+            final int mailboxCapacity) {
+        return new Builder(actorSystemName).metricCaptureEnabled(metricCaptureEnabled)
+                .mailboxCapacity(mailboxCapacity).build();
+    }
+
+    public static class Builder extends CommonConfig.Builder<Builder> {
 
-        public Builder(String actorSystemName){
+        public Builder(final String actorSystemName) {
             super(actorSystemName);
 
             //Actor names
             configHolder.put(TAG_RPC_BROKER_NAME, "broker");
+            configHolder.put(TAG_RPC_REGISTRAR_NAME, "registrar");
             configHolder.put(TAG_RPC_REGISTRY_NAME, "registry");
             configHolder.put(TAG_RPC_MGR_NAME, "rpc");
 
@@ -103,16 +120,14 @@ public class RemoteRpcProviderConfig extends CommonConfig {
 
         }
 
-        public Builder gossipTickInterval(String interval) {
+        public Builder gossipTickInterval(final String interval) {
             configHolder.put(TAG_GOSSIP_TICK_INTERVAL, interval);
             return this;
         }
 
         @Override
-        public RemoteRpcProviderConfig build(){
+        public RemoteRpcProviderConfig build() {
             return new RemoteRpcProviderConfig(merge());
         }
     }
-
-
 }