StevenLuMT commented on code in PR #3444:
URL: https://github.com/apache/bookkeeper/pull/3444#discussion_r942618402
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java:
##########
@@ -73,18 +74,28 @@ public long getLocation(long ledgerId, long entryId) throws
IOException {
LongPairWrapper key = LongPairWrapper.get(ledgerId, entryId);
LongWrapper value = LongWrapper.get();
+ long startTimeNanos = MathUtils.nowInNano();
+ boolean operationSuccess = false;
try {
if (locationsDb.get(key.array, value.array) < 0) {
if (log.isDebugEnabled()) {
log.debug("Entry not found {}@{} in db index", ledgerId,
entryId);
}
return 0;
}
-
+ operationSuccess = true;
return value.getValue();
} finally {
key.recycle();
value.recycle();
+ long eventLatencyMillis = MathUtils.elapsedNanos(startTimeNanos);
Review Comment:
I think no need declare a tmp eventLatency,just write the code like :
```
if (operationSuccess) {
stats.getLookupEntryLocationStats()
.registerSuccessfulEvent(MathUtils.elapsedNanos(startTimeNanos),
TimeUnit.NANOSECONDS);
} else {
stats.getLookupEntryLocationStats()
.registerFailedEvent(MathUtils.elapsedNanos(startTimeNanos),
TimeUnit.NANOSECONDS);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]