/** Stop managing a location. There should be no transactions running. */ public static synchronized void release(Location location) { expel(location, false); }
/** Stop managing all locations. Use with great care. */ public static synchronized void reset() { // Copy to avoid potential CME. Set<Location> x = new HashSet<>(cache.keySet()) ; for (Location loc : x) expel(loc, true) ; cache.clear() ; }
/** 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. }
@After public void expelDatabase() { StoreConnection.expel(loc, true) ; }
@After public void expelDatabase() { StoreConnection.expel(loc, true) ; }
/** * Clean up test resources */ @After public void cleanupTest() { StoreConnection.expel(Location.mem(), true); }
/** * Cleans up resources used by tests */ @After public void cleanupTest() { StoreConnection.expel(Location.mem(), true); }
@Before public void clearupTest() { // Flush and clean. StoreConnection.expel(loc, true) ; FileOps.clearAll(DB_DIR); }
@Before public void clearupTest() { // Flush and clean. StoreConnection.expel(loc, true) ; FileOps.clearAll(DB_DIR); }
/** * Cleans up resources used to avoid process memory leaks */ @After public void cleanupTest() { StoreConnection.expel(Location.create(tempDir.getRoot().getAbsolutePath()), true); }
/** * Cleans up after the tests by ensuring that the TDB dataset is closed */ @After public void cleanupTest() { if (currDataset != null) { currDataset.close(); } StoreConnection.expel(Location.mem(), true); }
@Test public void testTDBFresh02() { boolean b = TDBFactory.inUseLocation(DIR) ; assertFalse("Expect false before any creation attempted", b) ; TDBFactory.createDataset(DIR) ; b = TDBFactory.inUseLocation(DIR) ; assertTrue("Expected true after creation attempted", b) ; StoreConnection.expel(Location.create(DIR), true); }
@Test public void testTDBFresh02() { boolean b = TDBFactory.inUseLocation(DIR) ; assertFalse("Expect false before any creation attempted", b) ; TDBFactory.createDataset(DIR) ; b = TDBFactory.inUseLocation(DIR) ; assertTrue("Expected true after creation attempted", b) ; StoreConnection.expel(Location.create(DIR), true); }
@Test public void testTDBFresh03() { boolean b = TDBFactory.inUseLocation(DIR) ; assertFalse("Expect true before any creation attempted", b) ; TDBFactory.createDataset(DIR) ; b = TDBFactory.inUseLocation(DIR) ; assertTrue("Expected true after creation attempted", b) ; StoreConnection.expel(Location.create(DIR), true); b = TDBFactory.inUseLocation(DIR) ; assertTrue("Expected true even after StoreConenction reset", b) ; }
@Test public void testTDBFresh03() { boolean b = TDBFactory.inUseLocation(DIR) ; assertFalse("Expect true before any creation attempted", b) ; TDBFactory.createDataset(DIR) ; b = TDBFactory.inUseLocation(DIR) ; assertTrue("Expected true after creation attempted", b) ; StoreConnection.expel(Location.create(DIR), true); b = TDBFactory.inUseLocation(DIR) ; assertTrue("Expected true even after StoreConenction reset", b) ; }
@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()) ; }