Fix Already initialized exception from netconf-connector 77/16477/1
authorMaros Marsalek <mmarsale@cisco.com>
Fri, 13 Mar 2015 12:49:07 +0000 (13:49 +0100)
committerMaros Marsalek <mmarsale@cisco.com>
Fri, 13 Mar 2015 13:01:16 +0000 (14:01 +0100)
Netconf-connector called initialization code and cleanup code (after capability
changed notification was received) in wrong order. This caused the cleanup

Change-Id: I3ea2166c912e2b6775bf9493a95102d66b5ae8a2
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalProvider.java

index ac84acb2f177a16d3aa110f54ee4bcc692f80664..cdce946aba6833006dce994a6c7ee9dc87624311 100644 (file)
@@ -220,8 +220,9 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
         messageTransformer = new NetconfMessageTransformer(result);
 
         updateTransformer(messageTransformer);
-        notificationHandler.onRemoteSchemaUp(messageTransformer);
+        // salFacade.onDeviceConnected has to be called before the notification handler is initialized
         salFacade.onDeviceConnected(result, remoteSessionCapabilities, deviceRpc);
+        notificationHandler.onRemoteSchemaUp(messageTransformer);
 
         logger.info("{}: Netconf connector initialized successfully", id);
     }
index 3246f519042802cedd396708ed17c0db69c79301..2931468501a17d851f5629ef151f4d22bd992495 100644 (file)
@@ -123,11 +123,13 @@ final class NetconfDeviceSalProvider implements AutoCloseable, Provider, Binding
             this.notificationService = notificationService;
 
             registration = mountBuilder.register();
+            logger.debug("{}: Mountpoint exposed into MD-SAL {}", id, registration);
         }
 
         @Deprecated
         synchronized void onDeviceDisconnected() {
             if(registration == null) {
+                logger.trace("{}: Not removing mountpoint from MD-SAL, mountpoint was not registered yet", id);
                 return;
             }
 
@@ -137,6 +139,7 @@ final class NetconfDeviceSalProvider implements AutoCloseable, Provider, Binding
                 // Only log and ignore
                 logger.warn("Unable to unregister mount instance for {}. Ignoring exception", id.getPath(), e);
             } finally {
+                logger.debug("{}: Mountpoint removed from MD-SAL {}", id, registration);
                 registration = null;
             }
         }
@@ -156,10 +159,13 @@ final class NetconfDeviceSalProvider implements AutoCloseable, Provider, Binding
             mountBuilder.addService(DOMNotificationService.class, notificationService);
 
             topologyRegistration = mountBuilder.register();
+            logger.debug("{}: TOPOLOGY Mountpoint exposed into MD-SAL {}", id, registration);
+
         }
 
         synchronized void onTopologyDeviceDisconnected() {
             if(topologyRegistration == null) {
+                logger.trace("{}: Not removing TOPOLOGY mountpoint from MD-SAL, mountpoint was not registered yet", id);
                 return;
             }
 
@@ -169,16 +175,15 @@ final class NetconfDeviceSalProvider implements AutoCloseable, Provider, Binding
                 // Only log and ignore
                 logger.warn("Unable to unregister mount instance for {}. Ignoring exception", id.getTopologyPath(), e);
             } finally {
+                logger.debug("{}: TOPOLOGY Mountpoint removed from MD-SAL {}", id, registration);
                 topologyRegistration = null;
             }
         }
 
         @Override
         synchronized public void close() throws Exception {
-            if(registration != null) {
-                onDeviceDisconnected();
-                onTopologyDeviceDisconnected();
-            }
+            onDeviceDisconnected();
+            onTopologyDeviceDisconnected();
             mountService = null;
         }