This is an automated email from the ASF dual-hosted git repository.
lushiji pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new b71446f393 add stats for rocksdb getLastEntryInLedger (#4529)
b71446f393 is described below
commit b71446f393718e0819e1c296dfa48302a019b99b
Author: ken <[email protected]>
AuthorDate: Fri Feb 14 09:54:03 2025 +0800
add stats for rocksdb getLastEntryInLedger (#4529)
Co-authored-by: fanjianye <[email protected]>
---
.../apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java | 8 ++++++++
.../bookkeeper/bookie/storage/ldb/EntryLocationIndexStats.java | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java
index d06822ba6b..87f0af0771 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java
@@ -117,8 +117,16 @@ public class EntryLocationIndex implements Closeable {
private long getLastEntryInLedgerInternal(long ledgerId) throws
IOException {
LongPairWrapper maxEntryId = LongPairWrapper.get(ledgerId,
Long.MAX_VALUE);
+ long startTimeNanos = MathUtils.nowInNano();
// Search the last entry in storage
Entry<byte[], byte[]> entry = locationsDb.getFloor(maxEntryId.array);
+ if (entry != null) {
+ stats.getGetLastEntryInLedgerStats()
+
.registerSuccessfulEvent(MathUtils.elapsedNanos(startTimeNanos),
TimeUnit.NANOSECONDS);
+ } else {
+ stats.getGetLastEntryInLedgerStats()
+
.registerFailedEvent(MathUtils.elapsedNanos(startTimeNanos),
TimeUnit.NANOSECONDS);
+ }
maxEntryId.recycle();
if (entry == null) {
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndexStats.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndexStats.java
index 80bdda4825..f5d015b496 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndexStats.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndexStats.java
@@ -42,6 +42,7 @@ class EntryLocationIndexStats {
private static final String ENTRIES_COUNT = "entries-count";
private static final String LOOKUP_ENTRY_LOCATION =
"lookup-entry-location";
+ private static final String GET_LAST_ENTRY_IN_LEDGER =
"get-last-entry-in-ledger";
@StatsDoc(
name = ENTRIES_COUNT,
@@ -55,6 +56,12 @@ class EntryLocationIndexStats {
)
private final OpStatsLogger lookupEntryLocationStats;
+ @StatsDoc(
+ name = GET_LAST_ENTRY_IN_LEDGER,
+ help = "operation stats of get last entry in ledger"
+ )
+ private final OpStatsLogger getLastEntryInLedgerStats;
+
EntryLocationIndexStats(StatsLogger statsLogger,
Supplier<Long> entriesCountSupplier) {
entriesCountGauge = new Gauge<Long>() {
@@ -70,6 +77,7 @@ class EntryLocationIndexStats {
};
statsLogger.registerGauge(ENTRIES_COUNT, entriesCountGauge);
lookupEntryLocationStats =
statsLogger.getOpStatsLogger(LOOKUP_ENTRY_LOCATION);
+ getLastEntryInLedgerStats =
statsLogger.getOpStatsLogger(GET_LAST_ENTRY_IN_LEDGER);
}
}