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());
}
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);
}
}
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;
}
Aggregations