X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2FNetconfServerSessionListener.java;h=e83e0b0227e236bf592ad5d2c4b327efd795db80;hp=4f2f65c1a00732137229fba7e1416d9c1db70904;hb=9049093a8ddb4278fb98fcf0dc5d1914d1617004;hpb=c2fd5f62f3b80a7e7b4b7e167349ede433e785d6 diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java index 4f2f65c1a0..e83e0b0227 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java @@ -11,17 +11,14 @@ package org.opendaylight.controller.netconf.impl; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; - 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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,54 +28,56 @@ import org.w3c.dom.Node; public class NetconfServerSessionListener implements NetconfSessionListener { - static final Logger logger = LoggerFactory.getLogger(NetconfServerSessionListener.class); - private final SessionMonitoringService monitoringService; + private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionListener.class); + 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) { - logger.debug("Session {} down, reason: {}", netconfNetconfServerSession, cause.getMessage()); + 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 { operationRouter.close(); } catch (Exception closingEx) { - logger.debug("Ignoring exception while closing operationRouter", closingEx); + LOG.debug("Ignoring exception while closing operationRouter", closingEx); } try { onSessionDownCloseable.close(); } catch(Exception ex){ - logger.debug("Ignoring exception while closing onSessionDownCloseable", ex); + LOG.debug("Ignoring exception while closing onSessionDownCloseable", ex); } } @Override - public void onSessionTerminated(NetconfServerSession netconfNetconfServerSession, - NetconfTerminationReason netconfTerminationReason) { - logger.debug("Session {} terminated, reason: {}", netconfNetconfServerSession, + 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"); @@ -86,35 +85,22 @@ public class NetconfServerSessionListener implements NetconfSessionListener