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);
}
Aggregations