File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -117,8 +117,16 @@ public long getLastEntryInLedger(long ledgerId) throws IOException {
117117 private long getLastEntryInLedgerInternal (long ledgerId ) throws IOException {
118118 LongPairWrapper maxEntryId = LongPairWrapper .get (ledgerId , Long .MAX_VALUE );
119119
120+ long startTimeNanos = MathUtils .nowInNano ();
120121 // Search the last entry in storage
121122 Entry <byte [], byte []> entry = locationsDb .getFloor (maxEntryId .array );
123+ if (entry != null ) {
124+ stats .getGetLastEntryInLedgerStats ()
125+ .registerSuccessfulEvent (MathUtils .elapsedNanos (startTimeNanos ), TimeUnit .NANOSECONDS );
126+ } else {
127+ stats .getGetLastEntryInLedgerStats ()
128+ .registerFailedEvent (MathUtils .elapsedNanos (startTimeNanos ), TimeUnit .NANOSECONDS );
129+ }
122130 maxEntryId .recycle ();
123131
124132 if (entry == null ) {
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ class EntryLocationIndexStats {
4242
4343 private static final String ENTRIES_COUNT = "entries-count" ;
4444 private static final String LOOKUP_ENTRY_LOCATION = "lookup-entry-location" ;
45+ private static final String GET_LAST_ENTRY_IN_LEDGER = "get-last-entry-in-ledger" ;
4546
4647 @ StatsDoc (
4748 name = ENTRIES_COUNT ,
@@ -55,6 +56,12 @@ class EntryLocationIndexStats {
5556 )
5657 private final OpStatsLogger lookupEntryLocationStats ;
5758
59+ @ StatsDoc (
60+ name = GET_LAST_ENTRY_IN_LEDGER ,
61+ help = "operation stats of get last entry in ledger"
62+ )
63+ private final OpStatsLogger getLastEntryInLedgerStats ;
64+
5865 EntryLocationIndexStats (StatsLogger statsLogger ,
5966 Supplier <Long > entriesCountSupplier ) {
6067 entriesCountGauge = new Gauge <Long >() {
@@ -70,6 +77,7 @@ public Long getSample() {
7077 };
7178 statsLogger .registerGauge (ENTRIES_COUNT , entriesCountGauge );
7279 lookupEntryLocationStats = statsLogger .getOpStatsLogger (LOOKUP_ENTRY_LOCATION );
80+ getLastEntryInLedgerStats = statsLogger .getOpStatsLogger (GET_LAST_ENTRY_IN_LEDGER );
7381 }
7482
7583}
You can’t perform that action at this time.
0 commit comments