@Override public void cleanup() { LOG.info("Begin to close rocketDb of {}", rootDir); for (ColumnFamilyHandle columnFamilyHandle : windowHandlers.values()) { columnFamilyHandle.dispose(); } if (ttlDB != null) { ttlDB.close(); } LOG.info("Successfully closed rocketDb of {}", rootDir); }
@Override public void close() throws VoldemortException { storeHandle.dispose(); rocksDB.close(); }
@Override public void truncate() { try { rocksDB.dropColumnFamily(storeHandle); storeHandle.dispose(); storeHandle = rocksDB.createColumnFamily(new ColumnFamilyDescriptor(getName().getBytes(), storeOptions)); } catch (RocksDBException e) { throw new VoldemortException("Failed to truncate DB", e); } }
handles.get(0).dispose(); ColumnFamilyHandle storeHandle = handles.get(1);
public synchronized void drop(String tableName) throws RocksDBException { ColumnFamily cf = cfs.remove(tableName); if (cf != null) { db.dropColumnFamily(cf.handle); cf.handle.dispose(); } }
@Override public void cleanup() { LOG.info("Begin to close rocketDb of {}", rootDir); for (ColumnFamilyHandle columnFamilyHandle : windowHandlers.values()) { columnFamilyHandle.dispose(); } if (ttlDB != null) { ttlDB.close(); } LOG.info("Successfully closed rocketDb of {}", rootDir); }
public synchronized void truncate(String tableName) throws InterruptedException, RocksDBException { ColumnFamily oldCf = cfs.get(tableName); if (oldCf == null) { throw new IllegalArgumentException("Table " + tableName + " does not exist."); } long newIndex = (oldCf.index + 1) % 2; String realTableName = String.format("%s__%d", tableName, newIndex); ColumnFamilyDescriptor descriptor = cfFactory.apply(realTableName); ColumnFamilyHandle handle = db.createColumnFamily(descriptor); cfs.put(tableName, new ColumnFamily(newIndex, handle)); while (oldCf.refCount.get() > 0) { Thread.sleep(10); } db.dropColumnFamily(oldCf.handle); oldCf.handle.dispose(); } }
public void initialize(List<ColumnFamilyDescriptor> cfDescriptors, List<ColumnFamilyHandle> cfHandles) throws RocksDBException { for (int i = 0; i < cfDescriptors.size(); i++) { String fullTableName = new String(cfDescriptors.get(i).columnFamilyName(), Charsets.UTF_8); int nameIndex = fullTableName.lastIndexOf("__"); String tableName; long index; if (nameIndex == -1) { tableName = fullTableName; index = 0; } else { tableName = fullTableName.substring(0, nameIndex); index = Long.parseLong(fullTableName.substring(nameIndex + 2)); } ColumnFamily cf = new ColumnFamily(index, cfHandles.get(i)); ColumnFamily oldCf = cfs.put(tableName, cf); if (oldCf != null && !tableName.equals("default")) { db.dropColumnFamily(oldCf.getHandle()); oldCf.getHandle().dispose(); } } }