Search in sources :

Example 1 with ContainerNodeMessage

use of org.opendaylight.netconf.topology.singleton.messages.ContainerNodeMessage in project netconf by opendaylight.

the class ProxyDOMActionService method invokeAction.

@Override
public FluentFuture<DOMActionResult> invokeAction(final Absolute type, final DOMDataTreeIdentifier domDataTreeIdentifier, final ContainerNode input) {
    requireNonNull(type);
    requireNonNull(input);
    requireNonNull(domDataTreeIdentifier);
    LOG.info("{}: Action Operation invoked with schema type: {} and node: {}.", id, type, input);
    final ContainerNodeMessage containerNodeMessage = new ContainerNodeMessage(input);
    final Future<Object> scalaFuture = Patterns.ask(masterActorRef, new InvokeActionMessage(new SchemaPathMessage(type), containerNodeMessage, domDataTreeIdentifier), actorResponseWaitTime);
    final SettableFuture<DOMActionResult> settableFuture = SettableFuture.create();
    scalaFuture.onComplete(new OnComplete<>() {

        @Override
        public void onComplete(final Throwable failure, final Object response) {
            if (failure != null) {
                if (failure instanceof ClusteringActionException) {
                    settableFuture.setException(failure);
                } else {
                    settableFuture.setException(new ClusteringActionException(id + ": Exception during remote Action invocation.", failure));
                }
                return;
            }
            if (response instanceof EmptyResultResponse) {
                settableFuture.set(null);
                return;
            }
            final Collection<? extends RpcError> errors = ((InvokeActionMessageReply) response).getRpcErrors();
            final ContainerNodeMessage containerNodeMessage = ((InvokeActionMessageReply) response).getContainerNodeMessage();
            final DOMActionResult result;
            if (containerNodeMessage == null) {
                result = new SimpleDOMActionResult(ImmutableList.copyOf(errors));
            } else {
                result = new SimpleDOMActionResult(containerNodeMessage.getNode(), ImmutableList.copyOf(errors));
            }
            settableFuture.set(result);
        }
    }, actorSystem.dispatcher());
    return FluentFuture.from(settableFuture);
}
Also used : SchemaPathMessage(org.opendaylight.netconf.topology.singleton.messages.SchemaPathMessage) RpcError(org.opendaylight.yangtools.yang.common.RpcError) EmptyResultResponse(org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyResultResponse) SimpleDOMActionResult(org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult) InvokeActionMessage(org.opendaylight.netconf.topology.singleton.messages.action.InvokeActionMessage) ClusteringActionException(org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringActionException) ContainerNodeMessage(org.opendaylight.netconf.topology.singleton.messages.ContainerNodeMessage) Collection(java.util.Collection) DOMActionResult(org.opendaylight.mdsal.dom.api.DOMActionResult) SimpleDOMActionResult(org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult)

Aggregations

Collection (java.util.Collection)1 DOMActionResult (org.opendaylight.mdsal.dom.api.DOMActionResult)1 SimpleDOMActionResult (org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult)1 ClusteringActionException (org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringActionException)1 ContainerNodeMessage (org.opendaylight.netconf.topology.singleton.messages.ContainerNodeMessage)1 SchemaPathMessage (org.opendaylight.netconf.topology.singleton.messages.SchemaPathMessage)1 InvokeActionMessage (org.opendaylight.netconf.topology.singleton.messages.action.InvokeActionMessage)1 EmptyResultResponse (org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyResultResponse)1 RpcError (org.opendaylight.yangtools.yang.common.RpcError)1