private final DurationStatisticsTracker commitStatTracker;
private final DOMDataWriteTransaction tx;
- public CommitCoordinationTask(final DOMDataWriteTransaction transaction,
+ CommitCoordinationTask(final DOMDataWriteTransaction transaction,
final Collection<DOMStoreThreePhaseCommitCohort> cohorts,
final DurationStatisticsTracker commitStatTracker) {
this.tx = Preconditions.checkNotNull(transaction, "transaction must not be null");
}
/**
- *
* Invokes canCommit on underlying cohorts and blocks till
* all results are returned.
*
+ * <p>
* Valid state transition is from SUBMITTED to CAN_COMMIT,
* if currentPhase is not SUBMITTED throws IllegalStateException.
*
}
/**
- *
* Invokes canCommit on underlying cohorts and returns composite future
* which will contains {@link Boolean#TRUE} only and only if
* all cohorts returned true.
*
+ * <p>
* Valid state transition is from SUBMITTED to CAN_COMMIT,
* if currentPhase is not SUBMITTED throws IllegalStateException.
*
*/
private ListenableFuture<?>[] canCommitAll() {
final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int i = 0;
+ int index = 0;
for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[i++] = cohort.canCommit();
+ ops[index++] = cohort.canCommit();
}
return ops;
}
/**
- *
* Invokes preCommit on underlying cohorts and blocks till
* all results are returned.
*
+ * <p>
* Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current
* state is not CAN_COMMIT
* throws IllegalStateException.
private void preCommitBlocking() throws TransactionCommitFailedException {
final ListenableFuture<?>[] preCommitFutures = preCommitAll();
try {
- for(final ListenableFuture<?> future : preCommitFutures) {
+ for (final ListenableFuture<?> future : preCommitFutures) {
future.get();
}
} catch (InterruptedException | ExecutionException e) {
}
/**
- *
* Invokes preCommit on underlying cohorts and returns future
* which will complete once all preCommit on cohorts completed or
* failed.
*
- *
+ * <p>
* Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current
* state is not CAN_COMMIT
* throws IllegalStateException.
*/
private ListenableFuture<?>[] preCommitAll() {
final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int i = 0;
+ int index = 0;
for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[i++] = cohort.preCommit();
+ ops[index++] = cohort.preCommit();
}
return ops;
}
/**
- *
* Invokes commit on underlying cohorts and blocks till
* all results are returned.
*
+ * <p>
* Valid state transition is from PRE_COMMIT to COMMIT, if not throws
* IllegalStateException.
*
private void commitBlocking() throws TransactionCommitFailedException {
final ListenableFuture<?>[] commitFutures = commitAll();
try {
- for(final ListenableFuture<?> future : commitFutures) {
+ for (final ListenableFuture<?> future : commitFutures) {
future.get();
}
} catch (InterruptedException | ExecutionException e) {
}
/**
- *
* Invokes commit on underlying cohorts and returns future which
* completes
* once all commits on cohorts are completed.
*
+ * <p>
* Valid state transition is from PRE_COMMIT to COMMIT, if not throws
* IllegalStateException
*
*/
private ListenableFuture<?>[] commitAll() {
final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int i = 0;
+ int index = 0;
for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[i++] = cohort.commit();
+ ops[index++] = cohort.commit();
}
return ops;
}
/**
* Aborts transaction.
*
+ * <p>
* Invokes {@link DOMStoreThreePhaseCommitCohort#abort()} on all
* cohorts, blocks
* for all results. If any of the abort failed throws
* IllegalStateException,
* which will contains originalCause as suppressed Exception.
*
+ * <p>
* If aborts we're successful throws supplied exception
*
* @param originalCause
* @throws IllegalStateException
* if abort failed.
*/
- private void abortBlocking(final TransactionCommitFailedException originalCause) throws TransactionCommitFailedException {
+ private void abortBlocking(
+ final TransactionCommitFailedException originalCause) throws TransactionCommitFailedException {
Exception cause = originalCause;
try {
abortAsyncAll().get();
private ListenableFuture<Void> abortAsyncAll() {
final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int i = 0;
+ int index = 0;
for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[i++] = cohort.abort();
+ ops[index++] = cohort.abort();
}
/*