@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); }
/** * Gets the ID of the Column Family. * * @return the ID of the Column Family. */ public int getID() { return getID(nativeHandle_); }
/** * Gets the name of the Column Family. * * @return The name of the Column Family. * * @throws RocksDBException if an error occurs whilst retrieving the name. */ public byte[] getName() throws RocksDBException { return getName(nativeHandle_); }
/** * Gets the handle for the default column family * * @return The handle of the default column family */ public ColumnFamilyHandle getDefaultColumnFamily() { final ColumnFamilyHandle cfHandle = new ColumnFamilyHandle(this, getDefaultColumnFamily(nativeHandle_)); cfHandle.disOwnNativeHandle(); return cfHandle; }
columnFamilyHandles.add(new ColumnFamilyHandle(ttlDB, handles[i]));
/** * Drops the column family identified by columnFamilyName. Internal * handles to this column family will be disposed. If the column family * is not known removal will fail. * * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} * instance * * @throws RocksDBException thrown if error happens in underlying * native library. */ public void dropColumnFamily(final ColumnFamilyHandle columnFamilyHandle) throws RocksDBException, IllegalArgumentException { // throws RocksDBException if something goes wrong dropColumnFamily(nativeHandle_, columnFamilyHandle.nativeHandle_); // After the drop the native handle is not valid anymore columnFamilyHandle.disOwnNativeHandle(); }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final ColumnFamilyHandle that = (ColumnFamilyHandle) o; try { return rocksDB_.nativeHandle_ == that.rocksDB_.nativeHandle_ && getID() == that.getID() && Arrays.equals(getName(), that.getName()); } catch (RocksDBException e) { throw new RuntimeException("Cannot compare column family handles", e); } }
private ByteStore newStore(String name) throws RocksDBException { if (inMemory) { return new MapStore(name); } else { final ColumnFamilyDescriptor columnFamilyDescriptor = new ColumnFamilyDescriptor(name.getBytes(UTF_8)); ColumnFamilyHandle handle = db.createColumnFamily(columnFamilyDescriptor); handleIdToNameMap.put(handle.getID(), name); metadataManager.createEntry(name, false); return new RocksDBStore(name, columnFamilyDescriptor, handle, db, stripeCount); } }
cfHandles.put(new ByteArray(handle.getName()), handle);
/** * Creates a new column family with the name columnFamilyName and * allocates a ColumnFamilyHandle within an internal structure. * The ColumnFamilyHandle is automatically disposed with DB disposal. * * @param columnFamilyDescriptor column family to be created. * @return {@link org.rocksdb.ColumnFamilyHandle} instance. * * @throws RocksDBException thrown if error happens in underlying * native library. */ public ColumnFamilyHandle createColumnFamily( final ColumnFamilyDescriptor columnFamilyDescriptor) throws RocksDBException { return new ColumnFamilyHandle(this, createColumnFamily(nativeHandle_, columnFamilyDescriptor.columnFamilyName(), columnFamilyDescriptor.columnFamilyOptions().nativeHandle_)); }
@Override public void close() throws VoldemortException { storeHandle.dispose(); rocksDB.close(); }
String name = new String(family, UTF_8); final ColumnFamilyHandle handle = familyHandles.get(i); handleIdToNameMap.put(handle.getID(), name); RocksDBStore store = new RocksDBStore(name, new ColumnFamilyDescriptor(family), handle, db, stripeCount); maps.put(name, store);
columnFamilyHandles.add(new ColumnFamilyHandle(otdb, handles[i]));
@Override public void cleanup() throws DBException { super.cleanup(); synchronized (RocksDBClient.class) { try { if (references == 1) { for (final ColumnFamily cf : COLUMN_FAMILIES.values()) { cf.getHandle().close(); } rocksDb.close(); rocksDb = null; dbOptions.close(); dbOptions = null; for (final ColumnFamily cf : COLUMN_FAMILIES.values()) { cf.getOptions().close(); } saveColumnFamilyNames(); COLUMN_FAMILIES.clear(); rocksDbDir = null; } } catch (final IOException e) { throw new DBException(e); } finally { references--; } } }
@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); } }
void replaySince(final long transactionNumber, ReplayHandler replayHandler) { try (ReplayHandlerAdapter handler = new ReplayHandlerAdapter(db.getDefaultColumnFamily().getID(), replayHandler, handleIdToNameMap); TransactionLogIterator iterator = db.getUpdatesSince(transactionNumber)) { while (iterator.isValid()) { iterator.status(); final TransactionLogIterator.BatchResult result = iterator.getBatch(); // requires isValid and status check LOGGER.debug("Requested sequence number: {}, iterator sequence number: {}", transactionNumber, result.sequenceNumber()); result.writeBatch() .iterate(handler); if (!iterator.isValid()) { break; } iterator.next(); // requires isValid } for (String updatedStore : handler.getUpdatedStores()) { final long latestTransactionNumber = metadataManager.getLatestTransactionNumber(); metadataManager.setLatestTransactionNumber(updatedStore, latestTransactionNumber, latestTransactionNumber); } } catch (RocksDBException e) { throw new DatastoreException(e); } }
columnFamilyHandles.add(new ColumnFamilyHandle(db, handles[i]));