/** Set the {@link StoreParams} for specific Location. * This call must only be called before a dataset from Location * is created. This operation should be used with care; bad choices * of {@link StoreParams} can reduce performance. * * <a href="http://jena.apache.org/documentation/tdb/store-parameters.html">See documentation</a>. * * @param location The persistent storage location * @param params StoreParams to use * @throws IllegalStateException If the dataset has already been setup. */ public static void setup(Location location, StoreParams params) { StoreConnection sConn = StoreConnection.getExisting(location) ; if ( sConn != null ) throw new IllegalStateException("Location is already active") ; StoreConnection.make(location, params) ; } }
/** Look at a directory and see if it is a new area */ public static boolean isNewDatabaseArea(Location location) { StoreConnection sConn = StoreConnection.getExisting(location) ; if ( sConn != null ) // Already has a StoreConnection return false ; if ( location.isMem() ) return true ; File d = new File(location.getDirectoryPath()) ; if ( !d.exists() ) return true ; FileFilter ff = fileFilterNewDB ; File[] entries = d.listFiles(ff) ; return entries.length == 0 ; }
/** Test whether a location already has a TDB database or whether a call to TDBFactory * will cause a new, fresh TDB database to be created (pragmatic tests). * The directory may be empty, or not exist. * Existing databases return "true". */ public static boolean inUseLocation(Location location) { if ( location.isMemUnique() ) return false ; if ( location.isMem() ) return StoreConnection.getExisting(location) != null ; String dirname = location.getDirectoryPath() ; File d = new File(dirname) ; if ( ! d.exists() ) // TDB autocreates directories one level. return ! FileOps.exists(d.getParent()) ; return ! TDBInternal.isNewDatabaseArea(location) ; }
public /* for testing */ static void init$() { if ( initialized ) return ; initialized = true ; if ( location == null ) location = Location.create(FusekiWebapp.dirSystemDatabase.toString()) ; if ( ! location.isMem() ) FileOps.ensureDir(location.getDirectoryPath()) ; // Force it into the store connection as a low footprint if ( StoreConnection.getExisting(location) != null ) Fuseki.serverLog.warn("System database already in the StoreConnection cache") ; StoreConnection.make(location, systemDatabaseParams) ; dataset = TDBFactory.createDataset(location) ; dsg = (DatasetGraphTransaction)(dataset.asDatasetGraph()) ; dsg.getContext().set(TDB.symUnionDefaultGraph, false) ; } }
public /* for testing */ static void init$() { if ( initialized ) return ; initialized = true ; if ( location == null ) location = Location.create(FusekiWebapp.dirSystemDatabase.toString()) ; if ( ! location.isMem() ) FileOps.ensureDir(location.getDirectoryPath()) ; // Force it into the store connection as a low footprint if ( StoreConnection.getExisting(location) != null ) Fuseki.serverLog.warn("System database already in the StoreConnection cache") ; StoreConnection.make(location, systemDatabaseParams) ; dataset = TDBFactory.createDataset(location) ; dsg = (DatasetGraphTransaction)(dataset.asDatasetGraph()) ; dsg.getContext().set(TDB.symUnionDefaultGraph, false) ; } }
@Test public void params_reconnect_01() { // Create. StoreConnection.make(loc, null) ; // Drop. StoreConnection.expel(loc, true) ; // Reconnect StoreConnection.make(loc, null) ; StoreParams pLoc = StoreParamsCodec.read(loc) ; assertNull(pLoc) ; StoreParams pDB = StoreConnection.getExisting(loc).getBaseDataset().getConfig().params ; assertNotNull(pDB) ; // Should be the default setup. assertTrue(StoreParams.sameValues(pDft, pDB)) ; }
@Test public void params_reconnect_01() { // Create. StoreConnection.make(loc, null) ; // Drop. StoreConnection.expel(loc, true) ; // Reconnect StoreConnection.make(loc, null) ; StoreParams pLoc = StoreParamsCodec.read(loc) ; assertNull(pLoc) ; StoreParams pDB = StoreConnection.getExisting(loc).getBaseDataset().getConfig().params ; assertNotNull(pDB) ; // Should be the default setup. assertTrue(StoreParams.sameValues(pDft, pDB)) ; }
@Test public void params_reconnect_03() { // Create. StoreConnection.make(loc, pApp) ; // Drop. StoreConnection.expel(loc, true) ; // Reconnect StoreConnection.make(loc, pSpecial) ; //StoreParams pLoc = StoreParamsCodec.read(loc) ; //assertNotNull(pLoc) ; StoreParams pDB = StoreConnection.getExisting(loc).getBaseDataset().getConfig().params ; assertNotNull(pDB) ; // Should be the default setup, modified by pApp for cache sizes. assertFalse(StoreParams.sameValues(pApp, pDB)) ; assertFalse(StoreParams.sameValues(pSpecial, pDB)) ; // Check it's default-modified-by-special. assertEquals(pSpecial.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pApp.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pSpecial.getBlockSize(), pDB.getBlockSize()) ; assertEquals(pApp.getBlockSize(), pDB.getBlockSize()) ; }
@Test public void params_reconnect_02() { // Create. StoreConnection.make(loc, null) ; // Drop. StoreConnection.expel(loc, true) ; // Reconnect StoreConnection.make(loc, pSpecial) ; //StoreParams pLoc = StoreParamsCodec.read(loc) ; //assertNotNull(pLoc) ; StoreParams pDB = StoreConnection.getExisting(loc).getBaseDataset().getConfig().params ; assertNotNull(pDB) ; // Should be the default setup, modified by pApp for cache sizes. assertFalse(StoreParams.sameValues(pDft, pDB)) ; assertFalse(StoreParams.sameValues(pSpecial, pDB)) ; // Check it's default-modified-by-special. assertEquals(pSpecial.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pDft.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pSpecial.getBlockSize(), pDB.getBlockSize()) ; assertEquals(pDft.getBlockSize(), pDB.getBlockSize()) ; }
@Test public void params_reconnect_03() { // Create. StoreConnection.make(loc, pApp) ; // Drop. StoreConnection.expel(loc, true) ; // Reconnect StoreConnection.make(loc, pSpecial) ; //StoreParams pLoc = StoreParamsCodec.read(loc) ; //assertNotNull(pLoc) ; StoreParams pDB = StoreConnection.getExisting(loc).getBaseDataset().getConfig().params ; assertNotNull(pDB) ; // Should be the default setup, modified by pApp for cache sizes. assertFalse(StoreParams.sameValues(pApp, pDB)) ; assertFalse(StoreParams.sameValues(pSpecial, pDB)) ; // Check it's default-modified-by-special. assertEquals(pSpecial.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pApp.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pSpecial.getBlockSize(), pDB.getBlockSize()) ; assertEquals(pApp.getBlockSize(), pDB.getBlockSize()) ; }
@Test public void params_reconnect_02() { // Create. StoreConnection.make(loc, null) ; // Drop. StoreConnection.expel(loc, true) ; // Reconnect StoreConnection.make(loc, pSpecial) ; //StoreParams pLoc = StoreParamsCodec.read(loc) ; //assertNotNull(pLoc) ; StoreParams pDB = StoreConnection.getExisting(loc).getBaseDataset().getConfig().params ; assertNotNull(pDB) ; // Should be the default setup, modified by pApp for cache sizes. assertFalse(StoreParams.sameValues(pDft, pDB)) ; assertFalse(StoreParams.sameValues(pSpecial, pDB)) ; // Check it's default-modified-by-special. assertEquals(pSpecial.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pDft.getBlockReadCacheSize(), pDB.getBlockReadCacheSize()) ; assertNotEquals(pSpecial.getBlockSize(), pDB.getBlockSize()) ; assertEquals(pDft.getBlockSize(), pDB.getBlockSize()) ; }