private void log(String msg, Transaction txn) { if ( ! log() ) return ; if ( txn == null ) logger().debug("<No txn>: "+msg) ; else logger().debug(txn.getLabel()+": "+msg) ; }
private void writerCommitsWorker(Transaction txn) { if ( activeReaders.get() == 0 && checkForJournalFlush() ) { // Can commit immediately. // Ensure the queue is empty though. // Could simply add txn to the commit queue and do it that way. if ( log() ) log("Commit immediately", txn) ; // Currently, all we need is // JournalControl.replay(txn) ; // because that plays queued transactions. // But for long term generallity, at the cost of one check of the journal size // we do this sequence. processDelayedReplayQueue(txn) ; enactTransaction(txn) ; JournalControl.replay(txn) ; } else { // Can't write back to the base database at the moment. commitedAwaitingFlush.add(txn) ; maxQueue = Math.max(commitedAwaitingFlush.size(), maxQueue) ; if ( log() ) log("Add to pending queue", txn) ; queue.add(txn) ; } }
private void logInternal(String action, Transaction txn) { if ( ! log() ) return ; String txnStr = ( txn == null ) ? "<null>" : txn.getLabel() ; //System.err.printf(format("%6s %s -- %s", action, txnStr, state())) ; logger().debug(format("%6s %s -- %s", action, txnStr, state())) ; }
private void checkNodesDatJrnl(String label, Transaction txn) { if ( txn != null ) { String x = txn.getBaseDataset().getLocation().getPath(label + ": nodes.dat-jrnl") ; long len = new File(x).length() ; if ( len != 0 ) log("nodes.dat-jrnl: not empty", txn) ; } }
if ( queue.size() > 0 && log() ) log(format("Pending transactions: R=%s / W=%s", activeReaders, activeWriters), txn) ; return ; if ( log() ) log("Start flush delayed commits", txn) ; if ( txn2.getTxnMode() == ReadWrite.READ ) continue ; if ( log() ) log(" Flush delayed commit of "+txn2.getLabel(), txn) ; if ( DEBUG ) checkNodesDatJrnl("2", txn) ; checkReplaySafe() ; if ( log() ) log("End flush delayed commits", txn) ;
synchronized private DatasetGraphTxn begin$(TxnType txnType, TxnType originalTxnType, String label) { Objects.requireNonNull(txnType); if ( txnType == TxnType.WRITE && activeWriters.get() > 0 ) // Guard throw new TDBTransactionException("Existing active write transaction") ; if ( DEBUG ) switch ( txnType ) { case READ : System.out.print("r") ; break ; case WRITE : System.out.print("w") ; break ; case READ_COMMITTED_PROMOTE : System.out.print("r(cp)") ; break ; case READ_PROMOTE : System.out.print("rp") ; break ; } DatasetGraphTDB dsg = determineBaseDataset() ; Transaction txn = createTransaction(dsg, txnType, originalTxnType, label) ; log("begin$", txn) ; ReadWrite mode = initialMode(txnType); DatasetGraphTxn dsgTxn = createDSGTxn(dsg, txn, mode); txn.setActiveDataset(dsgTxn) ; dsgTxn.getTransaction().forAllComponents(component->component.begin(dsgTxn.getTransaction())) ; return dsgTxn ; }