/** Flush the delayed write queue to the base storage. * This can only be done if there are no active transactions. * If there are active transactions, nothing is done but this is safe to call. */ public void flush() { if ( !haveUsedInTransaction() ) return; checkValid(); transactionManager.flush(); }
public void syncIfNotTransactional() { if ( !sConn.haveUsedInTransaction() ) sConn.getBaseDataset().sync() ; }
@Override public void sync() { if ( !sConn.haveUsedInTransaction() && get() != null ) get().sync() ; } }
@Override protected void checkNotActive() { checkNotClosed() ; if ( sConn.haveUsedInTransaction() && isInTransaction() ) throw new JenaTransactionException("Currently in a transaction (" + getLocation() + ")") ; }
/** Get the current DatasetGraphTDB */ @Override public DatasetGraphTDB get() { if ( isInTransaction() ) { DatasetGraphTxn dsgTxn = dsgtxn.get() ; if ( dsgTxn == null ) throw new TDBTransactionException("In a transaction but no transactional DatasetGraph") ; return dsgTxn.getView() ; } if ( sConn.haveUsedInTransaction() ) throw new TDBTransactionException("Not in a transaction") ; // Never been used in a transaction - return underlying database for old // style (non-transactional) usage. return sConn.getBaseDataset() ; }
@Override protected synchronized void _close() { if ( isClosed ) return ; if ( sConn.haveUsedInTransaction() ) { if ( isInTransaction() ) { TDB.logInfo.warn("Attempt to close a DatasetGraphTransaction while a transaction is active - ignored close (" + getLocation() + ")") ; return ; } // Otherwise ignore - close() while transactional is meaningless. return ; } synchronized(this) { if ( ! sConn.isValid() ) { // There may be another DatasetGraphTransaction using this location // and that DatasetGraphTransaction has been closed, invalidating // the StoreConnection. return ; } DatasetGraphTDB dsg = sConn.getBaseDataset() ; dsg.sync() ; dsg.close() ; StoreConnection.release(getLocation()) ; dsgtxn.remove() ; inTransaction.remove() ; isClosed = true ; return ; } }
@Override protected PrefixMapping createPrefixMapping() { boolean txnMode = getDatasetGraphTransaction() != null && getDatasetGraphTransaction().getStoreConnection().haveUsedInTransaction() ; if ( ! txnMode ) return createPrefixMapping$(); return Txn.calculateRead(getDataset(),()-> createPrefixMapping$()); }