Search in sources :

Example 1 with InvokeRpcMessageReply

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

the class ProxyNetconfDataTreeServiceTest method lock.

private void lock() {
    final ListenableFuture<DOMRpcResult> lock = proxy.lock();
    masterActor.expectMsgClass(NetconfDataTreeServiceRequest.class);
    masterActor.reply(new Status.Success(masterActor.ref()));
    masterActor.expectMsgClass(LockRequest.class);
    masterActor.reply(new InvokeRpcMessageReply(null, Collections.emptyList()));
    Futures.whenAllComplete(lock).run(() -> {
        assertTrue(lock.isDone());
        assertNotNull(Futures.getUnchecked(lock));
    }, MoreExecutors.directExecutor());
}
Also used : Status(akka.actor.Status) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) InvokeRpcMessageReply(org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessageReply)

Example 2 with InvokeRpcMessageReply

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

the class ActorProxyNetconfServiceFacade method discardChanges.

@Override
public ListenableFuture<DOMRpcResult> discardChanges() {
    LOG.debug("{}: Discard changes via actor {}", id, masterActor);
    final SettableFuture<DOMRpcResult> discardChangesResult = SettableFuture.create();
    final Future<Object> future = Patterns.ask(masterActor, new DiscardChangesRequest(), askTimeout);
    future.onComplete(new OnComplete<>() {

        @Override
        public void onComplete(final Throwable failure, final Object response) {
            if (failure != null) {
                discardChangesResult.setException(failure);
            } else if (response instanceof InvokeRpcMessageReply) {
                discardChangesResult.set(mapInvokeRpcMessageReplyToDOMRpcResult((InvokeRpcMessageReply) response));
            } else {
                discardChangesResult.setException(new ClusteringRpcException("Discard changes operation returned unexpected type"));
                LOG.error("{}: Discard changes  via actor {} returned unexpected type", id, masterActor);
            }
        }
    }, executionContext);
    return discardChangesResult;
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) DiscardChangesRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.DiscardChangesRequest) ClusteringRpcException(org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringRpcException) InvokeRpcMessageReply(org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessageReply)

Example 3 with InvokeRpcMessageReply

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

the class ProxyNetconfServiceTest method commit.

private void commit(final ProxyNetconfService netconf) throws InterruptedException, ExecutionException, TimeoutException {
    final ListenableFuture<?> submit = netconf.commit();
    masterActor.expectMsgClass(CommitRequest.class);
    masterActor.reply(new InvokeRpcMessageReply(null, Collections.emptyList()));
    submit.get(5, TimeUnit.SECONDS);
}
Also used : InvokeRpcMessageReply(org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessageReply)

Example 4 with InvokeRpcMessageReply

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

the class ActorProxyNetconfServiceFacade method commit.

@Override
public ListenableFuture<? extends DOMRpcResult> commit() {
    LOG.debug("{}: Commit via actor {}", id, masterActor);
    final Future<Object> future = Patterns.ask(masterActor, new CommitRequest(), askTimeout);
    final SettableFuture<DOMRpcResult> settableFuture = SettableFuture.create();
    future.onComplete(new OnComplete<>() {

        @Override
        public void onComplete(final Throwable failure, final Object response) {
            if (failure != null) {
                LOG.debug("{}: Commit failed", id, failure);
                settableFuture.setException(newNetconfServiceFailedException(processFailure(failure)));
            } else if (response instanceof InvokeRpcMessageReply) {
                LOG.debug("{}: Commit succeeded", id);
                settableFuture.set(mapInvokeRpcMessageReplyToDOMRpcResult((InvokeRpcMessageReply) response));
            } else {
                settableFuture.setException(new ClusteringRpcException("Commit operation returned unexpected type"));
                LOG.error("{}: Commit via actor {} returned unexpected type", id, masterActor);
            }
        }

        private NetconfServiceFailedException newNetconfServiceFailedException(final Throwable failure) {
            return new NetconfServiceFailedException(String.format("%s: Commit of operation failed", getDeviceId()), failure);
        }
    }, executionContext);
    return settableFuture;
}
Also used : CommitRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.CommitRequest) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) ClusteringRpcException(org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringRpcException) InvokeRpcMessageReply(org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessageReply)

Example 5 with InvokeRpcMessageReply

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

the class ActorProxyNetconfServiceFacade method lock.

@Override
public ListenableFuture<DOMRpcResult> lock() {
    LOG.debug("{}: Lock via actor {}", id, masterActor);
    final SettableFuture<DOMRpcResult> lockResult = SettableFuture.create();
    final Future<Object> future = Patterns.ask(masterActor, new LockRequest(), askTimeout);
    future.onComplete(new OnComplete<>() {

        @Override
        public void onComplete(final Throwable failure, final Object response) {
            if (failure != null) {
                lockResult.setException(failure);
            } else if (response instanceof InvokeRpcMessageReply) {
                lockResult.set(mapInvokeRpcMessageReplyToDOMRpcResult((InvokeRpcMessageReply) response));
            } else {
                lockResult.setException(new ClusteringRpcException("Lock operation returned unexpected type"));
                LOG.error("{}: Lock via actor {} returned unexpected type", id, masterActor);
            }
        }
    }, executionContext);
    return lockResult;
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) LockRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.LockRequest) ClusteringRpcException(org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringRpcException) InvokeRpcMessageReply(org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessageReply)

Aggregations

InvokeRpcMessageReply (org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessageReply)6 DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)5 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)4 ClusteringRpcException (org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringRpcException)4 Status (akka.actor.Status)1 CommitRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.CommitRequest)1 DiscardChangesRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.DiscardChangesRequest)1 LockRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.LockRequest)1 UnlockRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.UnlockRequest)1