use of org.opendaylight.controller.cluster.access.commands.SkipTransactionsRequest in project controller by opendaylight.
the class AbstractFrontendHistory method handleTransactionRequest.
@Nullable
final TransactionSuccess<?> handleTransactionRequest(final TransactionRequest<?> request, final RequestEnvelope envelope, final long now) throws RequestException {
if (request instanceof TransactionPurgeRequest) {
return handleTransactionPurgeRequest((TransactionPurgeRequest) request, envelope, now);
} else if (request instanceof SkipTransactionsRequest) {
return handleSkipTransactionsRequest((SkipTransactionsRequest) request, envelope, now);
}
final TransactionIdentifier id = request.getTarget();
final long txidBits = id.getTransactionId();
if (purgedTransactions.contains(txidBits)) {
LOG.warn("{}: Request {} is contained purged transactions {}", persistenceId, request, purgedTransactions);
throw new DeadTransactionException(purgedTransactions.toRangeSet());
}
final Boolean closed = closedTransactions.get(UnsignedLong.fromLongBits(txidBits));
if (closed != null) {
final boolean successful = closed;
LOG.debug("{}: Request {} refers to a {} transaction", persistenceId, request, successful ? "successful" : "failed");
throw new ClosedTransactionException(successful);
}
FrontendTransaction tx = transactions.get(id);
if (tx == null) {
// The transaction does not exist and we are about to create it, check sequence number
if (request.getSequence() != 0) {
LOG.warn("{}: no transaction state present, unexpected request {}", persistenceId(), request);
throw new OutOfOrderRequestException(0);
}
tx = createTransaction(request, id);
transactions.put(id, tx);
} else if (!(request instanceof IncrementTransactionSequenceRequest)) {
final Optional<TransactionSuccess<?>> maybeReplay = tx.replaySequence(request.getSequence());
if (maybeReplay.isPresent()) {
final TransactionSuccess<?> replay = maybeReplay.get();
LOG.debug("{}: envelope {} replaying response {}", persistenceId(), envelope, replay);
return replay;
}
}
return tx.handleRequest(request, envelope, now);
}
use of org.opendaylight.controller.cluster.access.commands.SkipTransactionsRequest in project controller by opendaylight.
the class ProxyHistory method doSkipTransactions.
@Holding("lock")
private void doSkipTransactions(final List<TransactionIdentifier> toSkip) {
final var txIds = toSkip.stream().mapToLong(TransactionIdentifier::getTransactionId).distinct().sorted().mapToObj(UnsignedLong::fromLongBits).collect(ImmutableList.toImmutableList());
LOG.debug("Proxy {} skipping transactions {}", this, txIds);
connection.enqueueRequest(new SkipTransactionsRequest(new TransactionIdentifier(identifier, txIds.get(0).longValue()), 0, localActor(), txIds.subList(1, txIds.size())), resp -> {
LOG.debug("Proxy {} confirmed transaction skip", this);
}, connection.currentTime());
}
Aggregations