Search in sources :

Example 6 with AbortLocalTransactionRequest

use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.

the class LocalReadWriteProxyTransactionTest method testSendAbort.

@Test
public void testSendAbort() throws Exception {
    final TestProbe probe = createProbe();
    final TransactionRequest<?> request = new AbortLocalTransactionRequest(TRANSACTION_ID, probe.ref());
    transaction.sendAbort(request, createCallbackMock());
    assertOperationThrowsException(() -> transaction.delete(PATH_1), IllegalStateException.class);
}
Also used : AbortLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest) TestProbe(akka.testkit.TestProbe) Test(org.junit.Test)

Example 7 with AbortLocalTransactionRequest

use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.

the class LocalProxyTransaction method forwardToRemote.

@Override
final void forwardToRemote(final RemoteProxyTransaction successor, final TransactionRequest<?> request, final Consumer<Response<?, ?>> callback) {
    if (request instanceof CommitLocalTransactionRequest) {
        final CommitLocalTransactionRequest req = (CommitLocalTransactionRequest) request;
        final DataTreeModification mod = req.getModification();
        LOG.debug("Applying modification {} to successor {}", mod, successor);
        mod.applyToCursor(new AbstractDataTreeModificationCursor() {

            @Override
            public void write(final PathArgument child, final NormalizedNode<?, ?> data) {
                successor.write(current().node(child), data);
            }

            @Override
            public void merge(final PathArgument child, final NormalizedNode<?, ?> data) {
                successor.merge(current().node(child), data);
            }

            @Override
            public void delete(final PathArgument child) {
                successor.delete(current().node(child));
            }
        });
        successor.sealOnly();
        final ModifyTransactionRequest successorReq = successor.commitRequest(req.isCoordinated());
        successor.sendRequest(successorReq, callback);
    } else if (request instanceof AbortLocalTransactionRequest) {
        LOG.debug("Forwarding abort {} to successor {}", request, successor);
        successor.abort();
    } else if (request instanceof TransactionPurgeRequest) {
        LOG.debug("Forwarding purge {} to successor {}", request, successor);
        successor.enqueuePurge(callback);
    } else if (request instanceof ModifyTransactionRequest) {
        successor.handleForwardedRequest(request, callback);
    } else {
        throwUnhandledRequest(request);
    }
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification) AbortLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest) AbstractDataTreeModificationCursor(org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor) TransactionPurgeRequest(org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)

Aggregations

AbortLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest)7 Test (org.junit.Test)6 TestProbe (akka.testkit.TestProbe)4 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)3 ArrayList (java.util.ArrayList)1 ConnectionEntry (org.opendaylight.controller.cluster.access.client.ConnectionEntry)1 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)1 ExistsTransactionRequest (org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest)1 ReadTransactionRequest (org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest)1 TransactionPurgeRequest (org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)1 Response (org.opendaylight.controller.cluster.access.concepts.Response)1 AbstractDataTreeModificationCursor (org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor)1 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)1