use of org.opendaylight.netconf.topology.singleton.messages.netconf.ReplaceEditConfigRequest in project netconf by opendaylight.
the class NetconfDataTreeServiceActor method onReceive.
@Override
public void onReceive(final Object message) {
if (message instanceof GetWithFieldsRequest) {
final GetWithFieldsRequest getRequest = (GetWithFieldsRequest) message;
final YangInstanceIdentifier path = getRequest.getPath();
final ListenableFuture<Optional<NormalizedNode>> future = netconfService.get(getRequest.getPath(), getRequest.getFields());
context().stop(self());
sendResult(future, path, sender(), self());
} else if (message instanceof GetRequest) {
final GetRequest getRequest = (GetRequest) message;
final YangInstanceIdentifier path = getRequest.getPath();
final ListenableFuture<Optional<NormalizedNode>> future = netconfService.get(path);
context().stop(self());
sendResult(future, path, sender(), self());
} else if (message instanceof GetConfigWithFieldsRequest) {
final GetConfigWithFieldsRequest getConfigRequest = (GetConfigWithFieldsRequest) message;
final YangInstanceIdentifier path = getConfigRequest.getPath();
final ListenableFuture<Optional<NormalizedNode>> future = netconfService.getConfig(path, getConfigRequest.getFields());
context().stop(self());
sendResult(future, path, sender(), self());
} else if (message instanceof GetConfigRequest) {
final GetConfigRequest getConfigRequest = (GetConfigRequest) message;
final YangInstanceIdentifier path = getConfigRequest.getPath();
final ListenableFuture<Optional<NormalizedNode>> future = netconfService.getConfig(path);
context().stop(self());
sendResult(future, path, sender(), self());
} else if (message instanceof LockRequest) {
invokeRpcCall(netconfService::lock, sender(), self());
} else if (message instanceof MergeEditConfigRequest) {
final MergeEditConfigRequest request = (MergeEditConfigRequest) message;
netconfService.merge(request.getStore(), request.getNormalizedNodeMessage().getIdentifier(), request.getNormalizedNodeMessage().getNode(), Optional.ofNullable(request.getDefaultOperation()));
} else if (message instanceof ReplaceEditConfigRequest) {
final ReplaceEditConfigRequest request = (ReplaceEditConfigRequest) message;
netconfService.replace(request.getStore(), request.getNormalizedNodeMessage().getIdentifier(), request.getNormalizedNodeMessage().getNode(), Optional.ofNullable(request.getDefaultOperation()));
} else if (message instanceof CreateEditConfigRequest) {
final CreateEditConfigRequest request = (CreateEditConfigRequest) message;
netconfService.create(request.getStore(), request.getNormalizedNodeMessage().getIdentifier(), request.getNormalizedNodeMessage().getNode(), Optional.ofNullable(request.getDefaultOperation()));
} else if (message instanceof DeleteEditConfigRequest) {
final DeleteEditConfigRequest request = (DeleteEditConfigRequest) message;
netconfService.delete(request.getStore(), request.getPath());
} else if (message instanceof RemoveEditConfigRequest) {
final RemoveEditConfigRequest request = (RemoveEditConfigRequest) message;
netconfService.remove(request.getStore(), request.getPath());
} else if (message instanceof CommitRequest) {
submit(sender(), self());
} else if (message instanceof DiscardChangesRequest) {
invokeRpcCall(netconfService::discardChanges, sender(), self());
} else if (message instanceof UnlockRequest) {
context().stop(self());
invokeRpcCall(netconfService::unlock, sender(), self());
} else if (message instanceof ReceiveTimeout) {
LOG.warn("Haven't received any message for {} seconds, cancelling transaction and stopping actor", idleTimeout);
invokeRpcCall(netconfService::discardChanges, sender(), self());
invokeRpcCall(netconfService::unlock, sender(), self());
context().stop(self());
} else {
unhandled(message);
}
}
use of org.opendaylight.netconf.topology.singleton.messages.netconf.ReplaceEditConfigRequest in project netconf by opendaylight.
the class ProxyNetconfServiceTest method testReplace.
@Test
public void testReplace() {
ProxyNetconfService netconf = newSuccessfulProxyNetconfService();
netconf.replace(STORE, PATH, node, Optional.empty());
final ReplaceEditConfigRequest replaceRequest = masterActor.expectMsgClass(ReplaceEditConfigRequest.class);
assertEquals(STORE, replaceRequest.getStore());
assertEquals(PATH, replaceRequest.getNormalizedNodeMessage().getIdentifier());
assertEquals(node, replaceRequest.getNormalizedNodeMessage().getNode());
}
use of org.opendaylight.netconf.topology.singleton.messages.netconf.ReplaceEditConfigRequest in project netconf by opendaylight.
the class ActorProxyNetconfServiceFacade method replace.
@Override
public ListenableFuture<? extends DOMRpcResult> replace(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data, final Optional<ModifyAction> defaultOperation) {
LOG.debug("{}: Replace {} {} via actor {}", id, store, path, masterActor);
masterActor.tell(new ReplaceEditConfigRequest(store, new NormalizedNodeMessage(path, data), defaultOperation.orElse(null)), ActorRef.noSender());
return createResult();
}
use of org.opendaylight.netconf.topology.singleton.messages.netconf.ReplaceEditConfigRequest in project netconf by opendaylight.
the class NetconfDataTreeServiceActorTest method testReplace.
@Test
public void testReplace() {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(netconfService).replace(STORE, PATH, NODE, Optional.empty());
final NormalizedNodeMessage node = new NormalizedNodeMessage(PATH, NODE);
actorRef.tell(new ReplaceEditConfigRequest(STORE, node, null), probe.ref());
verify(netconfService).replace(STORE, PATH, NODE, Optional.empty());
}
Aggregations