import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.api.NetconfTerminationReason;
import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouterImpl;
import org.opendaylight.controller.netconf.api.NetconfTerminationReason;
import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouterImpl;
import org.opendaylight.controller.netconf.util.messages.SendErrorExceptionUtil;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.opendaylight.controller.netconf.util.messages.SendErrorExceptionUtil;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
-import static com.google.common.base.Preconditions.checkState;
-
-public class NetconfServerSessionListener implements
- SessionListener<NetconfMessage, NetconfServerSession, NetconfTerminationReason> {
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
- private NetconfOperationRouterImpl operationRouter;
+ static final Logger logger = LoggerFactory.getLogger(NetconfServerSessionListener.class);
+ private final SessionMonitoringService monitoringService;
+ private final NetconfOperationRouterImpl operationRouter;
}
@Override
public void onSessionDown(NetconfServerSession netconfNetconfServerSession, Exception e) {
logger.debug("Session {} down, reason: {}", netconfNetconfServerSession, e.getMessage());
}
@Override
public void onSessionDown(NetconfServerSession netconfNetconfServerSession, Exception e) {
logger.debug("Session {} down, reason: {}", netconfNetconfServerSession, e.getMessage());
NetconfTerminationReason netconfTerminationReason) {
logger.debug("Session {} terminated, reason: {}", netconfNetconfServerSession,
netconfTerminationReason.getErrorMessage());
NetconfTerminationReason netconfTerminationReason) {
logger.debug("Session {} terminated, reason: {}", netconfNetconfServerSession,
netconfTerminationReason.getErrorMessage());
Preconditions.checkState(operationRouter != null, "Cannot handle message, session up was not yet received");
// FIXME: there is no validation since the document may contain yang
// schemas
Preconditions.checkState(operationRouter != null, "Cannot handle message, session up was not yet received");
// FIXME: there is no validation since the document may contain yang
// schemas
- final NetconfMessage message = processDocument(netconfMessage);
- logger.debug("Respondign with message {}", XmlUtil.toString(message.getDocument()));
+ final NetconfMessage message = processDocument(netconfMessage,
+ session);
+ logger.debug("Responding with message {}", XmlUtil.toString(message.getDocument()));
throw new RuntimeException("Unable to process incoming message " + netconfMessage, e);
} catch (NetconfDocumentedException e) {
throw new RuntimeException("Unable to process incoming message " + netconfMessage, e);
} catch (NetconfDocumentedException e) {
final Document incommingDocument = netconfMessage.getDocument();
final Node rootNode = incommingDocument.getDocumentElement();
final Document incommingDocument = netconfMessage.getDocument();
final Node rootNode = incommingDocument.getDocumentElement();
final String messageId = rootNode.getAttributes().getNamedItem(MESSAGE_ID).getTextContent();
checkState(messageId != null);
final Document responseDocument = XmlUtil.newDocument();
final String messageId = rootNode.getAttributes().getNamedItem(MESSAGE_ID).getTextContent();
checkState(messageId != null);
final Document responseDocument = XmlUtil.newDocument();
- Document rpcReply = operationRouter.onNetconfMessage(incommingDocument);
+ Document rpcReply = operationRouter.onNetconfMessage(
+ incommingDocument, session);
+
+ session.onIncommingRpcSuccess();
+
responseDocument.appendChild(responseDocument.importNode(rpcReply.getDocumentElement(), true));
return new NetconfMessage(responseDocument);
} else {
responseDocument.appendChild(responseDocument.importNode(rpcReply.getDocumentElement(), true));
return new NetconfMessage(responseDocument);
} else {