@Override public void abort() { delegate.abort(); }
/** * Start a transaction which is READ mode and which will switch to WRITE if an update * is attempted but only if no intermediate transaction has performed an update. * <p> * See {@link #begin(TxnType)} for more details an options. * <p> * May not be implemented. See {@link #begin(ReadWrite)} is guaranteed to be provided. */ public default void begin() { begin(TxnType.READ_PROMOTE); }
@Override public void commit() { delegate.commit(); }
public void end() { dataService.finishTxn() ; if ( transactional.isInTransaction() ) { Log.warn(this, "Transaction still active - no commit or abort seen (forced abort)") ; try { transactional.abort() ; } catch (RuntimeException ex) { Log.warn(this, "Exception in forced abort (trying to continue)", ex) ; } } if ( transactional.isInTransaction() ) transactional.end() ; activeDSG = null ; }
@Override public boolean promote(Promote txnType) { return txn.promote(txnType); } @Override public void commit() { txn.commit(); }
@Override public ReadWrite transactionMode() { return delegate.transactionMode(); }
/** Say whether a transaction is active */ @Override public boolean isInTransaction() { return transactional != null && transactional.isInTransaction(); }
@Override public void end() { delegate.end(); }
@Override public TxnType transactionType() { return delegate.transactionType(); } }
@Test public void txn_threaded_02() { //Transactional tx = DatasetGraphFactory.createTxnMem(); Transactional tx = counter; // Start and enter the W transaction. ThreadAction a = ThreadTxn.threadTxnWrite(tx, ()->{}); // ThreadAction started ... in W transaction. Txn.exec(tx, TxnType.READ_PROMOTE, ()->{ // ... have the thread action complete. a.run(); // Blocks promotion. boolean b = tx.promote(); assertFalse(b); assertEquals(ReadWrite.READ, tx.transactionMode()); }); }
public void end() { dataService.finishTxn() ; if ( transactional.isInTransaction() ) { Log.warn(this, "Transaction still active - no commit or abort seen (forced abort)") ; try { transactional.abort() ; } catch (RuntimeException ex) { Log.warn(this, "Exception in forced abort (trying to continue)", ex) ; } } if ( transactional.isInTransaction() ) transactional.end() ; activeDSG = null ; }
@Override public boolean promote(Promote txnType) { return txn.promote(txnType); } @Override public void commit() { txn.commit(); }
@Override public ReadWrite transactionMode() { return txn.transactionMode(); } @Override public TxnType transactionType() { return txn.transactionType(); }
@Override public boolean isInTransaction() { return txn.isInTransaction(); } @Override public void end() { txn.end(); }
@Override public void end() { txn.end(); } @Override public ReadWrite transactionMode() { return txn.transactionMode(); }
@Override public TxnType transactionType() { return txn.transactionType(); } @Override public boolean supportsTransactions() { return true; }
private static Runnable beforeAction(Transactional trans, TxnType txnType, boolean isCommit) { return ()-> trans.begin(txnType) ; }