You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by yo...@apache.org on 2023/08/29 07:00:13 UTC
[bookkeeper] branch branch-4.16 updated: Optimize getEntryLogMetadata (#3948)
This is an automated email from the ASF dual-hosted git repository.
yong pushed a commit to branch branch-4.16
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.16 by this push:
new 4052dc0f8f Optimize getEntryLogMetadata (#3948)
4052dc0f8f is described below
commit 4052dc0f8f482b238f58fecbfb15eb222dbc109f
Author: Zhangao <ga...@qq.com>
AuthorDate: Tue Aug 29 14:59:27 2023 +0800
Optimize getEntryLogMetadata (#3948)
###Motivation
In the `getEntryLogMetadata` method, the `FileNotFoundException` exception is caught before the more general Exception. This modification ensures that if the log file is not found, there is no need to proceed with the `extractEntryLogMetadataByScanning(entryLogId, throttler)` method call.
This enhancement improves the code's error handling by distinguishing between different exceptions that may occur during the retrieval of entry log metadata. It ensures that unnecessary operations, scanning the log, are skipped when the log file is not found.
(cherry picked from commit 69f27b71c6a6ef051b5aba718cca0c209e9e17db)
---
.../src/main/java/org/apache/bookkeeper/bookie/DefaultEntryLogger.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/DefaultEntryLogger.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/DefaultEntryLogger.java
index b6321c6f38..26b62fa9d7 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/DefaultEntryLogger.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/DefaultEntryLogger.java
@@ -1036,6 +1036,9 @@ public class DefaultEntryLogger implements EntryLogger {
// entry log
try {
return extractEntryLogMetadataFromIndex(entryLogId);
+ } catch (FileNotFoundException fne) {
+ LOG.warn("Cannot find entry log file {}.log : {}", Long.toHexString(entryLogId), fne.getMessage());
+ throw fne;
} catch (Exception e) {
LOG.info("Failed to get ledgers map index from: {}.log : {}", entryLogId, e.getMessage());