@Override public void add(TransactionLogRecord record) { if (state != Transaction.State.ACTIVE) { throw new TransactionNotActiveException("Transaction is not active!"); } transactionLog.add(record); }
public void commitAsync(ExecutionCallback callback) { if (state != PREPARED) { throw new IllegalStateException("Transaction is not prepared"); } checkTimeout(); state = COMMITTING; transactionLog.commitAsync(nodeEngine, callback); // We should rethrow exception if transaction is not TWO_PHASE state = COMMITTED; }
@Override public TransactionLogRecord get(Object key) { return transactionLog.get(key); }
public List<Future> rollback(NodeEngine nodeEngine) { List<Future> futures = new ArrayList<Future>(size()); ListIterator<TransactionLogRecord> iterator = recordList.listIterator(size()); while (iterator.hasPrevious()) { TransactionLogRecord record = iterator.previous(); Future future = invoke(nodeEngine, record, record.newRollbackOperation()); futures.add(future); } return futures; }
public List<TransactionLogRecord> getTransactionRecords() { return transactionLog.getRecordList(); }
public XATransaction(NodeEngine nodeEngine, List<TransactionLogRecord> logs, String txnId, SerializableXID xid, String txOwnerUuid, long timeoutMillis, long startTime) { this.nodeEngine = nodeEngine; this.transactionLog = new TransactionLog(logs); this.timeoutMillis = timeoutMillis; this.txnId = txnId; this.xid = xid; this.txOwnerUuid = txOwnerUuid; ILogger logger = nodeEngine.getLogger(getClass()); this.commitExceptionHandler = logAllExceptions(logger, "Error during commit!", Level.WARNING); this.rollbackExceptionHandler = logAllExceptions(logger, "Error during rollback!", Level.WARNING); this.startTime = startTime; state = PREPARED; }
try { if (transactionType == TWO_PHASE) { if (transactionLog.size() > 1) { if (state != PREPARED) { throw new IllegalStateException("Transaction is not prepared"); try { state = COMMITTING; List<Future> futures = transactionLog.commit(nodeEngine); waitWithDeadline(futures, Long.MAX_VALUE, MILLISECONDS, RETHROW_TRANSACTION_EXCEPTION); state = COMMITTED;
public void commitAsync(NodeEngine nodeEngine, ExecutionCallback callback) { for (TransactionLogRecord record : recordList) { invokeAsync(nodeEngine, callback, record, record.newCommitOperation()); } }
@Override public void remove(Object key) { transactionLog.remove(key); }
@Override public void prepare() throws TransactionException { if (state != ACTIVE) { throw new TransactionNotActiveException("Transaction is not active"); } checkTimeout(); try { state = PREPARING; List<Future> futures = transactionLog.prepare(nodeEngine); waitWithDeadline(futures, timeoutMillis, MILLISECONDS, RETHROW_TRANSACTION_EXCEPTION); futures.clear(); putTransactionInfoRemote(); state = PREPARED; } catch (Throwable e) { throw ExceptionUtil.rethrow(e, TransactionException.class); } }
@Override public void commit() throws TransactionException, IllegalStateException { if (state != PREPARED) { throw new IllegalStateException("Transaction is not prepared"); } checkTimeout(); try { state = COMMITTING; List<Future> futures = transactionLog.commit(nodeEngine); // We should rethrow exception if transaction is not TWO_PHASE waitWithDeadline(futures, COMMIT_TIMEOUT_MINUTES, MINUTES, commitExceptionHandler); state = COMMITTED; } catch (Throwable e) { state = COMMIT_FAILED; throw ExceptionUtil.rethrow(e, TransactionException.class); } }
public List<TransactionLogRecord> getTransactionRecords() { return transactionLog.getRecordList(); }
public XATransaction(NodeEngine nodeEngine, List<TransactionLogRecord> logs, String txnId, SerializableXID xid, String txOwnerUuid, long timeoutMillis, long startTime) { this.nodeEngine = nodeEngine; this.transactionLog = new TransactionLog(logs); this.timeoutMillis = timeoutMillis; this.txnId = txnId; this.xid = xid; this.txOwnerUuid = txOwnerUuid; ILogger logger = nodeEngine.getLogger(getClass()); this.commitExceptionHandler = logAllExceptions(logger, "Error during commit!", Level.WARNING); this.rollbackExceptionHandler = logAllExceptions(logger, "Error during rollback!", Level.WARNING); this.startTime = startTime; state = PREPARED; }
try { if (transactionType == TWO_PHASE) { if (transactionLog.size() > 1) { if (state != PREPARED) { throw new IllegalStateException("Transaction is not prepared"); try { state = COMMITTING; List<Future> futures = transactionLog.commit(nodeEngine); waitWithDeadline(futures, Long.MAX_VALUE, MILLISECONDS, RETHROW_TRANSACTION_EXCEPTION); state = COMMITTED;
public void commitAsync(NodeEngine nodeEngine, ExecutionCallback callback) { for (TransactionLogRecord record : recordList) { invokeAsync(nodeEngine, callback, record, record.newCommitOperation()); } }
@Override public void remove(Object key) { transactionLog.remove(key); }
@Override public void prepare() throws TransactionException { if (state != ACTIVE) { throw new TransactionNotActiveException("Transaction is not active"); } checkTimeout(); try { state = PREPARING; List<Future> futures = transactionLog.prepare(nodeEngine); waitWithDeadline(futures, timeoutMillis, MILLISECONDS, RETHROW_TRANSACTION_EXCEPTION); futures.clear(); putTransactionInfoRemote(); state = PREPARED; } catch (Throwable e) { throw ExceptionUtil.rethrow(e, TransactionException.class); } }
@Override public void commit() throws TransactionException, IllegalStateException { if (state != PREPARED) { throw new IllegalStateException("Transaction is not prepared"); } checkTimeout(); try { state = COMMITTING; List<Future> futures = transactionLog.commit(nodeEngine); // We should rethrow exception if transaction is not TWO_PHASE waitWithDeadline(futures, COMMIT_TIMEOUT_MINUTES, MINUTES, commitExceptionHandler); state = COMMITTED; } catch (Throwable e) { state = COMMIT_FAILED; throw ExceptionUtil.rethrow(e, TransactionException.class); } }