This is an automated email from the ASF dual-hosted git repository.
zhaijia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 4274f94 ISSUE #895: print entrylog metadata
4274f94 is described below
commit 4274f945da1c8bb556f51e623273a1584040b7b8
Author: cguttapalem <[email protected]>
AuthorDate: Mon Dec 25 21:16:13 2017 +0800
ISSUE #895: print entrylog metadata
Descriptions of the changes in this PR:
- bookieshell command to print entrylog metadata
Master Issue: #895
Author: cguttapalem <[email protected]>
Reviewers: Jia Zhai <None>, Sijie Guo <[email protected]>
This closes #896 from reddycharan/printentrylogmetadata, closes #895
---
.../org/apache/bookkeeper/bookie/BookieShell.java | 70 ++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
index d7728d6..bfc24fc 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
@@ -53,6 +53,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
@@ -140,6 +141,7 @@ public class BookieShell implements Tool {
static final String CMD_SIMPLETEST = "simpletest";
static final String CMD_BOOKIESANITYTEST = "bookiesanity";
static final String CMD_READLOG = "readlog";
+ static final String CMD_READLOGMETADATA = "readlogmetadata";
static final String CMD_READJOURNAL = "readjournal";
static final String CMD_LASTMARK = "lastmark";
static final String CMD_AUTORECOVERY = "autorecovery";
@@ -1121,6 +1123,63 @@ public class BookieShell implements Tool {
}
/**
+ * Command to print metadata of entrylog.
+ */
+ class ReadLogMetadataCmd extends MyCommand {
+ Options rlOpts = new Options();
+
+ ReadLogMetadataCmd() {
+ super(CMD_READLOGMETADATA);
+ }
+
+ @Override
+ public int runCmd(CommandLine cmdLine) throws Exception {
+ String[] leftArgs = cmdLine.getArgs();
+ if (leftArgs.length <= 0) {
+ LOG.error("ERROR: missing entry log id or entry log file
name");
+ printUsage();
+ return -1;
+ }
+
+ long logId;
+ try {
+ logId = Long.parseLong(leftArgs[0]);
+ } catch (NumberFormatException nfe) {
+ // not a entry log id
+ File f = new File(leftArgs[0]);
+ String name = f.getName();
+ if (!name.endsWith(".log")) {
+ // not a log file
+ LOG.error("ERROR: invalid entry log file name " +
leftArgs[0]);
+ printUsage();
+ return -1;
+ }
+ String idString = name.split("\\.")[0];
+ logId = Long.parseLong(idString, 16);
+ }
+
+ printEntryLogMetadata(logId);
+
+ return 0;
+ }
+
+ @Override
+ String getDescription() {
+ return "Prints entrylog's metadata";
+ }
+
+ @Override
+ String getUsage() {
+ return "readlogmetadata <entry_log_id | entry_log_file_name>";
+ }
+
+ @Override
+ Options getOptions() {
+ return rlOpts;
+ }
+ }
+
+ /**
* Command to read journal files.
*/
class ReadJournalCmd extends MyCommand {
@@ -2466,6 +2525,7 @@ public class BookieShell implements Tool {
commands.put(CMD_SIMPLETEST, new SimpleTestCmd());
commands.put(CMD_BOOKIESANITYTEST, new BookieSanityTestCmd());
commands.put(CMD_READLOG, new ReadLogCmd());
+ commands.put(CMD_READLOGMETADATA, new ReadLogMetadataCmd());
commands.put(CMD_READJOURNAL, new ReadJournalCmd());
commands.put(CMD_LASTMARK, new LastMarkCmd());
commands.put(CMD_AUTORECOVERY, new AutoRecoveryCmd());
@@ -2804,6 +2864,16 @@ public class BookieShell implements Tool {
}
}
+ protected void printEntryLogMetadata(long logId) throws IOException {
+ LOG.info("Print entryLogMetadata of entrylog {} ({}.log)", logId,
Long.toHexString(logId));
+ initEntryLogger();
+ EntryLogMetadata entryLogMetadata =
entryLogger.getEntryLogMetadata(logId);
+ entryLogMetadata.getLedgersMap().forEach((ledgerId, size) -> {
+ LOG.info("--------- Lid={}, TotalSizeOfEntriesOfLedger={}
---------",
+ ledgerIdFormatter.formatLedgerId(ledgerId), size);
+ });
+ }
+
/**
* Get an iterable over pages of entries and locations for a ledger.
*
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].