public void onSuccess(Boolean result) {
if (result == null || !result) {
handleException(clientSubmitFuture, transaction, cohorts, cohortSize,
- CAN_COMMIT, new TransactionCommitFailedException(
+ CAN_COMMIT, TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER,
+ new TransactionCommitFailedException(
"Can Commit failed, no detailed cause available."));
} else {
if(remaining.decrementAndGet() == 0) {
@Override
public void onFailure(Throwable t) {
- handleException(clientSubmitFuture, transaction, cohorts, cohortSize, CAN_COMMIT, t);
+ handleException(clientSubmitFuture, transaction, cohorts, cohortSize, CAN_COMMIT,
+ TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER, t);
}
};
@Override
public void onFailure(Throwable t) {
- handleException(clientSubmitFuture, transaction, cohorts, cohortSize, PRE_COMMIT, t);
+ handleException(clientSubmitFuture, transaction, cohorts, cohortSize, PRE_COMMIT,
+ TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER, t);
}
};
@Override
public void onFailure(Throwable t) {
- handleException(clientSubmitFuture, transaction, cohorts, cohortSize, COMMIT, t);
+ handleException(clientSubmitFuture, transaction, cohorts, cohortSize, COMMIT,
+ TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER, t);
}
};
private void handleException(final AsyncNotifyingSettableFuture clientSubmitFuture,
final DOMDataWriteTransaction transaction,
final Iterable<DOMStoreThreePhaseCommitCohort> cohorts, int cohortSize,
- final String phase, final Throwable t) {
+ final String phase, final TransactionCommitFailedExceptionMapper exMapper,
+ final Throwable t) {
if(clientSubmitFuture.isDone()) {
// We must have had failures from multiple cohorts.
e = new RuntimeException("Unexpected error occurred", t);
}
- final TransactionCommitFailedException clientException =
- TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER.apply(e);
+ final TransactionCommitFailedException clientException = exMapper.apply(e);
// Transaction failed - tell all cohorts to abort.