Skip to content

Commit

Permalink
add new API to access CF metric value
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourav Maji committed Jan 31, 2025
1 parent 301fe82 commit c153a83
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,13 @@ public RocksDBMemoryStats(MetricsRepository metricsRepository, String name, bool
// Lock down the list of RocksDB interfaces while the collection is ongoing
synchronized (hostedRocksDBPartitions) {
for (RocksDBStoragePartition dbPartition: hostedRocksDBPartitions.values()) {
if (!(dbPartition instanceof ReplicationMetadataRocksDBStoragePartition)) {
continue;
}
try {
total += dbPartition.getRocksDBStatValue(metric);
} catch (VeniceException e) {
LOGGER.warn("Could not get rocksDB metric {} with error:", metric, e);
continue;
if (dbPartition instanceof ReplicationMetadataRocksDBStoragePartition) {
try {
total += dbPartition.getRocksDBCFStatValue(metric);
} catch (VeniceException e) {
LOGGER.warn("Could not get rocksDB CF metric {} with error:", metric, e);
continue;
}
}
if (INSTANCE_METRIC_DOMAINS.contains(metric)) {
// Collect this metric once from any available partition and move on
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.linkedin.davinci.store.rocksdb;

import static com.linkedin.davinci.store.AbstractStorageEngine.METADATA_PARTITION_ID;
import static com.linkedin.davinci.store.rocksdb.RocksDBSstFileWriter.REPLICATION_METADATA_COLUMN_FAMILY_INDEX;

import com.linkedin.davinci.blobtransfer.BlobSnapshotManager;
import com.linkedin.davinci.callback.BytesStreamingCallback;
Expand Down Expand Up @@ -924,10 +925,22 @@ private void deRegisterDBStats() {
}

public long getRocksDBStatValue(String statName) {
return getRocksDBStatValue(statName, 0);
}

public long getRocksDBCFStatValue(String statName) {
return getRocksDBStatValue(statName, REPLICATION_METADATA_COLUMN_FAMILY_INDEX);
}

private long getRocksDBStatValue(String statName, int cfIndex) {
readCloseRWLock.readLock().lock();
try {
makeSureRocksDBIsStillOpen();
return rocksDB.getLongProperty(statName);
if (cfIndex == REPLICATION_METADATA_COLUMN_FAMILY_INDEX) {
return rocksDB.getLongProperty(columnFamilyHandleList.get(REPLICATION_METADATA_COLUMN_FAMILY_INDEX), statName);
} else {
return rocksDB.getLongProperty(statName);
}
} catch (RocksDBException e) {
throw new VeniceException(
"Failed to get property value from RocksDB: " + replicaId + " for property: " + statName,
Expand Down

0 comments on commit c153a83

Please sign in to comment.