X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2FNetconfServerSessionListener.java;h=b0dcf7876b3b398f141cb205d6885da69cf5b098;hb=refs%2Fchanges%2F13%2F23413%2F26;hp=4f2f65c1a00732137229fba7e1416d9c1db70904;hpb=c7ec8db7f107b5e265f4e8b2fe3dd0f7b1163b64;p=controller.git 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..b0dcf7876b 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,18 +11,15 @@ 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.config.util.xml.DocumentedException; +import org.opendaylight.controller.config.util.xml.XmlUtil; 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; import org.w3c.dom.Document; @@ -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, final 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,36 +85,23 @@ public class NetconfServerSessionListener implements NetconfSessionListener