use of org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage in project netconf by opendaylight.
the class ActorProxyTransactionFacade method merge.
@Override
public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) {
LOG.debug("{}: Merge {} {} via actor {}", id, store, path, masterTxActor);
masterTxActor.tell(new MergeRequest(store, new NormalizedNodeMessage(path, data)), ActorRef.noSender());
}
use of org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage in project netconf by opendaylight.
the class ActorProxyTransactionFacade method read.
@Override
public FluentFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
LOG.debug("{}: Read {} {} via actor {}", id, store, path, masterTxActor);
final Future<Object> future = Patterns.ask(masterTxActor, new ReadRequest(store, path), askTimeout);
final SettableFuture<Optional<NormalizedNode>> settableFuture = SettableFuture.create();
future.onComplete(new OnComplete<>() {
@Override
public void onComplete(final Throwable failure, final Object response) {
if (failure != null) {
LOG.debug("{}: Read {} {} failed", id, store, path, failure);
final Throwable processedFailure = processFailure(failure);
if (processedFailure instanceof ReadFailedException) {
settableFuture.setException(processedFailure);
} else {
settableFuture.setException(new ReadFailedException("Read of store " + store + " path " + path + " failed", processedFailure));
}
return;
}
LOG.debug("{}: Read {} {} succeeded: {}", id, store, path, response);
if (response instanceof EmptyReadResponse) {
settableFuture.set(Optional.empty());
return;
}
if (response instanceof NormalizedNodeMessage) {
final NormalizedNodeMessage data = (NormalizedNodeMessage) response;
settableFuture.set(Optional.of(data.getNode()));
}
}
}, executionContext);
return FluentFuture.from(settableFuture);
}
use of org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage in project netconf by opendaylight.
the class ProxyDOMRpcService method invokeRpc.
@Override
public FluentFuture<DOMRpcResult> invokeRpc(final QName type, final NormalizedNode input) {
LOG.trace("{}: Rpc operation invoked with schema type: {} and node: {}.", id, type, input);
final NormalizedNodeMessage normalizedNodeMessage = input != null ? new NormalizedNodeMessage(YangInstanceIdentifier.empty(), input) : null;
final Future<Object> scalaFuture = Patterns.ask(masterActorRef, new InvokeRpcMessage(new SchemaPathMessage(type), normalizedNodeMessage), actorResponseWaitTime);
final SettableFuture<DOMRpcResult> settableFuture = SettableFuture.create();
scalaFuture.onComplete(new OnComplete<>() {
@Override
public void onComplete(final Throwable failure, final Object response) {
if (failure != null) {
if (failure instanceof ClusteringRpcException) {
settableFuture.setException(failure);
} else {
settableFuture.setException(new ClusteringRpcException(id + ": Exception during remote rpc invocation.", failure));
}
return;
}
if (response instanceof EmptyResultResponse) {
settableFuture.set(null);
return;
}
final Collection<? extends RpcError> errors = ((InvokeRpcMessageReply) response).getRpcErrors();
final NormalizedNodeMessage normalizedNodeMessageResult = ((InvokeRpcMessageReply) response).getNormalizedNodeMessage();
final DOMRpcResult result;
if (normalizedNodeMessageResult == null) {
result = new DefaultDOMRpcResult(ImmutableList.copyOf(errors));
} else {
result = new DefaultDOMRpcResult(normalizedNodeMessageResult.getNode(), errors);
}
settableFuture.set(result);
}
}, actorSystem.dispatcher());
return FluentFuture.from(settableFuture);
}
use of org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage in project netconf by opendaylight.
the class WriteAdapter method handle.
@SuppressWarnings("checkstyle:IllegalCatch")
public void handle(final Object message, final ActorRef sender, final ActorContext context, final ActorRef self) {
// TODO Maybe we should store it and fail the submit immediately?.
try {
if (message instanceof MergeRequest) {
final MergeRequest mergeRequest = (MergeRequest) message;
final NormalizedNodeMessage data = mergeRequest.getNormalizedNodeMessage();
tx.merge(mergeRequest.getStore(), data.getIdentifier(), data.getNode());
} else if (message instanceof PutRequest) {
final PutRequest putRequest = (PutRequest) message;
final NormalizedNodeMessage data = putRequest.getNormalizedNodeMessage();
tx.put(putRequest.getStore(), data.getIdentifier(), data.getNode());
} else if (message instanceof DeleteRequest) {
final DeleteRequest deleteRequest = (DeleteRequest) message;
tx.delete(deleteRequest.getStore(), deleteRequest.getPath());
} else if (message instanceof CancelRequest) {
cancel(context, sender, self);
} else if (message instanceof SubmitRequest) {
submit(sender, self, context);
}
} catch (final RuntimeException exception) {
LOG.error("Write command has failed.", exception);
}
}
use of org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage in project netconf by opendaylight.
the class ActorProxyNetconfServiceFacade method create.
@Override
public ListenableFuture<? extends DOMRpcResult> create(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data, final Optional<ModifyAction> defaultOperation) {
LOG.debug("{}: Create {} {} via actor {}", id, store, path, masterActor);
masterActor.tell(new CreateEditConfigRequest(store, new NormalizedNodeMessage(path, data), defaultOperation.orElse(null)), ActorRef.noSender());
return createResult();
}
Aggregations