Skip to content

Commit

Permalink
Optimize getEntryLogMetadata (#3948)
Browse files Browse the repository at this point in the history
###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 69f27b7)
  • Loading branch information
gaozhangmin authored and zymap committed Aug 29, 2023
1 parent e63f647 commit 4052dc0
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,9 @@ public EntryLogMetadata getEntryLogMetadata(long entryLogId, AbstractLogCompacto
// 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());

Expand Down

0 comments on commit 4052dc0

Please sign in to comment.