- public void close() {
- if (STATE_UPDATER.compareAndSet(this, IDLE_STATE, CLOSED_STATE)) {
- // FIXME: signal close to both client actor and backend actor
- } else if (state != CLOSED_STATE) {
- throw new IllegalStateException("Cannot close history with an open transaction");
+ AbstractTransactionCommitCohort onTransactionReady(final ClientTransaction tx,
+ final AbstractTransactionCommitCohort cohort) {
+
+ final State local = state();
+ switch (local) {
+ case CLOSED:
+ return super.onTransactionReady(tx, cohort);
+ case IDLE:
+ throw new IllegalStateException(String.format("Local history %s is idle when readying transaction %s",
+ this, tx.getIdentifier()));
+ case TX_OPEN:
+ updateState(local, State.IDLE);
+ return super.onTransactionReady(tx, cohort);
+ default:
+ throw new IllegalStateException(String.format("Local history %s in unhandled state %s", this, local));
+