*/
COMMITED,
/**
- * Some of cohorts responsed back with unsuccessful message.
+ * Some of cohorts responded back with unsuccessful message.
*/
FAILED,
/**
this.timeout = Preconditions.checkNotNull(timeout);
}
+ void reset() {
+ switch (state) {
+ case CAN_COMMIT_SENT:
+ case CAN_COMMIT_SUCCESSFUL:
+ case PRE_COMMIT_SENT:
+ case PRE_COMMIT_SUCCESSFUL:
+ case COMMIT_SENT:
+ abort();
+ break;
+ default :
+ break;
+ }
+
+ successfulFromPrevious = null;
+ state = State.IDLE;
+ }
+
void canCommit(final DataTreeCandidate tip) throws ExecutionException, TimeoutException {
Collection<CanCommit> messages = registry.createCanCommitMessages(txId, tip, schema);
// FIXME: Optimize empty collection list with pre-created futures, containing success.
}
Optional<Future<Iterable<Object>>> abort() {
- if (successfulFromPrevious != null) {
+ state = State.ABORTED;
+ if (successfulFromPrevious != null && !Iterables.isEmpty(successfulFromPrevious)) {
return Optional.of(sendMesageToSuccessful(new DataTreeCohortActor.Abort(txId)));
}