Search in sources :

Example 21 with ModifyTransactionRequest

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

ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)21 Test (org.junit.Test)12 TestProbe (akka.testkit.TestProbe)10 ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)9 AbortLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest)5 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)5 Response (org.opendaylight.controller.cluster.access.concepts.Response)5 TransactionModification (org.opendaylight.controller.cluster.access.commands.TransactionModification)4 AbstractLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbstractLocalTransactionRequest)3 ExistsTransactionRequest (org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest)3 IncrementTransactionSequenceRequest (org.opendaylight.controller.cluster.access.commands.IncrementTransactionSequenceRequest)3 ReadTransactionRequest (org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest)3 TransactionDelete (org.opendaylight.controller.cluster.access.commands.TransactionDelete)3 TransactionMerge (org.opendaylight.controller.cluster.access.commands.TransactionMerge)3 TransactionPurgeRequest (org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)3 TransactionRequest (org.opendaylight.controller.cluster.access.commands.TransactionRequest)3 TransactionWrite (org.opendaylight.controller.cluster.access.commands.TransactionWrite)3 AbstractDataTreeModificationCursor (org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor)3 Optional (com.google.common.base.Optional)2 CheckedFuture (com.google.common.util.concurrent.CheckedFuture)2