/** * Updates the value of metricView if the reference is still valid. */ private void setProperty(ColumnFamilyHandle handle, String property, RocksDBNativeMetricView metricView) { if (metricView.isClosed()) { return; } try { synchronized (lock) { if (rocksDB != null) { long value = rocksDB.getLongProperty(handle, property); metricView.setValue(value); } } } catch (RocksDBException e) { metricView.close(); LOG.warn("Failed to read native metric %s from RocksDB", property, e); } }
public long setUp() throws Exception { long sz = 0; // System.out.println("s="+i); sz += dbs.getLongProperty("rocksdb.estimate-num-keys"); long size = sz; this.closed = false; return size; }
/** * initializes the Object set of this hash table. * * @param initialCapacity * an <code>int</code> value * @return an <code>int</code> value * @throws HashtableFullException * @throws FileNotFoundException */ public long setUp() throws Exception { long sz = 0; for (RocksDB db : dbs) { // System.out.println("s="+i); sz += db.getLongProperty("rocksdb.estimate-num-keys"); } long size = sz; this.closed = false; return size; }
/** * initializes the Object set of this hash table. * * @param initialCapacity * an <code>int</code> value * @return an <code>int</code> value * @throws HashtableFullException * @throws FileNotFoundException */ public long setUp() throws Exception { long sz = 0; for (RocksDB db : dbs) { // System.out.println("s="+i); sz += db.getLongProperty("rocksdb.estimate-num-keys"); } long size = sz; this.closed = false; return size; }
@Override public long count() throws IOException { try { return db.getLongProperty("rocksdb.estimate-num-keys"); } catch (RocksDBException e) { throw new IOException("Error in getting records count", e); } }
private void append(StringBuilder sb, String propName, String propDisplayName) throws RocksDBException { sb.append("* "); sb.append(propDisplayName); sb.append(": "); sb.append(db.getLongProperty(handle, propName)); sb.append("\n"); }
/** * <p> Similar to GetProperty(), but only works for a subset of properties * whose return value is a numerical value. Return the value as long.</p> * * <p><strong>Note</strong>: As the returned property is of type * {@code uint64_t} on C++ side the returning value can be negative * because Java supports in Java 7 only signed long values.</p> * * <p><strong>Java 7</strong>: To mitigate the problem of the non * existent unsigned long tpye, values should be encapsulated using * {@link java.math.BigInteger} to reflect the correct value. The correct * behavior is guaranteed if {@code 2^64} is added to negative values.</p> * * <p><strong>Java 8</strong>: In Java 8 the value should be treated as * unsigned long using provided methods of type {@link Long}.</p> * * @param property to be fetched. * * @return numerical property value. * * @throws RocksDBException if an error happens in the underlying native code. */ public long getLongProperty(final String property) throws RocksDBException { return getLongProperty(nativeHandle_, property, property.length()); }
/** * <p> Similar to GetProperty(), but only works for a subset of properties * whose return value is a numerical value. Return the value as long.</p> * * <p><strong>Note</strong>: As the returned property is of type * {@code uint64_t} on C++ side the returning value can be negative * because Java supports in Java 7 only signed long values.</p> * * <p><strong>Java 7</strong>: To mitigate the problem of the non * existent unsigned long tpye, values should be encapsulated using * {@link java.math.BigInteger} to reflect the correct value. The correct * behavior is guaranteed if {@code 2^64} is added to negative values.</p> * * <p><strong>Java 8</strong>: In Java 8 the value should be treated as * unsigned long using provided methods of type {@link Long}.</p> * * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} * instance * @param property to be fetched. * * @return numerical property value * * @throws RocksDBException if an error happens in the underlying native code. */ public long getLongProperty(final ColumnFamilyHandle columnFamilyHandle, final String property) throws RocksDBException { return getLongProperty(nativeHandle_, columnFamilyHandle.nativeHandle_, property, property.length()); }
public long getSize() { try { long sz = 0; sz = dbs.getLongProperty("rocksdb.estimate-num-keys"); return sz; } catch (RocksDBException e) { SDFSLogger.getLog().error("unable to get lenght for rocksdb", e); return 0; } }
@Override public long getSize() { try { long sz = 0; for (RocksDB db : dbs) { sz += db.getLongProperty("rocksdb.estimate-num-keys"); } return sz; } catch (RocksDBException e) { SDFSLogger.getLog().error("unable to get lenght for rocksdb", e); return 0; } }
@Override public long getUsedSize() { try { long sz = 0; for (RocksDB db : dbs) { sz += db.getLongProperty("rocksdb.estimate-num-keys"); } return sz * Main.CHUNK_LENGTH; } catch (RocksDBException e) { SDFSLogger.getLog().error("unable to get lenght for rocksdb", e); return 0; } }
@Override public long getUsedSize() { try { long sz = 0; for (RocksDB db : dbs) { sz += db.getLongProperty("rocksdb.estimate-num-keys"); } return sz * Main.CHUNK_LENGTH; } catch (RocksDBException e) { SDFSLogger.getLog().error("unable to get lenght for rocksdb", e); return 0; } }
@Override public long getSize() { try { long sz = 0; for (RocksDB db : dbs) { sz += db.getLongProperty("rocksdb.estimate-num-keys"); } return sz; } catch (RocksDBException e) { SDFSLogger.getLog().error("unable to get lenght for rocksdb", e); return 0; } }
/** * Updates the value of metricView if the reference is still valid. */ private void setProperty(ColumnFamilyHandle handle, String property, RocksDBNativeMetricView metricView) { if (metricView.isClosed()) { return; } try { synchronized (lock) { if (rocksDB != null) { long value = rocksDB.getLongProperty(handle, property); metricView.setValue(value); } } } catch (RocksDBException e) { metricView.close(); LOG.warn("Failed to read native metric %s from RocksDB", property, e); } }
/** * Updates the value of metricView if the reference is still valid. */ private void setProperty(ColumnFamilyHandle handle, String property, RocksDBNativeMetricView metricView) { if (metricView.isClosed()) { return; } try { synchronized (lock) { if (rocksDB != null) { long value = rocksDB.getLongProperty(handle, property); metricView.setValue(value); } } } catch (RocksDBException e) { metricView.close(); LOG.warn("Failed to read native metric %s from RocksDB", property, e); } }
private void registerMetrics() { final MetricSetBuilder builder = new MetricSetBuilder(MetricRegistry.name(METRICS_PREFIX, name)); for (String property : METRIC_PROPERTIES) { builder.gauge(property, () -> { try { return db.getLongProperty(handle, property); } catch (RocksDBException e) { // throwing an exception would cause Dropwizard's metrics reporter to not report the remaining metrics logger.warn("failed to retrieve property '{}", property, e); return null; } }); } Metrics.getInstance().registerAll(builder.build()); }
/** * Return an approximate count of key-value mappings in this store. * * <code>RocksDB</code> cannot return an exact entry count without doing a * full scan, so this method relies on the <code>rocksdb.estimate-num-keys</code> * property to get an approximate count. The returned size also includes * a count of dirty keys in the store's in-memory cache, which may lead to some * double-counting of entries and inflate the estimate. * * @return an approximate count of key-value mappings in the store. */ @Override public long approximateNumEntries() { validateStoreOpen(); final long value; try { value = db.getLongProperty("rocksdb.estimate-num-keys"); } catch (final RocksDBException e) { throw new ProcessorStateException("Error fetching property from store " + name, e); } if (isOverflowing(value)) { return Long.MAX_VALUE; } return value; }