Search in sources :

Example 1 with CancelRequest

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

the class WriteTransactionActorTestAdapter method testCancel.

@Test
public void testCancel() {
    when(mockWriteTx.cancel()).thenReturn(true);
    actorRef.tell(new CancelRequest(), probe.ref());
    verify(mockWriteTx).cancel();
    probe.expectMsg(true);
}
Also used : CancelRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.CancelRequest) Test(org.junit.Test)

Example 2 with CancelRequest

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

the class ActorProxyTransactionFacade method cancel.

@Override
public boolean cancel() {
    LOG.debug("{}: Cancel via actor {}", id, masterTxActor);
    final Future<Object> future = Patterns.ask(masterTxActor, new CancelRequest(), askTimeout);
    future.onComplete(new OnComplete<>() {

        @Override
        public void onComplete(final Throwable failure, final Object response) {
            if (failure != null) {
                LOG.warn("{}: Cancel failed", id, failure);
                return;
            }
            LOG.debug("{}: Cancel succeeded", id);
        }
    }, executionContext);
    return true;
}
Also used : CancelRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.CancelRequest)

Example 3 with CancelRequest

use of org.opendaylight.netconf.topology.singleton.messages.transactions.CancelRequest 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);
    }
}
Also used : MergeRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.MergeRequest) NormalizedNodeMessage(org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage) PutRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.PutRequest) CancelRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.CancelRequest) SubmitRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitRequest) DeleteRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.DeleteRequest)

Aggregations

CancelRequest (org.opendaylight.netconf.topology.singleton.messages.transactions.CancelRequest)3 Test (org.junit.Test)1 NormalizedNodeMessage (org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage)1 DeleteRequest (org.opendaylight.netconf.topology.singleton.messages.transactions.DeleteRequest)1 MergeRequest (org.opendaylight.netconf.topology.singleton.messages.transactions.MergeRequest)1 PutRequest (org.opendaylight.netconf.topology.singleton.messages.transactions.PutRequest)1 SubmitRequest (org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitRequest)1