@Override public void begin() throws IllegalStateException { if (state == ACTIVE) { throw new IllegalStateException("Transaction is already active"); } if (TRANSACTION_EXISTS.get() != null) { throw new IllegalStateException("Nested transactions are not allowed!"); } startTime = currentTimeMillis(); backupAddresses = transactionManagerService.pickBackupLogAddresses(durability); //init caller thread if (threadId == null) { threadId = Thread.currentThread().getId(); setThreadFlag(TRUE); } state = ACTIVE; transactionManagerService.startCount.inc(); }
@Override public void begin() throws IllegalStateException { if (state == ACTIVE) { throw new IllegalStateException("Transaction is already active"); } if (TRANSACTION_EXISTS.get() != null) { throw new IllegalStateException("Nested transactions are not allowed!"); } startTime = currentTimeMillis(); backupAddresses = transactionManagerService.pickBackupLogAddresses(durability); //init caller thread if (threadId == null) { threadId = Thread.currentThread().getId(); setThreadFlag(TRUE); } state = ACTIVE; transactionManagerService.startCount.inc(); }
@Override public void rollback() throws IllegalStateException { try { if (state == NO_TXN || state == ROLLED_BACK) { throw new IllegalStateException("Transaction is not active"); } checkThread(); state = ROLLING_BACK; try { //TODO: Do we need both a purge and rollback? rollbackBackupLogs(); List<Future> futures = transactionLog.rollback(nodeEngine); waitWithDeadline(futures, Long.MAX_VALUE, MILLISECONDS, rollbackExceptionHandler); purgeBackupLogs(); } catch (Throwable e) { throw rethrow(e); } finally { state = ROLLED_BACK; transactionManagerService.rollbackCount.inc(); } } finally { setThreadFlag(null); } }
@Override public void rollback() throws IllegalStateException { try { if (state == NO_TXN || state == ROLLED_BACK) { throw new IllegalStateException("Transaction is not active"); } checkThread(); state = ROLLING_BACK; try { //TODO: Do we need both a purge and rollback? rollbackBackupLogs(); List<Future> futures = transactionLog.rollback(nodeEngine); waitWithDeadline(futures, Long.MAX_VALUE, MILLISECONDS, rollbackExceptionHandler); purgeBackupLogs(); } catch (Throwable e) { throw rethrow(e); } finally { state = ROLLED_BACK; transactionManagerService.rollbackCount.inc(); } } finally { setThreadFlag(null); } }