Search in sources :

Example 6 with CommitLocalTransactionRequest

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

the class LocalReadWriteProxyTransactionTest method testCommitRequest.

@Test
public void testCommitRequest() throws Exception {
    transaction.doWrite(PATH_1, DATA_1);
    final boolean coordinated = true;
    final CommitLocalTransactionRequest request = transaction.commitRequest(coordinated);
    Assert.assertEquals(coordinated, request.isCoordinated());
    Assert.assertEquals(modification, request.getModification());
}
Also used : CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest) Test(org.junit.Test)

Example 7 with CommitLocalTransactionRequest

use of org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest 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)

Example 8 with CommitLocalTransactionRequest

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

the class LocalReadWriteProxyTransaction method commitRequest.

@Override
CommitLocalTransactionRequest commitRequest(final boolean coordinated) {
    final CursorAwareDataTreeModification mod = getModification();
    final CommitLocalTransactionRequest ret = new CommitLocalTransactionRequest(getIdentifier(), nextSequence(), localActor(), mod, recordedFailure, coordinated);
    closedException = this::submittedException;
    return ret;
}
Also used : CursorAwareDataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)

Aggregations

CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)8 Test (org.junit.Test)5 TestProbe (akka.testkit.TestProbe)3 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)3 CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification)3 TransactionCommitSuccess (org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess)2 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)2 AbortLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest)1 ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)1 TransactionDelete (org.opendaylight.controller.cluster.access.commands.TransactionDelete)1 TransactionMerge (org.opendaylight.controller.cluster.access.commands.TransactionMerge)1 TransactionModification (org.opendaylight.controller.cluster.access.commands.TransactionModification)1 TransactionPurgeRequest (org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)1 TransactionWrite (org.opendaylight.controller.cluster.access.commands.TransactionWrite)1 Response (org.opendaylight.controller.cluster.access.concepts.Response)1 AbstractDataTreeModificationCursor (org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor)1 DOMStoreThreePhaseCommitCohort (org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort)1 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1