@Override public void commit() { getT().commit(); }
@Override public void commit() { getDSG().commit(); getDSG().end(); }
@Override public void finishBulk() { if ( bulkUseTransaction() ) { dsg.commit(); dsg.end(); } long totalElapsed = timer.endTimer(); outputSummary(totalElapsed); }
@Test(expected=JenaTransactionException.class) public void zero_txn_3() { DatasetGraph dsg = DatasetGraphZero.create(); dsg.commit(); }
@Test(expected=JenaTransactionException.class) public void sink_txn_3() { DatasetGraph dsg = DatasetGraphSink.create(); dsg.commit(); }
private void run_01(TxnType txnType) { DatasetGraph dsg = create() ; dsg.begin(txnType) ; dsg.add(q1) ; dsg.commit() ; dsg.end() ; }
private void run_02(TxnType txnType) { DatasetGraph dsg = create() ; dsg.begin(txnType) ;dsg.end() ; dsg.begin(txnType) ; dsg.add(q1) ; dsg.commit() ; dsg.end() ; }
private void run_04(TxnType txnType) { DatasetGraph dsg = create() ; dsg.begin(ReadWrite.WRITE) ;dsg.abort() ; dsg.end() ; dsg.begin(txnType) ; dsg.add(q1) ; dsg.commit() ; dsg.end() ; }
private void run_07(TxnType txnType) { DatasetGraph dsg = create() ; // Start long running reader. ThreadAction tt = ThreadTxn.threadTxnRead(dsg, () -> { long x = Iter.count(dsg.find()) ; if ( x != 0 ) throw new RuntimeException() ; }) ; // Start R->W here dsg.begin(txnType) ; dsg.add(q1) ; dsg.add(q2) ; dsg.commit() ; dsg.end() ; tt.run() ; }
@Test public void txnRead1() { final DatasetGraph dsg = emptyDsg(); assertFalse(dsg.isInTransaction()); dsg.begin(ReadWrite.READ); assertTrue(dsg.isInTransaction()); dsg.commit(); dsg.end(); }
private void run_08(TxnType txnType) { DatasetGraph dsg = create() ; // Start R->W here dsg.begin(txnType) ; dsg.add(q1) ; dsg.add(q2) ; dsg.commit() ; dsg.end() ; Txn.executeRead(dsg, () -> { long x = Iter.count(dsg.find()) ; assertEquals(2, x) ; }) ; }
@Test public void isolation_01() { // Start a read transaction on another thread. // The transaction has begin() by the time threadTxnRead // returns but the action of the ThreadTxn is not triggered // until other.run() is called. DatasetGraph dsg = create() ; ThreadAction other = ThreadTxn.threadTxnRead(dsg, ()-> Assert.assertTrue(dsg.isEmpty()) ) ; dsg.begin(WRITE) ; dsg.add(q1) ; dsg.commit() ; dsg.end() ; other.run() ; } }
private void test_thread_writer(TxnType txnType) { DatasetGraph dsg = create(); ThreadAction a = ThreadTxn.threadTxnWrite(dsg, ()->dsg.add(q1)); dsg.begin(txnType); assertEquals(txnType, dsg.transactionType()); a.run(); dsg.add(q2); // TDB1 does not keep the the original TxnType. assertEquals(txnType, dsg.transactionType()); assertEquals(ReadWrite.WRITE, dsg.transactionMode()); dsg.commit(); dsg.end(); }
private void promote_readCommit_txnCommit(TxnType txnType, boolean asyncCommit) { DatasetGraph dsg = create() ; ThreadAction tt = asyncCommit? ThreadTxn.threadTxnWrite(dsg, () -> dsg.add(q3) ) : ThreadTxn.threadTxnWriteAbort(dsg, () -> dsg.add(q3)) ; dsg.begin(txnType) ; // Other runs tt.run() ; // Can promote if readCommited // Can't promote if not readCommited dsg.add(q1) ; if ( txnType == TxnType.READ_PROMOTE && asyncCommit ) fail("Should not be here") ; // read commited - we should see the ThreadAction change. assertEquals(asyncCommit, dsg.contains(q3)) ; dsg.commit() ; dsg.end() ; //logger2.setLevel(level2); }
@Test public void exclusive_1() { DatasetGraph dsg = TDBFactory.createDatasetGraph() ; TransactionManager txnmgr = TDBInternal.getTransactionManager(dsg) ; checkTxnMgr(txnmgr, 0, 0) ; ReentrantReadWriteLock rwx = (ReentrantReadWriteLock)txnmgr.getExclusivityLock$() ; checkLock(rwx,0,0) ; dsg.begin(ReadWrite.WRITE); checkLock(rwx,1,0) ; // Exclusivity reader lock. checkTxnMgr(txnmgr, 0, 1) ; dsg.commit(); checkLock(rwx,0,0) ; // Exclusivity reader lock. checkTxnMgr(txnmgr, 0, 0) ; dsg.end(); checkLock(rwx,0,0) ; // Exclusivity reader lock. checkTxnMgr(txnmgr, 0, 0) ; }
@Test public void exclusive_1() { DatasetGraph dsg = TDBFactory.createDatasetGraph() ; TransactionManager txnmgr = TDBInternal.getTransactionManager(dsg) ; checkTxnMgr(txnmgr, 0, 0) ; ReentrantReadWriteLock rwx = (ReentrantReadWriteLock)txnmgr.getExclusivityLock$() ; checkLock(rwx,0,0) ; dsg.begin(ReadWrite.WRITE); checkLock(rwx,1,0) ; // Exclusivity reader lock. checkTxnMgr(txnmgr, 0, 1) ; dsg.commit(); checkLock(rwx,0,0) ; // Exclusivity reader lock. checkTxnMgr(txnmgr, 0, 0) ; dsg.end(); checkLock(rwx,0,0) ; // Exclusivity reader lock. checkTxnMgr(txnmgr, 0, 0) ; }
private void test_promote_thread_writer(TxnType txnType) { DatasetGraph dsg = create(); ThreadAction a = ThreadTxn.threadTxnWrite(dsg, ()->dsg.add(q1)); dsg.begin(txnType); assertEquals(txnType, dsg.transactionType()); a.run(); boolean b = dsg.promote(); if ( txnType == TxnType.READ_PROMOTE ) assertFalse(b); if ( txnType == TxnType.READ_COMMITTED_PROMOTE ) assertTrue(b); dsg.add(q2); assertEquals(txnType, dsg.transactionType()); assertEquals(ReadWrite.WRITE, dsg.transactionMode()); dsg.commit(); dsg.end(); }