Beispiel #1
0
  private void processMessage(final NetconfMessage message) {
    Request request = null;
    sessionLock.lock();
    try {
      request = requests.peek();
      if (request.future.isUncancellable()) {
        requests.poll();
      } else {
        request = null;
        logger.warn("{}: Ignoring unsolicited message {}", id, msgToS(message));
      }
    } finally {
      sessionLock.unlock();
    }

    if (request != null) {

      logger.debug("{}: Message received {}", id, message);

      if (logger.isTraceEnabled()) {
        logger.trace(
            "{}: Matched request: {} to response: {}",
            id,
            msgToS(request.request),
            msgToS(message));
      }

      try {
        NetconfMessageTransformUtil.checkValidReply(request.request, message);
      } catch (final NetconfDocumentedException e) {
        logger.warn(
            "{}: Invalid request-reply match, reply message contains different message-id, request: {}, response: {}",
            id,
            msgToS(request.request),
            msgToS(message),
            e);

        request.future.set(
            RpcResultBuilder.<NetconfMessage>failed()
                .withRpcError(NetconfMessageTransformUtil.toRpcError(e))
                .build());
        return;
      }

      try {
        NetconfMessageTransformUtil.checkSuccessReply(message);
      } catch (final NetconfDocumentedException e) {
        logger.warn(
            "{}: Error reply from remote device, request: {}, response: {}",
            id,
            msgToS(request.request),
            msgToS(message),
            e);

        request.future.set(
            RpcResultBuilder.<NetconfMessage>failed()
                .withRpcError(NetconfMessageTransformUtil.toRpcError(e))
                .build());
        return;
      }

      request.future.set(RpcResultBuilder.success(message).build());
    }
  }
Beispiel #2
0
 private DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> findDataNode(
     final DOMRpcResult result) {
   return ((ContainerNode) result.getResult())
       .getChild(NetconfMessageTransformUtil.toId(NetconfMessageTransformUtil.NETCONF_DATA_QNAME))
       .get();
 }