Merge "BUG 2676 : Use transaction-dispatcher for ShardTransaction"
[controller.git] / opendaylight / netconf / netconf-impl / src / main / java / org / opendaylight / controller / netconf / impl / NetconfServerSessionListener.java
index b2b8c50029868d507971cf70d1f22af940861e0d..a6531d3c63d09b6fc64a1c0afd08e3f21041b2df 100644 (file)
@@ -15,10 +15,10 @@ import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.api.NetconfSessionListener;
 import org.opendaylight.controller.netconf.api.NetconfTerminationReason;
+import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.impl.mapping.operations.DefaultCloseSession;
 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter;
-import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
 import org.opendaylight.controller.netconf.util.messages.SendErrorExceptionUtil;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
@@ -31,29 +31,31 @@ import org.w3c.dom.Node;
 public class NetconfServerSessionListener implements NetconfSessionListener<NetconfServerSession> {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionListener.class);
-    private final SessionMonitoringService monitoringService;
+    private final NetconfMonitoringService monitoringService;
     private final NetconfOperationRouter operationRouter;
     private final AutoCloseable onSessionDownCloseable;
 
-    public NetconfServerSessionListener(NetconfOperationRouter operationRouter, SessionMonitoringService monitoringService,
-                                        AutoCloseable onSessionDownCloseable) {
+    public NetconfServerSessionListener(final NetconfOperationRouter operationRouter, NetconfMonitoringService monitoringService,
+                                        final AutoCloseable onSessionDownCloseable) {
         this.operationRouter = operationRouter;
         this.monitoringService = monitoringService;
         this.onSessionDownCloseable = onSessionDownCloseable;
     }
 
     @Override
-    public void onSessionUp(NetconfServerSession netconfNetconfServerSession) {
+    public void onSessionUp(final NetconfServerSession netconfNetconfServerSession) {
         monitoringService.onSessionUp(netconfNetconfServerSession);
+        // FIXME monitoring service should be also notified about all the other changes to netconf session (from ietf-netconf-monitoring point of view)
+        // This means also notifying after every message is processed
     }
 
     @Override
-    public void onSessionDown(NetconfServerSession netconfNetconfServerSession, Exception cause) {
+    public void onSessionDown(final NetconfServerSession netconfNetconfServerSession, final Exception cause) {
         LOG.debug("Session {} down, reason: {}", netconfNetconfServerSession, cause.getMessage());
         onDown(netconfNetconfServerSession);
     }
 
-    public void onDown(NetconfServerSession netconfNetconfServerSession) {
+    public void onDown(final NetconfServerSession netconfNetconfServerSession) {
         monitoringService.onSessionDown(netconfNetconfServerSession);
 
         try {
@@ -69,15 +71,15 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
     }
 
     @Override
-    public void onSessionTerminated(NetconfServerSession netconfNetconfServerSession,
-            NetconfTerminationReason netconfTerminationReason) {
+    public void onSessionTerminated(final NetconfServerSession netconfNetconfServerSession,
+            final NetconfTerminationReason netconfTerminationReason) {
         LOG.debug("Session {} terminated, reason: {}", netconfNetconfServerSession,
                 netconfTerminationReason.getErrorMessage());
         onDown(netconfNetconfServerSession);
     }
 
     @Override
-    public void onMessage(NetconfServerSession session, NetconfMessage netconfMessage) {
+    public void onMessage(final NetconfServerSession session, final NetconfMessage netconfMessage) {
         try {
 
             Preconditions.checkState(operationRouter != null, "Cannot handle message, session up was not yet received");
@@ -85,7 +87,7 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
             // schemas
             final NetconfMessage message = processDocument(netconfMessage,
                     session);
-            LOG.debug("Responding with message {}", XmlUtil.toString(message.getDocument()));
+            LOG.debug("Responding with message {}", message);
             session.sendMessage(message);
 
             if (isCloseSession(netconfMessage)) {
@@ -105,7 +107,7 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
         }
     }
 
-    private void closeNetconfSession(NetconfServerSession session) {
+    private void closeNetconfSession(final NetconfServerSession session) {
         // destroy NetconfOperationService
         session.close();
         LOG.info("Session {} closed successfully", session.getSessionId());
@@ -113,7 +115,7 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
 
 
 
-    private NetconfMessage processDocument(final NetconfMessage netconfMessage, NetconfServerSession session)
+    private NetconfMessage processDocument(final NetconfMessage netconfMessage, final NetconfServerSession session)
             throws NetconfDocumentedException {
 
         final Document incomingDocument = netconfMessage.getDocument();
@@ -146,7 +148,7 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
         }
     }
 
-    private void checkMessageId(Node rootNode) throws NetconfDocumentedException {
+    private void checkMessageId(final Node rootNode) throws NetconfDocumentedException {
 
         NamedNodeMap attributes = rootNode.getAttributes();