use of org.opendaylight.controller.cluster.access.commands.PersistenceProtocol in project controller by opendaylight.
the class LocalReadOnlyProxyTransaction method commonModifyTransactionRequest.
private static void commonModifyTransactionRequest(final ModifyTransactionRequest request) {
Verify.verify(request.getModifications().isEmpty());
final PersistenceProtocol protocol = request.getPersistenceProtocol().get();
Verify.verify(protocol == PersistenceProtocol.ABORT);
}
use of org.opendaylight.controller.cluster.access.commands.PersistenceProtocol in project controller by opendaylight.
the class FrontendReadWriteTransaction method handleModifyTransaction.
@Nullable
private TransactionSuccess<?> handleModifyTransaction(final ModifyTransactionRequest request, final RequestEnvelope envelope, final long now) throws RequestException {
// We need to examine the persistence protocol first to see if this is an idempotent request. If there is no
// protocol, there is nothing for us to do.
final java.util.Optional<PersistenceProtocol> maybeProto = request.getPersistenceProtocol();
if (!maybeProto.isPresent()) {
applyModifications(request.getModifications());
return replyModifySuccess(request.getSequence());
}
switch(maybeProto.get()) {
case ABORT:
if (ABORTING.equals(state)) {
LOG.debug("{}: Transaction {} already aborting", persistenceId(), getIdentifier());
return null;
}
final ReadWriteShardDataTreeTransaction openTransaction = checkOpen();
startAbort();
openTransaction.abort(() -> {
recordAndSendSuccess(envelope, now, new ModifyTransactionSuccess(getIdentifier(), request.getSequence()));
finishAbort();
});
return null;
case READY:
ensureReady(request.getModifications());
return replyModifySuccess(request.getSequence());
case SIMPLE:
ensureReady(request.getModifications());
directCommit(envelope, now);
return null;
case THREE_PHASE:
ensureReady(request.getModifications());
coordinatedCommit(envelope, now);
return null;
default:
LOG.warn("{}: rejecting unsupported protocol {}", persistenceId(), maybeProto.get());
throw new UnsupportedRequestException(request);
}
}
Aggregations