hangc0276 opened a new pull request #2349:
URL: https://github.com/apache/bookkeeper/pull/2349
### Motivation
When i use `bookkeeper shell readlogmetadata` to get an entrylog file's
metadata info, i encountered the following exception:
```
19:51:11.282 [main] INFO org.apache.bookkeeper.bookie.EntryLogger - Failed
to get ledgers map index from: 0.log : No file for log 0
19:51:11.284 [main] WARN org.apache.bookkeeper.bookie.EntryLogger - Failed
to get channel to scan entry log: 0.log
Exception in thread "main"
com.google.common.util.concurrent.UncheckedExecutionException: No file for log 0
at
org.apache.bookkeeper.tools.cli.commands.bookie.ReadLogMetadataCommand.apply(ReadLogMetadataCommand.java:106)
at
org.apache.bookkeeper.bookie.BookieShell$ReadLogMetadataCmd.runCmd(BookieShell.java:988)
at
org.apache.bookkeeper.bookie.BookieShell$MyCommand.runCmd(BookieShell.java:223)
at org.apache.bookkeeper.bookie.BookieShell.run(BookieShell.java:1976)
at org.apache.bookkeeper.bookie.BookieShell.main(BookieShell.java:2067)
Caused by: java.io.FileNotFoundException: No file for log 0
at
org.apache.bookkeeper.bookie.EntryLogger.findFile(EntryLogger.java:960)
at
org.apache.bookkeeper.bookie.EntryLogger.getChannelForLogId(EntryLogger.java:895)
at
org.apache.bookkeeper.bookie.EntryLogger.scanEntryLog(EntryLogger.java:976)
at
org.apache.bookkeeper.bookie.EntryLogger.extractEntryLogMetadataByScanning(EntryLogger.java:1132)
at
org.apache.bookkeeper.bookie.EntryLogger.getEntryLogMetadata(EntryLogger.java:1041)
at
org.apache.bookkeeper.tools.cli.commands.bookie.ReadLogMetadataCommand.printEntryLogMetadata(ReadLogMetadataCommand.java:132)
at
org.apache.bookkeeper.tools.cli.commands.bookie.ReadLogMetadataCommand.readLogMetadata(ReadLogMetadataCommand.java:125)
at
org.apache.bookkeeper.tools.cli.commands.bookie.ReadLogMetadataCommand.apply(ReadLogMetadataCommand.java:104)
```
In the source code, it parse the entry log id with 10 radix, however, the
entry log file name is 16 radix entry log id and parse failed. Then parsing it
with entry log file name, and set the log file name into flags. When parse the
flags in `ReadLogMetadataCommand` class, it first check
```
private static final long DEFAULT_LOGID = -1L
if (flags.logId != DEFAULT_LOGID) {
logid = flags.logId;
}
```
the default flag.logid is 0, so the `logid` will be set to 0.
### Changes
1. using `16 radix` to parse entry log id
2. when using entry log file name to get entry log metatdata, set the
flags.logid to `-1`
3. export entry log usage to the output
--
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]