- private void doCanCommit(final CohortEntry cohortEntry) {
- boolean canCommit = false;
- try {
- canCommit = cohortEntry.canCommit();
-
- log.debug("{}: canCommit for {}: {}", name, cohortEntry.getTransactionID(), canCommit);
-
- if(cohortEntry.isDoImmediateCommit()) {
- if(canCommit) {
- doCommit(cohortEntry);
- } else {
- cohortEntry.getReplySender().tell(new Failure(new TransactionCommitFailedException(
- "Can Commit failed, no detailed cause available.")), cohortEntry.getShard().self());
- }
- } else {
- cohortEntry.getReplySender().tell(
- canCommit ? CanCommitTransactionReply.yes(cohortEntry.getClientVersion()).toSerializable() :
- CanCommitTransactionReply.no(cohortEntry.getClientVersion()).toSerializable(),
- cohortEntry.getShard().self());
- }
- } catch (Exception e) {
- log.debug("{}: An exception occurred during canCommit", name, e);
-
- Throwable failure = e;
- if(e instanceof ExecutionException) {
- failure = e.getCause();
- }
-
- cohortEntry.getReplySender().tell(new Failure(failure), cohortEntry.getShard().self());
- } finally {
- if(!canCommit) {
- // Remove the entry from the cache now.
- currentTransactionComplete(cohortEntry.getTransactionID(), true);
- }
- }
- }
-
- private boolean doCommit(CohortEntry cohortEntry) {
- log.debug("{}: Committing transaction {}", name, cohortEntry.getTransactionID());
-
- boolean success = false;