public Transaction(DatasetGraphTDB dsg, long version, TxnType txnType, ReadWrite mode, long id, TxnType originalTxnType, String label, TransactionManager txnMgr) { this.id = id ; if (label == null ) label = "Txn" ; label = label+"["+id+"]" ; switch(mode) { case READ : label = label+"/R" ; break ; case WRITE : label = label+"/W" ; break ; } this.label = label ; this.txnMgr = txnMgr ; this.basedsg = dsg ; this.version = version ; this.txnType = txnType ; this.originalTxnType = originalTxnType ; this.mode = mode ; this.journal = ( txnMgr == null ) ? null : txnMgr.getJournal() ; activedsg = null ; // Don't know yet. this.iterators = null ; //new ArrayList<>() ; // Debugging aid. state = TxnState.ACTIVE ; outcome = TxnOutcome.UNFINISHED ; changesPending = (mode == ReadWrite.WRITE) ; }
/** Highly risky! */ public void printJournal() { JournalControl.print(transactionManager.getJournal()); }
/** Flush the journal regardless - use with great case - do not use when transactions may be active. */ public void forceRecoverFromJournal() { JournalControl.recoverFromJournal(getBaseDataset().getConfig(), transactionManager.getJournal()); }
/** Stop managing a location. Use with great care (testing only). */ public static synchronized void expel(Location location, boolean force) { StoreConnection sConn = cache.get(location) ; if (sConn == null) return ; if (!force && sConn.transactionManager.activeTransactions()) throw new TDBTransactionException("Can't expel: Active transactions for location: " + location) ; // No transactions at this point (or we don't care and are clearing up forcefully.) sConn.transactionManager.closedown() ; sConn.baseDSG.close() ; sConn.isValid = false ; cache.remove(location) ; ChannelManager.release(sConn.transactionManager.getJournal().getFilename()) ; // Release the lock if (SystemTDB.DiskLocationMultiJvmUsagePrevention) { if (location.getLock().isOwned()) { location.getLock().release(); } else if (location.getLock().canLock()) { SystemTDB.errlog.warn("Location " + location.getDirectoryPath() + " was not locked, if another JVM accessed this location simultaneously data corruption may have occurred"); } } }