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 c24be832822..6f66766d408 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 @@ -295,7 +295,14 @@ String getDescription() { @Override String getUsage() { - return "metaformat [-nonInteractive] [-force]"; + return "metaformat Format bookkeeper metadata in zookeeper\n" + + " Usage: metaformat [options]\n" + + " Options:\n" + + " -f, --force\n" + + " If [nonInteractive] is specified, " + + "then whether to force delete the old data without prompt\n" + + " -n, --nonInteractive\n" + + " Whether to confirm if old data exists "; } @Override @@ -340,7 +347,10 @@ String getDescription() { @Override String getUsage() { - return "initnewcluster"; + return "initnewcluster Initializes a new bookkeeper cluster. If initnewcluster fails then try nuking " + + "existing cluster by running nukeexistingcluster before running initnewcluster again, " + + "initbookie requires no options,use the default conf or re-specify BOOKIE_CONF \n" + + " Usage: initnewcluster"; } @Override @@ -378,7 +388,16 @@ String getDescription() { @Override String getUsage() { - return "nukeexistingcluster -zkledgersrootpath [-instanceid | -force]"; + return "nukeexistingcluster Nuke bookkeeper cluster by deleting metadata\n" + + " Usage: nukeexistingcluster [options]\n" + + " Options:\n" + + " -f, --force\n" + + " If instanceid is not specified, " + + "then whether to force nuke the metadata without validating instanceid\n" + + " * -i, --instanceid\n" + + " the bookie cluster's instanceid (param format: `instanceId`)\n" + + " * -p,--zkledgersrootpath\n" + + " zookeeper ledgers rootpath (param format: `zkLedgersRootPath`)"; } @Override @@ -423,7 +442,16 @@ String getDescription() { @Override String getUsage() { - return "bookieformat [-nonInteractive] [-force] [-deleteCookie]"; + return "bookieformat Format the current server contents\n" + + " Usage: bookieformat [options]\n" + + " Options:\n" + + " -f, --force\n" + + " If [nonInteractive] is specified, then whether " + + "to force delete the old data without prompt..? \n" + + " * -n, --nonInteractive\n" + + " Whether to confirm if old data exists..? \n" + + " * -d, --deleteCookie\n" + + " Delete its cookie on metadata store "; } @Override @@ -464,7 +492,9 @@ String getDescription() { @Override String getUsage() { - return CMD_INITBOOKIE; + return "initbookie Initialize new Bookie, initbookie requires no options," + + "use the default conf or re-specify BOOKIE_CONF \n" + + " Usage: initbookie"; } @Override @@ -505,7 +535,25 @@ String getDescription() { @Override String getUsage() { - return "recover [-deleteCookie] "; + return "recover Recover the ledger data for failed bookie\n" + + " Usage: recover [options]\n" + + " Options:\n" + + " -q, --query\n" + + " Query the ledgers that contain given bookies\n" + + " -dr, --dryrun\n" + + " Printing the recovery plan w/o doing actual recovery\n" + + " -f, --force\n" + + " Force recovery without confirmation\n" + + " -l, --ledger\n" + + " Recover a specific ledger (param format: `ledgerId`)\n" + + " -sk, --skipOpenLedgers\n" + + " Skip recovering open ledgers\n" + + " -d, --deleteCookie\n" + + " Delete cookie node for the bookie\n" + + " -sku, --skipUnrecoverableLedgers\n" + + " Skip unrecoverable ledgers\n" + + " -rate, --replicationRate\n" + + " Replication rate by bytes"; } @Override @@ -574,7 +622,13 @@ String getDescription() { @Override String getUsage() { - return "ledger [-m] "; + return "ledger Dump ledger index entries into readable format\n" + + " Usage: ledger [options]\n" + + " Options:\n" + + " -m, --meta\n" + + " Print meta information\n" + + " * \n" + + " Ledger ID(param format: `ledgerId`) "; } @Override @@ -611,9 +665,21 @@ String getDescription() { @Override String getUsage() { - return "readledger [-bookie ] [-msg] -ledgerid " - + "[-firstentryid [-lastentryid ]] " - + "[-force-recovery]"; + return "readledger Read a range of entries from a ledger\n" + + " Usage: readledger [options]\n" + + " Options:\n" + + " -m, --msg\n" + + " Print message body\n" + + " * -l, --ledgerid\n" + + " Ledger ID (param format: `ledgerId`)\n" + + " * -fe, --firstentryid\n" + + " First EntryID (param format: `firstEntryId`)\n" + + " * -le, --lastentryid\n" + + " Last EntryID (param format: `lastEntryId`)\n" + + " -r, --force-recovery\n" + + " Ensure the ledger is properly closed before reading\n" + + " * -b, --bookie\n" + + " Only read from a specific bookie (param format: `address:port`)"; } @Override @@ -677,8 +743,20 @@ String getDescription() { @Override String getUsage() { - return "listunderreplicated [[-missingreplica ]" - + " [-excludingmissingreplica ]] [-printmissingreplica] [-printreplicationworkerid]"; + return "listunderreplicated List ledgers marked as underreplicated, with optional options to " + + "specify missingreplica (BookieId) and to exclude missingreplica\n" + + " Usage: listunderreplicated [options]\n" + + " Options:\n" + + " -c,--onlydisplayledgercount\n" + + " Only display underreplicated ledger count \n" + + " * -emr,--excludingmissingreplica\n" + + " Bookie Id of missing replica to ignore (param format: `address:port`)\n" + + " * -mr,--missingreplica\n" + + " Bookie Id of missing replica (param format: `address:port`)\n" + + " -pmr,--printmissingreplica\n" + + " Whether to print missingreplicas list \n" + + " -prw,--printreplicationworkerid\n" + + " Whether to print replicationworkerid "; } @Override @@ -735,7 +813,13 @@ String getDescription() { @Override String getUsage() { - return "listledgers [-meta] [-bookieid ]"; + return "listledgers List all ledgers on the cluster (this may take a long time)\n" + + " Usage: listledgers [options]\n" + + " Options:\n" + + " -m, --meta\n" + + " Print metadata\n" + + " * -bookieid\n" + + " List ledgers residing in this bookie(param format: `address:port`) "; } @Override @@ -781,7 +865,13 @@ String getDescription() { @Override String getUsage() { - return "activeledgers [-logId ] [-timeout ] [-formatter ]"; + return "activeledgers List all active ledgers on the entry log file\n" + + " Usage: activeledgers [options]\n" + + " Options:\n" + + " * -l, --logId\n" + + " Entry log file id (`ledgers/logFileName.log`,param format: `logFileName`)\n" + + " * -t, --timeout\n" + + " Read timeout(ms, param format: `runTimeoutMs`) "; } @Override @@ -844,7 +934,17 @@ String getDescription() { @Override String getUsage() { - return "ledgermetadata -ledgerid [--dumptofile FILENAME|--restorefromfile FILENAME]"; + return "ledgermetadata Print the metadata for a ledger, or optionally dump to a file\n" + + " Usage: ledgermetadata [options]\n" + + " Options:\n" + + " -dumptofile \n" + + " Dump metadata for ledger, to a file (param format: `dumpFilePath`)\n" + + " -restorefromfile \n" + + " Restore metadata for ledger, from a file (param format: `storeFilePath`)\n" + + " -update \n" + + " Update metadata if ledger already exist \n" + + " * -l, --ledgerid\n" + + " Ledger ID(param format: `ledgerId`) "; } @Override @@ -876,7 +976,9 @@ String getDescription() { @Override String getUsage() { - return "localconsistencycheck"; + return "localconsistencycheck Validate Ledger Storage internal metadata, " + + "localconsistencycheck requires no options,use the default conf or re-specify BOOKIE_CONF \n" + + " Usage: localconsistencycheck"; } @Override @@ -924,7 +1026,17 @@ String getDescription() { @Override String getUsage() { - return "simpletest [-ensemble N] [-writeQuorum N] [-ackQuorum N] [-numEntries N]"; + return "simpletest Simple test to create a ledger and write entries to it\n" + + " Usage: simpletest [options]\n" + + " Options:\n" + + " -e, --ensemble\n" + + " Ensemble size (default 3, param format: `ensembleSize`)\n" + + " -w, --writeQuorum\n" + + " Write quorum size (default 2, param format: `writeQuorumSize`)\n" + + " -a, --ackQuorum\n" + + " Ack quorum size (default 2, param format: `ackQuorumSize`)\n" + + " -n, --numEntries\n" + + " Entries to write (default 1000, param format: `entriesToWrite`)"; } @Override @@ -956,7 +1068,14 @@ String getDescription() { @Override String getUsage() { - return "bookiesanity [-entries N] [-timeout N]"; + return "bookiesanity Sanity test for local bookie. " + + "Create ledger and write/reads entries on local bookie\n" + + " Usage: bookiesanity [options]\n" + + " Options:\n" + + " -e, --entries\n" + + " Total entries to be added for the test (default 10, param format: `entryNum`)\n" + + " -t, --timeout\n" + + " Timeout for write/read in seconds (default 1s, param format: `readTimeoutMs`) "; } @Override @@ -1025,8 +1144,19 @@ String getDescription() { @Override String getUsage() { - return "readlog [-msg] [-ledgerid " - + "[-entryid ]] [-startpos [-endpos ]]"; + return "readlog Scan an entry file and format the entries into readable format\n" + + " Usage: readlog [options]\n" + + " Options:\n" + + " -m, --msg\n" + + " Print message body\n" + + " * -l, --ledgerid\n" + + " Ledger ID (param format: `ledgerId`)\n" + + " * -e, --entryid\n" + + " Entry ID (param format: `entryId`)\n" + + " * -sp, --startpos\n" + + " Start Position (param format: `startPosition`)\n" + + " * -ep, --endpos\n" + + " End Position (param format: `endPosition`)"; } @Override @@ -1074,7 +1204,12 @@ String getDescription() { @Override String getUsage() { - return "readlogmetadata "; + return "readlogmetadata Prints entrylog's metadata\n" + + " Usage: readlogmetadata [options]\n" + + " Options:\n" + + " * \n" + + " entry log id or entry log file name (param format: `entryLogId` " + + "or `entryLogFileName`)"; } @Override @@ -1131,7 +1266,14 @@ String getDescription() { @Override String getUsage() { - return "readjournal [-dir] [-msg] "; + return "readjournal Scan a journal file and format the entries into readable format\n" + + " Usage: readjournal [options]\n" + + " Options:\n" + + " * -dir\n" + + " Journal directory needed if more than one journal configured" + + " (param format: `journalDir`)\n" + + " -m, --msg\n" + + " Print message body"; } @Override @@ -1162,7 +1304,8 @@ String getDescription() { @Override String getUsage() { - return "lastmark"; + return "lastmark Print last log marker \n" + + " Usage: lastmark"; } @Override @@ -1226,7 +1369,17 @@ String getDescription() { @Override String getUsage() { - return "listbookies [-readwrite|-readonly|-all] [-hostnames]"; + return "listbookies List the bookies, which are running as either readwrite or readonly mode\n" + + " Usage: listbookies [options]\n" + + " Options:\n" + + " -a, --all\n" + + " Print all bookies\n" + + " -h, --hostnames\n" + + " Also print hostname of the bookie\n" + + " -ro, --readonly\n" + + " Print readonly bookies\n" + + " -rw, --readwrite\n" + + " Print readwrite bookies "; } @Override @@ -1265,7 +1418,15 @@ String getDescription() { @Override String getUsage() { - return "listfilesondisc [-journal|-entrylog|-index]"; + return "listfilesondisc List the files in JournalDirectory/LedgerDirectories/IndexDirectories \n" + + " Usage: listfilesondisc [options]\n" + + " Options:\n" + + " -txn, --journal\n" + + " Print list of Journal Files\n" + + " -log, --entrylog\n" + + " Print list of EntryLog Files\n" + + " -idx, --index\n" + + " Print list of Index files "; } @Override @@ -1341,7 +1502,13 @@ String getDescription() { @Override String getUsage() { - return "autorecovery [-enable|-disable]"; + return "autorecovery Enable or disable autorecovery in the cluster\n" + + " Usage: autorecovery [options]\n" + + " Options:\n" + + " * -e, --enable\n" + + " Enable auto recovery of underreplicated ledgers\n" + + " * -d, --disable\n" + + " Disable auto recovery of underreplicated ledgers"; } @Override @@ -1380,7 +1547,9 @@ String getDescription() { @Override String getUsage() { - return "queryautorecoverystatus"; + return "queryautorecoverystatus Query the autorecovery status, " + + "queryautorecoverystatus requires no options,use the default conf or re-specify BOOKIE_CONF \n" + + " Usage: queryautorecoverystatus"; } @Override @@ -1417,7 +1586,15 @@ String getDescription() { @Override String getUsage() { - return "lostbookierecoverydelay [-get|-set ]"; + return "lostbookierecoverydelay Setter and Getter for LostBookieRecoveryDelay value" + + " (in seconds) in metadata store\n" + + " Usage: lostbookierecoverydelay [options]\n" + + " Options:\n" + + " -g, --get\n" + + " Get LostBookieRecoveryDelay value (in seconds)\n" + + " -s, --set\n" + + " Set LostBookieRecoveryDelay value (in seconds, " + + "param format: `lostBookieRecoveryDelayInSecs`) "; } @Override @@ -1458,7 +1635,9 @@ String getDescription() { @Override String getUsage() { - return "whoisauditor"; + return "whoisauditor Print the node which holds the auditor lock, " + + "whoisauditor requires no options,use the default conf or re-specify BOOKIE_CONF \n" + + " Usage: whoisauditor"; } @Override @@ -1491,7 +1670,9 @@ String getDescription() { @Override String getUsage() { - return "whatisinstanceid"; + return "whatisinstanceid Print the instanceid of the cluster, " + + "whatisinstanceid requires no options,use the default conf or re-specify BOOKIE_CONF \n" + + " Usage: whatisinstanceid"; } @Override @@ -1542,7 +1723,17 @@ String getDescription() { @Override String getUsage() { - return "updatecookie [-bookieId ] [-expandstorage] [-list] [-delete ]"; + return "updatecookie Command to update cookie\n" + + " Usage: updatecookie [options]\n" + + " Options:\n" + + " * -b, --bookieId\n" + + " Bookie Id (param format: `address:port`)\n" + + " -e, --expandstorage\n" + + " Expand Storage\n" + + " -l, --list\n" + + " List paths of all the cookies present locally and on zookkeeper\n" + + " -d, --delete\n" + + " Delete cookie both locally and in ZooKeeper (param format: force)"; } @Override @@ -1616,8 +1807,24 @@ String getDescription() { @Override String getUsage() { - return "updateledgers -bookieId [-updatespersec N] [-maxOutstandingReads N] [-limit N] " - + "[-verbose true/false] [-printprogress N]"; + return "updateledgers Update bookie id in ledgers\n" + + " Usage: updateledgers [options]\n" + + " Options:\n" + + " * -b, --bookieId\n" + + " Bookie Id (param format: `address:port`)\n" + + " -s, --updatespersec\n" + + " Number of ledgers updating per second (default: 5, " + + "param format: `updatespersec`)\n" + + " -r, --maxOutstandingReads\n" + + " Max outstanding reads (default: 5 * updatespersec, " + + "param format: `maxOutstandingReads`)\n" + + " -l, --limit\n" + + " Maximum number of ledgers to update (default: no limit, param format: `limit`)\n" + + " -v, --verbose\n" + + " Print status of the ledger updation (default: false, param format: `verbose`)\n" + + " -p, --printprogress\n" + + " Print messages on every configured seconds if verbose turned on " + + "(default: 10 secs, param format: `printprogress`)"; } @Override @@ -1693,8 +1900,28 @@ String getDescription() { @Override String getUsage() { - return "updateBookieInLedger -srcBookie -destBookie " - + "[-updatespersec N] [-maxOutstandingReads N] [-limit N] [-verbose true/false] [-printprogress N]"; + return "updateBookieInLedger Replace bookie in ledger metadata. (useful when re-ip of host) " + + "replace srcBookie with destBookie. (this may take a long time)\n" + + " Usage: updateBookieInLedger [options]\n" + + " Options:\n" + + " * -sb, --srcBookie\n" + + " Source bookie which needs to be replaced by destination bookie " + + "(param format: `address:port`)\n" + + " * -db, --destBookie\n" + + " Destination bookie which replaces source bookie (param format: `address:port`)\n" + + " -s, --updatespersec\n" + + " Number of ledgers updating per second (default: 5, " + + "param format: `updatesPerSec`)\n" + + " -r, --maxOutstandingReads\n" + + " Max outstanding reads (default: 5 * updatespersec, " + + "param format: `maxOutstandingReads`)\n" + + " -l, --limit\n" + + " Maximum number of ledgers to update (default: no limit, param format: `limit`)\n" + + " -v, --verbose\n" + + " Print status of the ledger updation (default: false, param format: `verbose`)\n" + + " -p, --printprogress\n" + + " Print messages on every configured seconds if verbose turned on (default: 10, " + + "param format: `printprogress`)"; } @Override @@ -1772,7 +1999,13 @@ String getDescription() { @Override String getUsage() { - return "deleteledger -ledgerid [-force]"; + return "deleteledger Delete a ledger\n" + + " Usage: deleteledger [options]\n" + + " Options:\n" + + " * -l, --ledgerid\n" + + " Ledger ID (param format: `ledgerId`)\n" + + " * -f, --force\n" + + " Whether to force delete the Ledger without prompt"; } @Override @@ -1798,7 +2031,10 @@ String getDescription() { @Override String getUsage() { - return "bookieinfo"; + return "bookieinfo Retrieve bookie info such as free and total disk space," + + "bookieinfo requires no options," + + "use the default conf or re-specify BOOKIE_CONF \n" + + " Usage: bookieinfo"; } @Override @@ -1830,7 +2066,9 @@ String getDescription() { @Override String getUsage() { - return CMD_TRIGGERAUDIT; + return "triggeraudit Force trigger the Audit by resetting the lostBookieRecoveryDelay, " + + "triggeraudit requires no options,use the default conf or re-specify BOOKIE_CONF \n" + + " Usage: triggeraudit"; } @Override @@ -1872,7 +2110,17 @@ String getDescription() { @Override String getUsage() { - return "forceauditchecks [-checkallledgerscheck [-placementpolicycheck] [-replicascheck]"; + return "forceauditchecks Reset the last run time of auditor checks " + + "(checkallledgerscheck, placementpolicycheck, replicascheck) " + + "The current auditor must be REBOOTED after this command is run" + + " Usage: forceauditchecks [options]\n" + + " Options:\n" + + " * -calc, --checkallledgerscheck\n" + + " Force checkAllLedgers audit upon next Auditor startup\n" + + " * -ppc, --placementpolicycheck\n" + + " Force placementPolicyCheck audit upon next Auditor startup\n" + + " * -rc, --replicascheck\n" + + " Force replicasCheck audit upon next Auditor startup"; } @Override @@ -1936,7 +2184,13 @@ String getDescription() { @Override String getUsage() { - return CMD_DECOMMISSIONBOOKIE + " [-bookieid ]"; + return "decommissionbookie Force trigger the Audittask and make sure all the ledgers stored in the " + + "decommissioning bookie " + "are replicated and cookie of the decommissioned bookie is deleted " + + "from metadata server.\n" + + " Usage: decommissionbookie [options]\n" + + " Options:\n" + + " * -bookieid\n" + + " Decommission a remote bookie (param format: `address:port`)"; } @Override @@ -1972,7 +2226,11 @@ String getDescription() { @Override String getUsage() { - return CMD_ENDPOINTINFO + " [-bookieid ]"; + return "endpointinfo Get info about a remote bookie with a specific bookie\n" + + " Usage: endpointinfo [options]\n" + + " Options:\n" + + " * -b, --bookieid\n" + + " Bookie Id (param format: `address:port`)"; } @Override @@ -2025,7 +2283,8 @@ String getDescription() { @Override String getUsage() { - return CMD_CONVERT_TO_DB_STORAGE; + return "convert-to-db-storage Convert bookie indexes from InterleavedStorage to DbLedgerStorage\n" + + " Usage: convert-to-db-storage\n"; } @Override @@ -2059,7 +2318,9 @@ String getDescription() { @Override String getUsage() { - return CMD_CONVERT_TO_INTERLEAVED_STORAGE; + return "convert-to-interleaved-storage " + + "Convert bookie indexes from DbLedgerStorage to InterleavedStorage\n" + + " Usage: convert-to-interleaved-storage"; } @Override @@ -2092,7 +2353,10 @@ String getDescription() { @Override String getUsage() { - return CMD_REBUILD_DB_LEDGER_LOCATIONS_INDEX; + return "rebuild-db-ledger-locations-index Rebuild DbLedgerStorage locations index by scanning " + + "the entry logs, rebuild-db-ledger-locations-index requires no options,use the default conf " + + "or re-specify BOOKIE_CONF \n" + + " Usage: rebuild-db-ledger-locations-index"; } @Override @@ -2126,7 +2390,12 @@ String getDescription() { @Override String getUsage() { - return CMD_REBUILD_DB_LEDGERS_INDEX; + return "rebuild-db-ledgers-index Rebuild DbLedgerStorage ledgers index by scanning the journal " + + "and entry logs (sets all ledgers to fenced)\n" + + " Usage: rebuild-db-ledgers-index [options]\n" + + " Options:\n" + + " -v, --verbose\n" + + " Verbose logging, print the ledgers added to the new index"; } @Override @@ -2165,7 +2434,11 @@ String getDescription() { @Override String getUsage() { - return CMD_CHECK_DB_LEDGERS_INDEX; + return "check-db-ledgers-index Check DbLedgerStorage ledgers index by performing a read scan\n" + + " Usage: check-db-ledgers-index [options]\n" + + " Options:\n" + + " -v, --verbose\n" + + " Verbose logging, print the ledger data in the index"; } @Override @@ -2218,7 +2491,19 @@ String getDescription() { @Override String getUsage() { - return CMD_REGENERATE_INTERLEAVED_STORAGE_INDEX_FILE; + return "regenerate-interleaved-storage-index-file Regenerate an interleaved storage index file, " + + "from available entrylogger files\n" + + " Usage: regenerate-interleaved-storage-index-file [options]\n" + + " Options:\n" + + " * -l, --ledgerIds\n" + + " Ledger(s) whose index needs to be regenerated (param format: `l1,...,lN`)\n" + + " -dryRun\n" + + " Process the entryLogger, but don't write anything\n" + + " -password\n" + + " The bookie stores the password in the index file, so we need it to regenerate " + + "(param format: `ledgerPassword`)\n" + + " -b64password\n" + + " The password in base64 encoding (param format: `ledgerB64Password`)"; } @Override @@ -2256,7 +2541,8 @@ String getDescription() { @Override String getUsage() { - return "clusterinfo"; + return "clusterinfo Exposes the current info about the cluster of bookies\n" + + " Usage: clusterinfo"; } @Override diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/CreateCookieCommand.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/CreateCookieCommand.java index 46c597d49b2..c2e63594d19 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/CreateCookieCommand.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/CreateCookieCommand.java @@ -42,6 +42,11 @@ public class CreateCookieCommand extends CookieCommand { private static final String NAME = "create"; private static final String DESC = "Create a cookie for a given bookie"; + private static final String USAGE = "cookie_create Create a cookie for a given bookie\n" + + " Usage: cookie_create [options]\n" + + " Options:\n" + + " * -cf, --cookie-file\n" + + " The file to be uploaded as cookie (param format: `cookieFilePath`)"; /** * Flags to create a cookie for a given bookie. @@ -73,6 +78,7 @@ public CreateCookieCommand(Flags flags) { private CreateCookieCommand(Flags flags, PrintStream console) { super(CliSpec.newBuilder() .withName(NAME) + .withUsage(USAGE) .withDescription(DESC) .withFlags(flags) .withConsole(console) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/DeleteCookieCommand.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/DeleteCookieCommand.java index 73cb4e7f51e..d7ce7584e2c 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/DeleteCookieCommand.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/DeleteCookieCommand.java @@ -41,6 +41,12 @@ public class DeleteCookieCommand extends CookieCommand { private static final String NAME = "delete"; private static final String DESC = "Delete a cookie for a given bookie"; + private static final String USAGE = "cookie_delete Delete a cookie for a given bookie\n" + + " Usage: cookie_delete [options]\n" + + " Options:\n" + + " * \n" + + " The bookie-id to be deleted (param format: `address:port`)"; + /** * Flags to delete a cookie for a given bookie. */ @@ -64,6 +70,7 @@ public DeleteCookieCommand(Flags flags) { private DeleteCookieCommand(Flags flags, PrintStream console) { super(CliSpec.newBuilder() .withName(NAME) + .withUsage(USAGE) .withDescription(DESC) .withFlags(flags) .withConsole(console) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/GenerateCookieCommand.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/GenerateCookieCommand.java index d5484f4b74f..827078c0192 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/GenerateCookieCommand.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/GenerateCookieCommand.java @@ -43,6 +43,22 @@ public class GenerateCookieCommand extends CookieCommand { private static final String NAME = "generate"; private static final String DESC = "Generate a cookie for a given bookie"; + private static final String USAGE = "cookie_generate Generate a cookie for a given bookie\n" + + " Usage: cookie_generate [options]\n" + + " Options:\n" + + " -i, --instance-id\n" + + " The instance id of the cluster that this bookie belongs to." + + " If omitted, it will used the instance id of the cluster that this cli connects to. \n" + + " * -j, --journal-dirs\n" + + " The journal directories used by this bookie " + + "(param format: `journalDir1,...,journalDirM`)\n" + + " * -l, --ledger-dirs\n" + + " The ledger directories used by this bookie (param format: `ledgerDir1,...,ledgerDirN`)\n" + + " * -o, --output-file\n" + + " The output file to save the generated cookie (param format: `cookieLocalFilePath`)\n" + + " -ix, --index-dirs\n" + + " The index directories used by this bookie (param format: `indexDir1,...,indexDirN`)"; + /** * Flags to generate a cookie for a given bookie. */ @@ -96,6 +112,7 @@ public GenerateCookieCommand(Flags flags) { private GenerateCookieCommand(Flags flags, PrintStream console) { super(CliSpec.newBuilder() .withName(NAME) + .withUsage(USAGE) .withDescription(DESC) .withFlags(flags) .withConsole(console) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/GetCookieCommand.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/GetCookieCommand.java index 598127a75ad..372dcf4a94b 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/GetCookieCommand.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/GetCookieCommand.java @@ -42,6 +42,12 @@ public class GetCookieCommand extends CookieCommand { private static final String NAME = "get"; private static final String DESC = "Retrieve a cookie for a given bookie"; + private static final String USAGE = "cookie_get Retrieve a cookie for a given bookie\n" + + " Usage: cookie_get [options]\n" + + " Options:\n" + + " * \n" + + " The bookie-id to get (param format: `address:port`)"; + /** * Flags to delete a cookie for a given bookie. */ @@ -65,6 +71,7 @@ public GetCookieCommand(Flags flags) { private GetCookieCommand(Flags flags, PrintStream console) { super(CliSpec.newBuilder() .withName(NAME) + .withUsage(USAGE) .withDescription(DESC) .withFlags(flags) .withConsole(console) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/UpdateCookieCommand.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/UpdateCookieCommand.java index 4979b6ec0ed..f1fe3db455a 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/UpdateCookieCommand.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/cookie/UpdateCookieCommand.java @@ -43,6 +43,14 @@ public class UpdateCookieCommand extends CookieCommand { private static final String NAME = "update"; private static final String DESC = "Update a cookie for a given bookie"; + private static final String USAGE = "cookie_update Update a cookie for a given bookie\n" + + " Usage: cookie_update [options]\n" + + " Options:\n" + + " * -cf, --cookie-file\n" + + " The file to be uploaded as cookie (param format: `cookieFilePath`)\n" + + " * \n" + + " Bookie ID (param format: `address:port`)"; + /** * Flags to create a cookie for a given bookie. */ @@ -73,6 +81,7 @@ public UpdateCookieCommand(Flags flags) { private UpdateCookieCommand(Flags flags, PrintStream console) { super(CliSpec.newBuilder() .withName(NAME) + .withUsage(USAGE) .withDescription(DESC) .withFlags(flags) .withConsole(console) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/helpers/BookieShellCommand.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/helpers/BookieShellCommand.java index 4010e607eb8..8c2068b6516 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/helpers/BookieShellCommand.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/helpers/BookieShellCommand.java @@ -23,6 +23,7 @@ import org.apache.bookkeeper.tools.common.BKCommand; import org.apache.bookkeeper.tools.framework.CliFlags; import org.apache.commons.configuration.CompositeConfiguration; +import org.apache.commons.lang3.StringUtils; /** * This is a util class that converts new cli command to old shell command. @@ -52,7 +53,8 @@ public int runCmd(String[] args) throws Exception { @Override public String description() { - return shellCmdName + " [options]"; + // format as org.apache.bookkeeper.bookie.BookieShell.MyCommand.description + return StringUtils.isBlank(bkCmd.getUsage()) ? shellCmdName + " [options]" : bkCmd.getUsage(); } @Override diff --git a/tools/framework/src/main/java/org/apache/bookkeeper/tools/framework/CliCommand.java b/tools/framework/src/main/java/org/apache/bookkeeper/tools/framework/CliCommand.java index cf68acfeddf..c459eec7a4a 100644 --- a/tools/framework/src/main/java/org/apache/bookkeeper/tools/framework/CliCommand.java +++ b/tools/framework/src/main/java/org/apache/bookkeeper/tools/framework/CliCommand.java @@ -72,4 +72,8 @@ public void usage() { // run with "empty args", which will print the usage for this command group. Cli.printUsage(spec); } + + public String getUsage() { + return spec.usage(); + } } diff --git a/tools/ledger/src/test/java/org/apache/bookkeeper/tools/cli/commands/cookie/CreateCookieCommandTest.java b/tools/ledger/src/test/java/org/apache/bookkeeper/tools/cli/commands/cookie/CreateCookieCommandTest.java index f85c2e518fd..5a785e89dda 100644 --- a/tools/ledger/src/test/java/org/apache/bookkeeper/tools/cli/commands/cookie/CreateCookieCommandTest.java +++ b/tools/ledger/src/test/java/org/apache/bookkeeper/tools/cli/commands/cookie/CreateCookieCommandTest.java @@ -76,7 +76,7 @@ public void testMissingBookieId() { } private void assertPrintUsage(String consoleOutput) { - assertPrintUsage(consoleOutput, "create [flags] "); + assertPrintUsage(consoleOutput, "cookie_create [options]"); } /** diff --git a/tools/ledger/src/test/java/org/apache/bookkeeper/tools/cli/commands/cookie/UpdateCookieCommandTest.java b/tools/ledger/src/test/java/org/apache/bookkeeper/tools/cli/commands/cookie/UpdateCookieCommandTest.java index 13fa43d9f27..7ee8c844405 100644 --- a/tools/ledger/src/test/java/org/apache/bookkeeper/tools/cli/commands/cookie/UpdateCookieCommandTest.java +++ b/tools/ledger/src/test/java/org/apache/bookkeeper/tools/cli/commands/cookie/UpdateCookieCommandTest.java @@ -76,7 +76,7 @@ public void testMissingBookieId() { } private void assertPrintUsage(String consoleOutput) { - assertPrintUsage(consoleOutput, "update [flags] "); + assertPrintUsage(consoleOutput, "cookie_update [options]"); } /**