use of org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest in project controller by opendaylight.
the class LocalReadWriteProxyTransactionTest method testHandleForwardedRemoteDoCommitRequest.
@Test
public void testHandleForwardedRemoteDoCommitRequest() throws Exception {
final TestProbe probe = createProbe();
final TransactionDoCommitRequest request = new TransactionDoCommitRequest(TRANSACTION_ID, 0L, probe.ref());
testHandleForwardedRemoteRequest(request);
}
use of org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest in project controller by opendaylight.
the class RemoteProxyTransactionTest method testForwardToRemoteModifyDoCommit.
@Test
public void testForwardToRemoteModifyDoCommit() throws Exception {
final TestProbe probe = createProbe();
final TransactionDoCommitRequest request = new TransactionDoCommitRequest(TRANSACTION_ID, 0L, probe.ref());
final TransactionDoCommitRequest received = testForwardToRemote(request, TransactionDoCommitRequest.class);
Assert.assertEquals(request.getTarget(), received.getTarget());
}
use of org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest in project controller by opendaylight.
the class RemoteProxyTransaction method handleReplayedRemoteRequest.
@Override
void handleReplayedRemoteRequest(final TransactionRequest<?> request, @Nullable final Consumer<Response<?, ?>> callback, final long enqueuedTicks) {
final Consumer<Response<?, ?>> cb = callback != null ? callback : resp -> {
};
final Optional<Long> optTicks = Optional.of(Long.valueOf(enqueuedTicks));
if (request instanceof ModifyTransactionRequest) {
handleReplayedModifyTransactionRequest(enqueuedTicks, cb, (ModifyTransactionRequest) request);
} else if (request instanceof ReadTransactionRequest) {
ensureFlushedBuider(optTicks);
enqueueRequest(new ReadTransactionRequest(getIdentifier(), nextSequence(), localActor(), ((ReadTransactionRequest) request).getPath(), isSnapshotOnly()), resp -> {
recordFinishedRequest(resp);
cb.accept(resp);
}, enqueuedTicks);
} else if (request instanceof ExistsTransactionRequest) {
ensureFlushedBuider(optTicks);
enqueueRequest(new ExistsTransactionRequest(getIdentifier(), nextSequence(), localActor(), ((ExistsTransactionRequest) request).getPath(), isSnapshotOnly()), resp -> {
recordFinishedRequest(resp);
cb.accept(resp);
}, enqueuedTicks);
} else if (request instanceof TransactionPreCommitRequest) {
ensureFlushedBuider(optTicks);
final TransactionRequest<?> tmp = new TransactionPreCommitRequest(getIdentifier(), nextSequence(), localActor());
enqueueRequest(tmp, resp -> {
recordSuccessfulRequest(tmp);
cb.accept(resp);
}, enqueuedTicks);
} else if (request instanceof TransactionDoCommitRequest) {
ensureFlushedBuider(optTicks);
enqueueRequest(new TransactionDoCommitRequest(getIdentifier(), nextSequence(), localActor()), callback, enqueuedTicks);
} else if (request instanceof TransactionAbortRequest) {
ensureFlushedBuider(optTicks);
enqueueDoAbort(callback, enqueuedTicks);
} else if (request instanceof TransactionPurgeRequest) {
enqueuePurge(callback, enqueuedTicks);
} else if (request instanceof IncrementTransactionSequenceRequest) {
final IncrementTransactionSequenceRequest req = (IncrementTransactionSequenceRequest) request;
ensureFlushedBuider(optTicks);
enqueueRequest(new IncrementTransactionSequenceRequest(getIdentifier(), nextSequence(), localActor(), snapshotOnly, req.getIncrement()), callback, enqueuedTicks);
incrementSequence(req.getIncrement());
} else {
throw new IllegalArgumentException("Unhandled request {}" + request);
}
}
use of org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest in project controller by opendaylight.
the class RemoteProxyTransaction method handleForwardedRequest.
void handleForwardedRequest(final TransactionRequest<?> request, final Consumer<Response<?, ?>> callback) {
if (request instanceof ModifyTransactionRequest) {
handleForwardedModifyTransactionRequest(callback, (ModifyTransactionRequest) request);
} else if (request instanceof ReadTransactionRequest) {
ensureFlushedBuider();
sendRequest(new ReadTransactionRequest(getIdentifier(), nextSequence(), localActor(), ((ReadTransactionRequest) request).getPath(), isSnapshotOnly()), resp -> {
recordFinishedRequest(resp);
callback.accept(resp);
});
} else if (request instanceof ExistsTransactionRequest) {
ensureFlushedBuider();
sendRequest(new ExistsTransactionRequest(getIdentifier(), nextSequence(), localActor(), ((ExistsTransactionRequest) request).getPath(), isSnapshotOnly()), resp -> {
recordFinishedRequest(resp);
callback.accept(resp);
});
} else if (request instanceof TransactionPreCommitRequest) {
ensureFlushedBuider();
final TransactionRequest<?> tmp = new TransactionPreCommitRequest(getIdentifier(), nextSequence(), localActor());
sendRequest(tmp, resp -> {
recordSuccessfulRequest(tmp);
callback.accept(resp);
});
} else if (request instanceof TransactionDoCommitRequest) {
ensureFlushedBuider();
sendRequest(new TransactionDoCommitRequest(getIdentifier(), nextSequence(), localActor()), callback);
} else if (request instanceof TransactionAbortRequest) {
ensureFlushedBuider();
sendDoAbort(callback);
} else if (request instanceof TransactionPurgeRequest) {
enqueuePurge(callback);
} else {
throw new IllegalArgumentException("Unhandled request {}" + request);
}
}
use of org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest in project controller by opendaylight.
the class AbstractProxyTransaction method doCommit.
final void doCommit(final VotingFuture<?> ret) {
checkReadWrite();
checkSealed();
sendRequest(new TransactionDoCommitRequest(getIdentifier(), nextSequence(), localActor()), t -> {
if (t instanceof TransactionCommitSuccess) {
ret.voteYes();
} else if (t instanceof RequestFailure) {
ret.voteNo(((RequestFailure<?, ?>) t).getCause().unwrap());
} else {
ret.voteNo(unhandledResponseException(t));
}
LOG.debug("Transaction {} doCommit completed", this);
// Needed for ProxyHistory$Local data tree rebase points.
parent.completeTransaction(this);
enqueuePurge();
});
}
Aggregations