+ // The cohort actor list should already be built at this point by the canCommit phase but,
+ // if not for some reason, we'll try to build it here.
+
+ ListenableFuture<Void> future = resolveCohorts();
+ if(successfulFuture(future)) {
+ finishVoidOperation(operationName, messageSupplier, expectedResponseClass, propagateException,
+ returnFuture, callback);
+ } else {
+ Futures.addCallback(future, new FutureCallback<Void>() {
+ @Override
+ public void onSuccess(Void notUsed) {
+ finishVoidOperation(operationName, messageSupplier, expectedResponseClass,
+ propagateException, returnFuture, callback);
+ }
+
+ @Override
+ public void onFailure(Throwable failure) {
+ LOG.debug("Tx {}: a {} cohort path Future failed: {}", transactionId, operationName, failure);
+
+ if(propagateException) {
+ returnFuture.setException(failure);
+ } else {
+ returnFuture.set(null);
+ }
+ }
+ });
+ }
+
+ return returnFuture;
+ }
+
+ private void finishVoidOperation(final String operationName, MessageSupplier messageSupplier,
+ final Class<?> expectedResponseClass, final boolean propagateException,
+ final SettableFuture<Void> returnFuture, final OperationCallback callback) {
+ LOG.debug("Tx {} finish {}", transactionId, operationName);
+
+ callback.resume();
+
+ Future<Iterable<Object>> combinedFuture = invokeCohorts(messageSupplier);
+