/** Return the location of a DatasetGraph if it is backed by TDB, else null */ public static Location location(DatasetGraph datasetGraph) { if ( datasetGraph instanceof DatasetGraphTDB ) return ((DatasetGraphTDB)datasetGraph).getLocation() ; if ( datasetGraph instanceof DatasetGraphTransaction ) return ((DatasetGraphTransaction)datasetGraph).getLocation() ; return null ; }
public Location getLocation() { checkValid(); return baseDSG.getLocation(); }
public TransactionManager(DatasetGraphTDB dsg){ this.baseDataset = dsg ; this.journal = Journal.create(dsg.getLocation()) ; // LATER // Committer c = new Committer() ; // this.committerThread = new Thread(c) ; // committerThread.setDaemon(true) ; // committerThread.start() ; }
@Override public String toString() { return "Transaction: " + id + " : Mode=" + mode + " : State=" + state + " : " + basedsg.getLocation().getDirectoryPath() ; }
private static Journal findJournal(DatasetGraphTDB dsg) { Location loc = dsg.getLocation() ; String journalFilename = loc.absolute(Names.journalFile) ; File f = new File(journalFilename) ; //if ( FileOps.exists(journalFilename) if ( f.exists() && f.isFile() && f.length() > 0 ) return Journal.create(loc) ; else return null ; }
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) ; } }
/** Stop managing a DatasetGraph. Use with great care. */ public static synchronized void expel(DatasetGraph dsg) { DatasetGraphTDB dsgtdb = Txn.calculate(dsg, ()->getDatasetGraphTDB(dsg)); if ( dsgtdb == null ) return; StoreConnection.expel(dsgtdb.getLocation(), false); // No longer valid. }
@Override final public void finishBulk() { loaderTriples.loadDataFinish() ; loaderTriples.loadIndexStart() ; loaderTriples.loadIndexFinish() ; loaderTriples.loadFinish() ; if ( !dsg.getLocation().isMem() && startedEmpty && stats != null ) { String filename = dsg.getLocation().getPath(Names.optStats) ; Stats.write(filename, stats.results()) ; } forceSync(dsg) ; }
synchronized /*package*/ void notifyClose(Transaction txn) { // Caution - not called if "Transactional.end() is not called." if ( txn.getState() == TxnState.ACTIVE ) { // The application error case for begin(WRITE)...end() is handled in Trasnaction.close(). // This is internal checking. String x = txn.getBaseDataset().getLocation().getDirectoryPath() ; syslog.warn("close: Transaction not commited or aborted: Transaction: "+txn.getTxnId()+" @ "+x) ; // Force abort then close txn.abort() ; txn.close() ; return ; } noteTxnClose(txn) ; }
private DatasetGraphTDB buildReadonly() { BlockMgrBuilder blockMgrBuilder = new BlockMgrBuilderReadonly(); ObjectFileBuilder objectFileBuilder = new ObjectFileBuilderReadonly(); DatasetBuilderStd x = new DatasetBuilderStd(blockMgrBuilder, objectFileBuilder) ; DatasetGraphTDB dsg2 = x._build(dsg.getLocation(), dsg.getConfig().params, false, dsg.getReorderTransform()) ; return dsg2 ; }
@Override public void finishBulk() { loaderTriples.loadDataFinish() ; loaderQuads.loadDataFinish() ; loaderTriples.loadIndexStart() ; loaderQuads.loadIndexStart() ; loaderTriples.loadIndexFinish() ; loaderQuads.loadIndexFinish() ; loaderTriples.loadFinish() ; loaderQuads.loadFinish() ; if ( !dsg.getLocation().isMem() && startedEmpty && stats != null ) { String filename = dsg.getLocation().getPath(Names.optStats) ; Stats.write(filename, stats.results()) ; } forceSync(dsg) ; }
private DatasetGraphTDB buildWritable() { BlockMgrBuilder blockMgrBuilder = new BlockMgrBuilderTx() ; ObjectFileBuilder objectFileBuilder = new ObjectFileBuilderTx(); DatasetBuilderStd x = new DatasetBuilderStd(blockMgrBuilder, objectFileBuilder); DatasetGraphTDB dsg2 = x._build(dsg.getLocation(), dsg.getConfig().params, true, dsg.getReorderTransform()) ; dsg2.getContext().putAll(dsg.getContext()) ; return dsg2 ; }
/** Recover a base storage DatasetGraph */ public static void recovery(DatasetGraphTDB dsg) { if ( dsg.getLocation().isMem() ) return ; // Do we need to recover? Journal journal = findJournal(dsg) ; if ( journal == null || journal.isEmpty() ) return ; recoverFromJournal(dsg.getConfig(), journal) ; journal.close(); // Recovery complete. Tidy up. Node journal files have already been handled. if ( journal.getFilename() != null ) { if ( FileOps.exists(journal.getFilename()) ) FileOps.delete(journal.getFilename()) ; } }
Stats.write(dsg.getLocation().getPath(Names.optStats), sink.getCollector().results()) ;
private static StoreConnection _makeAndCache(DatasetGraphTDB dsg) { Location location = dsg.getLocation() ; StoreConnection sConn = cache.get(location) ; if (sConn == null)