BUG-3095 Add EventTime attribute to DOMNotification from netconf
[controller.git] / opendaylight / md-sal / sal-netconf-connector / src / main / java / org / opendaylight / controller / sal / connect / netconf / sal / NetconfDeviceSalProvider.java
index 3246f519042802cedd396708ed17c0db69c79301..bf870bf36a07ccd421f86e9eeba1571ad73f0e5e 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
@@ -22,7 +23,6 @@ import org.opendaylight.controller.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.controller.sal.core.api.Broker;
 import org.opendaylight.controller.sal.core.api.Provider;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -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,20 +175,19 @@ 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;
         }
 
-        public synchronized void publish(final ContainerNode domNotification) {
+        public synchronized void publish(final DOMNotification domNotification) {
             Preconditions.checkNotNull(notificationService, "Device not set up yet, cannot handle notification {}", domNotification);
             notificationService.publishNotification(domNotification);
         }