Merge "BUG-2188 :To report (TCP) port number (for the OpenFlow connection) for switch...
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / rpc / RpcManagerImpl.java
index 5b273a376a8d81229c7a997c5ac7018223eb64ff..3619e66e914d0f15eeaf0ba0940fc4b27ddac12f 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.openflowplugin.impl.rpc;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.collect.Iterators;
@@ -33,8 +34,6 @@ public class RpcManagerImpl implements RpcManager {
     private DeviceTerminationPhaseHandler deviceTerminPhaseHandler;
     private final int maxRequestsQuota;
     private final ConcurrentMap<NodeId, RpcContext> contexts = new ConcurrentHashMap<>();
-    private boolean isStatisticsRpcEnabled;
-    private NotificationPublishService notificationPublishService;
 
     private final LifecycleConductor conductor;
 
@@ -59,9 +58,11 @@ public class RpcManagerImpl implements RpcManager {
         final RpcContext rpcContext = new RpcContextImpl(
                 rpcProviderRegistry,
                 deviceContext,
+                deviceContext.getMessageSpy(),
                 maxRequestsQuota,
-                isStatisticsRpcEnabled,
-                notificationPublishService);
+                deviceContext.getDeviceState().getNodeInstanceIdentifier());
+
+        deviceContext.setRpcContext(rpcContext);
 
         Verify.verify(contexts.putIfAbsent(nodeId, rpcContext) == null, "RpcCtx still not closed for node {}", nodeId);
 
@@ -77,7 +78,6 @@ public class RpcManagerImpl implements RpcManager {
         }
     }
 
-
     @Override
     public void onDeviceContextLevelDown(final DeviceContext deviceContext) {
         final RpcContext removedContext = contexts.remove(deviceContext.getDeviceState().getNodeId());
@@ -87,18 +87,19 @@ public class RpcManagerImpl implements RpcManager {
         }
         deviceTerminPhaseHandler.onDeviceContextLevelDown(deviceContext);
     }
-    @Override
-    public void setStatisticsRpcEnabled(final boolean isStatisticsRpcEnabled) {
-        this.isStatisticsRpcEnabled = isStatisticsRpcEnabled;
-    }
-
-    @Override
-    public void setNotificationPublishService(final NotificationPublishService notificationPublishService) {
-        this.notificationPublishService = notificationPublishService;
-    }
 
     @Override
     public void setDeviceTerminationPhaseHandler(final DeviceTerminationPhaseHandler handler) {
         this.deviceTerminPhaseHandler = handler;
     }
+
+    /**
+     * This method is only for testing
+     */
+    @VisibleForTesting
+    void addRecordToContexts(NodeId nodeId, RpcContext rpcContexts) {
+        if(!contexts.containsKey(nodeId)) {
+            this.contexts.put(nodeId,rpcContexts);
+        }
+    }
 }