DeviceManager map key change 01/40001/6
authorJozef Bacigal <jbacigal@cisco.com>
Wed, 8 Jun 2016 08:32:22 +0000 (10:32 +0200)
committerJozef Bacigal <jbacigal@cisco.com>
Fri, 17 Jun 2016 08:21:16 +0000 (08:21 +0000)
Change-Id: I94f2488a7152472e728cc5123d905183a999030f
Signed-off-by: Jozef Bacigal <jbacigal@cisco.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java

index e84e0308b7f46679fc25ae0a47130ec841761bc7..3c2591dec3cd81f5d21029d107a1f5ae4779f296 100644 (file)
@@ -70,7 +70,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     private DeviceTerminationPhaseHandler deviceTerminPhaseHandler;
     private NotificationPublishService notificationPublishService;
 
-    private final ConcurrentMap<NodeId, DeviceContext> deviceContexts = new ConcurrentHashMap<>();
+    private final ConcurrentMap<DeviceInfo, DeviceContext> deviceContexts = new ConcurrentHashMap<>();
 
     private final long barrierIntervalNanos;
     private final int barrierCountLimit;
@@ -117,7 +117,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     public void onDeviceContextLevelUp(@CheckForNull DeviceInfo deviceInfo) throws Exception {
         // final phase - we have to add new Device to MD-SAL DataStore
         LOG.debug("Final phase of DeviceContextLevelUp for Node: {} ", deviceInfo.getNodeId());
-        DeviceContext deviceContext = Preconditions.checkNotNull(deviceContexts.get(deviceInfo.getNodeId()));
+        DeviceContext deviceContext = Preconditions.checkNotNull(deviceContexts.get(deviceInfo));
         ((DeviceContextImpl) deviceContext).initialSubmitTransaction();
         deviceContext.onPublished();
     }
@@ -165,7 +165,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
                 translatorLibrary,
                 switchFeaturesMandatory);
 
-        Verify.verify(deviceContexts.putIfAbsent(deviceInfo.getNodeId(), deviceContext) == null, "DeviceCtx still not closed.");
+        Verify.verify(deviceContexts.putIfAbsent(deviceInfo, deviceContext) == null, "DeviceCtx still not closed.");
 
         ((ExtensionConverterProviderKeeper) deviceContext).setExtensionConverterProvider(extensionConverterProvider);
         deviceContext.setStatisticsRpcEnabled(isStatisticsRpcEnabled);
@@ -313,7 +313,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     }
 
     @VisibleForTesting
-    void addDeviceContextToMap(final NodeId nodeId, final DeviceContext deviceContext){
-        deviceContexts.put(nodeId, deviceContext);
+    void addDeviceContextToMap(final DeviceInfo deviceInfo, final DeviceContext deviceContext){
+        deviceContexts.put(deviceInfo, deviceContext);
     }
 }
index 4427aeb7a95813b11a234b48a0e427107bfd0979..403f6242ac3955d94e0f2c847cb0c492443a8c29 100644 (file)
@@ -167,7 +167,7 @@ public class DeviceManagerImplTest {
         if (withException) {
             doThrow(new IllegalStateException("dummy")).when(mockedDeviceContext).initialSubmitTransaction();
         }
-        deviceManager.addDeviceContextToMap(DUMMY_NODE_ID, mockedDeviceContext);
+        deviceManager.addDeviceContextToMap(deviceInfo, mockedDeviceContext);
         deviceManager.onDeviceContextLevelUp(deviceInfo);
         if (withException) {
             verify(mockedDeviceContext).close();