@Test public void testDispose() throws Exception { YRDB[] dbs = new YRDB[RDBFactory.maxOpenDbs * 2]; RDBFactory rdbf = new RDBFactory("testDispose"); for (int i = 0; i < RDBFactory.maxOpenDbs; i++) { dbs[i] = rdbf.getRdb("/tmp/rdbfactorytest" + i, false); } for (int i = 0; i < RDBFactory.maxOpenDbs / 2; i++) { rdbf.dispose(dbs[i]); } for (int i = 0; i < RDBFactory.maxOpenDbs; i++) { assertTrue(isOpen(dbs[i])); } for (int i = RDBFactory.maxOpenDbs; i < 2 * RDBFactory.maxOpenDbs; i++) { dbs[i] = rdbf.getRdb("/tmp/rdbfactorytest" + i, false); } for (int i = 0; i < RDBFactory.maxOpenDbs / 2; i++) { assertFalse(isOpen(dbs[i])); } for (int i = RDBFactory.maxOpenDbs / 2; i < 2 * RDBFactory.maxOpenDbs; i++) { assertTrue(isOpen(dbs[i])); } for (int i = 0; i < 2 * RDBFactory.maxOpenDbs; i++) { Path d = Paths.get("/tmp/rdbfactorytest" + i); FileUtils.deleteRecursivelyIfExists(d); } }
public synchronized void dispose(YRDB rdb) { rdb.lastAccessTime = System.currentTimeMillis(); rdb.refcount--; }
RDBFactory implements Runnable { public synchronized void dispose(YRDB rdb) { rdb.lastAccessTime = System.currentTimeMillis(); rdb.refcount--; } }
RDBFactory implements Runnable { public synchronized void dispose(YRDB rdb) { rdb.lastAccessTime = System.currentTimeMillis(); rdb.refcount--; } RDBFactory(String dataDir); }
RDBFactory implements Runnable { public synchronized void dispose(YRDB rdb) { rdb.lastAccessTime = System.currentTimeMillis(); rdb.refcount--; } RDBFactory(String dataDir); static synchronized RDBFactory getInstance(String dataDir); YRDB getRdb(String relativePath, boolean readonly); YRDB getRdb(boolean readonly); void delete(String file); @Override synchronized void run(); synchronized void dispose(YRDB rdb); synchronized void closeIfOpen(String relativePath); static void setRegisterShutdownHooks(boolean registerShutdownHooks); YRDB getOpenRdb(); synchronized YRDB getOpenRdb(String relativePath); synchronized List<String> getOpenDbPaths(); synchronized void close(YRDB yrdb); CompletableFuture<Void> doBackup(String backupDir); CompletableFuture<Void> doBackup(String relativePath, String backupDir); CompletableFuture<Void> restoreBackup(String backupDir, String relativePath); CompletableFuture<Void> restoreBackup(int backupId, String backupDir, String relativePath); static void shutdownAll(); }
RDBFactory implements Runnable { public synchronized void dispose(YRDB rdb) { rdb.lastAccessTime = System.currentTimeMillis(); rdb.refcount--; } RDBFactory(String dataDir); static synchronized RDBFactory getInstance(String dataDir); YRDB getRdb(String relativePath, boolean readonly); YRDB getRdb(boolean readonly); void delete(String file); @Override synchronized void run(); synchronized void dispose(YRDB rdb); synchronized void closeIfOpen(String relativePath); static void setRegisterShutdownHooks(boolean registerShutdownHooks); YRDB getOpenRdb(); synchronized YRDB getOpenRdb(String relativePath); synchronized List<String> getOpenDbPaths(); synchronized void close(YRDB yrdb); CompletableFuture<Void> doBackup(String backupDir); CompletableFuture<Void> doBackup(String relativePath, String backupDir); CompletableFuture<Void> restoreBackup(String backupDir, String relativePath); CompletableFuture<Void> restoreBackup(int backupId, String backupDir, String relativePath); static void shutdownAll(); static FlushOptions flushOptions; }