private void setupPlain() { // Make without transactions. DatasetGraphTDB dsg = createPlain(location) ; dsg.add(quad1) ; dsg.close() ; return ; }
private void setupPlain() { // Make without transactions. DatasetGraphTDB dsg = createPlain(location) ; dsg.add(quad1) ; dsg.close() ; return ; }
@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 ; } }
/** 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"); } } }
private static void testGraph(String assemblerFile, boolean named) { Object thing = null ; try { thing = AssemblerUtils.build( assemblerFile, VocabTDB.tGraphTDB) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); } }
private static void testGraph(String assemblerFile, boolean named) { Object thing = null ; try { thing = AssemblerUtils.build( assemblerFile, VocabTDB.tGraphTDB) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); } }
@Test public void createGraphEmbed() { String f = dirAssem+"/tdb-graph-embed.ttl" ; Object thing = null ; try { thing = AssemblerUtils.build( f, JA.Model) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); }
@Test public void createGraphEmbed() { String f = dirAssem+"/tdb-graph-embed.ttl" ; Object thing = null ; try { thing = AssemblerUtils.build( f, JA.Model) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); }
public static void main(String[] args) { FileManager fm = FileManager.get(); fm.addLocatorClassLoader(ExampleTDB_04.class.getClassLoader()); InputStream in = fm.open("data/data.nt"); DatasetGraphTDB dsg = TDBInternal.getBaseDatasetGraphTDB(TDBFactory.createDatasetGraph()); GraphListener listener = new MyListener(); dsg.getDefaultGraph().getEventManager().register(listener); Iterator<Node> iter = dsg.listGraphNodes(); while ( iter.hasNext() ) { Graph graph = dsg.getGraph(iter.next()); graph.getEventManager().register(listener); } // this does not send events to the GraphListener TDBLoader.load(dsg, in, false); // this does not uses the Graph SPI dsg.add(new Quad(Quad.defaultGraphIRI, NodeFactory.createURI("x"), NodeFactory.createURI("y"), NodeFactory.createURI("z"))); // this does Graph graph = dsg.getDefaultGraph(); graph.add(new Triple(NodeFactory.createURI("x"), NodeFactory.createURI("y"), NodeFactory.createURI("z"))); // this sends events to the GraphListener Model model = ModelFactory.createModelForGraph(dsg.getDefaultGraph()) ; model.add(ResourceFactory.createProperty("foo:x1"), RDFS.label, "X1"); // this does it too in = fm.open("data/data.nt"); model.read(in, "", "N-TRIPLES"); dsg.close(); }
@Test public void testPlain() { assertEquals (3, countRDFNodes()) ; DatasetGraphTDB dsg = createPlain(location) ; assertTrue(dsg.contains(quad1)) ; dsg.add(quad2) ; assertTrue(dsg.contains(quad2)) ; dsg.close() ; StoreConnection.release(location) ; assertEquals (4, countRDFNodes()) ; }
@Test public void testPlain() { assertEquals (3, countRDFNodes()) ; DatasetGraphTDB dsg = createPlain(location) ; assertTrue(dsg.contains(quad1)) ; dsg.add(quad2) ; assertTrue(dsg.contains(quad2)) ; dsg.close() ; StoreConnection.release(location) ; assertEquals (4, countRDFNodes()) ; }