@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--; } } }
/** * Determine whether the given {@link RocksObject} is still valid, i.e., has not been deposed. * * @param obj object to check * @return true if {@code obj} is still valid * @throws IllegalArgumentException if {@code obj} is null */ public static boolean isInitialized(RocksObject obj) { Preconditions.checkArgument(obj != null, "null obj"); return obj.isOwningHandle(); } }
@Override public void close() { for (RocksObject disposable : disposables) { disposable.dispose(); } } }
protected abstract void disposeInternal(final long handle); }
/** * <p>Deletes underlying C++ iterator pointer.</p> * * <p>Note: the underlying handle can only be safely deleted if the parent * instance related to a certain RocksIterator is still valid and initialized. * Therefore {@code disposeInternal()} checks if the parent is initialized * before freeing the native handle.</p> */ @Override protected void disposeInternal() { if (parent_.isOwningHandle()) { disposeInternal(nativeHandle_); } }
private void close(RocksObject obj) { if (obj != null) try { obj.close(); } catch (RuntimeException e) { e.printStackTrace(); } }
private void close(RocksObject obj) { if (obj != null) try { obj.close(); } catch (RuntimeException e) { e.printStackTrace(); } }
/** * Silently close RocksDb objects. * * @param rocksObjList */ public static void closeRocksObjects(RocksObject... rocksObjList) { if (rocksObjList != null) { for (RocksObject obj : rocksObjList) { try { if (obj != null) { obj.close(); } } catch (Exception e) { LOGGER.warn(e.getMessage(), e); } } } }