diff --git a/core/src/main/java/org/apache/accumulo/core/cli/Help.java b/core/src/main/java/org/apache/accumulo/core/cli/Help.java index 6ba1d4c5759..3e3d96dc1e0 100644 --- a/core/src/main/java/org/apache/accumulo/core/cli/Help.java +++ b/core/src/main/java/org/apache/accumulo/core/cli/Help.java @@ -23,11 +23,12 @@ import com.beust.jcommander.ParameterException; public class Help { + private final JCommander commander = new JCommander(); + @Parameter(names = {"-h", "-?", "--help", "-help"}, help = true) public boolean help = false; public void parseArgs(String programName, String[] args, Object... others) { - JCommander commander = new JCommander(); commander.addObject(this); for (Object other : others) { commander.addObject(other); @@ -39,7 +40,10 @@ public void parseArgs(String programName, String[] args, Object... others) { commander.usage(); exitWithError(ex.getMessage(), 1); } - if (help) { + } + + public void printUsage(boolean isHelp) { + if (isHelp) { commander.usage(); exit(0); } diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/CreateEmpty.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/CreateEmpty.java index f7d7eb9acdd..b9677579681 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/rfile/CreateEmpty.java +++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/CreateEmpty.java @@ -97,6 +97,7 @@ public void execute(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs("accumulo create-empty", args); + opts.printUsage(opts.help); for (String arg : opts.files) { Path path = new Path(arg); diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/GenerateSplits.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/GenerateSplits.java index 865210a9708..5655425ff91 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/rfile/GenerateSplits.java +++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/GenerateSplits.java @@ -116,6 +116,7 @@ public static void main(String[] args) throws Exception { public void execute(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(GenerateSplits.class.getName(), args); + opts.printUsage(opts.help); if (opts.files.isEmpty()) { throw new IllegalArgumentException("No files were given"); } diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java index 1c3f5c90f4e..f8a789324e7 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java +++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java @@ -164,6 +164,7 @@ protected Class<? extends BiFunction<Key,Value,String>> getFormatter(String form public void execute(final String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs("accumulo rfile-info", args); + opts.printUsage(opts.help); if (opts.files.isEmpty()) { System.err.println("No files were given"); System.exit(1); diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/SplitLarge.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/SplitLarge.java index e3adf9e5175..ce25c7f41f0 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/rfile/SplitLarge.java +++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/SplitLarge.java @@ -75,6 +75,7 @@ public void execute(String[] args) throws Exception { FileSystem fs = FileSystem.get(conf); Opts opts = new Opts(); opts.parseArgs("accumulo split-large", args); + opts.printUsage(opts.help); for (String file : opts.files) { AccumuloConfiguration aconf = opts.getSiteConfiguration(); diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintBCInfo.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintBCInfo.java index fd8356a0261..cdab34713eb 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintBCInfo.java +++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintBCInfo.java @@ -75,6 +75,7 @@ static class Opts extends ConfigOpts { public PrintBCInfo(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs("PrintInfo", args); + opts.printUsage(opts.help); if (opts.file.isEmpty()) { System.err.println("No files were given"); System.exit(-1); diff --git a/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java b/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java index f17cf675d6b..497a1553a06 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java +++ b/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java @@ -80,6 +80,7 @@ public String description() { public void execute(String[] args) { Opts opts = new Opts(); opts.parseArgs("accumulo create-token", args); + opts.printUsage(opts.help); String pass = opts.password; if (pass == null && opts.securePassword != null) { diff --git a/core/src/main/java/org/apache/accumulo/core/util/Merge.java b/core/src/main/java/org/apache/accumulo/core/util/Merge.java index 41f5a67943b..0b32980106a 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/Merge.java +++ b/core/src/main/java/org/apache/accumulo/core/util/Merge.java @@ -100,6 +100,7 @@ static class Opts extends ClientOpts { public void start(String[] args) throws MergeException { Opts opts = new Opts(); opts.parseArgs(Merge.class.getName(), args); + opts.printUsage(opts.help); Span span = TraceUtil.startSpan(Merge.class, "start"); try (Scope scope = span.makeCurrent()) { diff --git a/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java b/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java index 7d9c2d44aa1..6bec5e53a42 100644 --- a/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java +++ b/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java @@ -19,9 +19,12 @@ package org.apache.accumulo.core.cli; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; +import com.beust.jcommander.Parameter; + public class TestHelp { protected class HelpStub extends Help { @Override @@ -46,4 +49,21 @@ public void testInvalidArgs() { } } + @Test + public void testHelpCommand() { + class TestHelpOpt extends HelpStub { + @Parameter(names = {"--test"}) + boolean test = false; + } + + String[] args = {"--help", "--test"}; + TestHelpOpt opts = new TestHelpOpt(); + opts.parseArgs("program", args); + assertTrue(opts.test); + try { + opts.printUsage(opts.help); + } catch (RuntimeException e) { + assertEquals("0", e.getMessage()); + } + } } diff --git a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/its/mapreduce/RowHashIT.java b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/its/mapreduce/RowHashIT.java index 5af7ebbaaca..3a5deb1828e 100644 --- a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/its/mapreduce/RowHashIT.java +++ b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/its/mapreduce/RowHashIT.java @@ -205,6 +205,7 @@ public int run(String[] args) throws Exception { job.setJarByClass(this.getClass()); RowHash.Opts opts = new RowHash.Opts(); opts.parseArgs(RowHash.class.getName(), args); + opts.printUsage(opts.help); job.setInputFormatClass(AccumuloInputFormat.class); String col = opts.column; diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java index b2333c32b7d..5e05b449548 100644 --- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java +++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java @@ -158,6 +158,7 @@ public static class Opts extends Help { public static void main(String[] args) throws IOException, InterruptedException { Opts opts = new Opts(); opts.parseArgs(MiniAccumuloRunner.class.getName(), args); + opts.printUsage(opts.help); if (opts.printProps) { printProperties(); diff --git a/server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java b/server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java index c65314a0f12..ec55deee15c 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java @@ -57,6 +57,7 @@ protected AbstractServer(String appName, ServerOpts opts, String[] args) { this.log = LoggerFactory.getLogger(getClass().getName()); this.applicationName = appName; opts.parseArgs(appName, args); + opts.printUsage(opts.help); this.hostname = Objects.requireNonNull(opts.getAddress()); var siteConfig = opts.getSiteConfiguration(); SecurityUtil.serverLogin(siteConfig); diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/CheckCompactionConfig.java b/server/base/src/main/java/org/apache/accumulo/server/conf/CheckCompactionConfig.java index c02b36edf70..b3e0a8a69ca 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/CheckCompactionConfig.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/CheckCompactionConfig.java @@ -83,6 +83,7 @@ public static void main(String[] args) throws Exception { public void execute(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(keyword(), args); + opts.printUsage(opts.help); if (opts.filePath == null) { throw new IllegalArgumentException("No properties file was given"); diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/util/ZooInfoViewer.java b/server/base/src/main/java/org/apache/accumulo/server/conf/util/ZooInfoViewer.java index c45b0b8832e..fcdfdea81e1 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/util/ZooInfoViewer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/util/ZooInfoViewer.java @@ -110,6 +110,7 @@ public void execute(String[] args) throws Exception { ZooInfoViewer.Opts opts = new ZooInfoViewer.Opts(); opts.parseArgs(ZooInfoViewer.class.getName(), args); + opts.printUsage(opts.help); log.info("print ids map: {}", opts.printIdMap); log.info("print properties: {}", opts.printProps); diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/util/ZooPropEditor.java b/server/base/src/main/java/org/apache/accumulo/server/conf/util/ZooPropEditor.java index ff277202fa3..4be170e783d 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/util/ZooPropEditor.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/util/ZooPropEditor.java @@ -84,6 +84,7 @@ public String description() { public void execute(String[] args) throws Exception { ZooPropEditor.Opts opts = new ZooPropEditor.Opts(); opts.parseArgs(ZooPropEditor.class.getName(), args); + opts.printUsage(opts.help); ZooReaderWriter zrw = new ZooReaderWriter(opts.getSiteConfiguration()); diff --git a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java index bd8d7d3fd51..a1625e17f99 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java +++ b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java @@ -527,6 +527,7 @@ public void execute(final String[] args) { boolean success = true; Opts opts = new Opts(); opts.parseArgs("accumulo init", args); + opts.printUsage(opts.help); var siteConfig = SiteConfiguration.auto(); ZooReaderWriter zoo = new ZooReaderWriter(siteConfig); SecurityUtil.serverLogin(siteConfig); diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java index fe5f57a971e..de3a63b1d51 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java @@ -96,26 +96,28 @@ public class Admin implements KeywordExecutable { private static final Logger log = LoggerFactory.getLogger(Admin.class); - static class AdminOpts extends ServerUtilOpts { - @Parameter(names = {"-f", "--force"}, - description = "force the given server to stop by removing its lock") - boolean force = false; + private static class SubCommandOpts { + @Parameter(names = {"-h", "-?", "--help", "-help"}, help = true) + public boolean help = false; } @Parameters(commandDescription = "stop the tablet server on the given hosts") - static class StopCommand { + static class StopCommand extends SubCommandOpts { + @Parameter(names = {"-f", "--force"}, + description = "force the given server to stop by removing its lock") + boolean force = false; @Parameter(description = "<host> {<host> ... }") List<String> args = new ArrayList<>(); } @Parameters(commandDescription = "Ping tablet servers. If no arguments, pings all.") - static class PingCommand { + static class PingCommand extends SubCommandOpts { @Parameter(description = "{<host> ... }") List<String> args = new ArrayList<>(); } @Parameters(commandDescription = "print tablets that are offline in online tables") - static class CheckTabletsCommand { + static class CheckTabletsCommand extends SubCommandOpts { @Parameter(names = "--fixFiles", description = "Remove dangling file pointers") boolean fixFiles = false; @@ -125,17 +127,17 @@ static class CheckTabletsCommand { } @Parameters(commandDescription = "stop the manager") - static class StopManagerCommand {} + static class StopManagerCommand extends SubCommandOpts {} @Deprecated(since = "2.1.0") @Parameters(commandDescription = "stop the master (DEPRECATED -- use stopManager instead)") static class StopMasterCommand {} @Parameters(commandDescription = "stop all tablet servers and the manager") - static class StopAllCommand {} + static class StopAllCommand extends SubCommandOpts {} @Parameters(commandDescription = "list Accumulo instances in zookeeper") - static class ListInstancesCommand { + static class ListInstancesCommand extends SubCommandOpts { @Parameter(names = "--print-errors", description = "display errors while listing instances") boolean printErrors = false; @Parameter(names = "--print-all", @@ -144,13 +146,13 @@ static class ListInstancesCommand { } @Parameters(commandDescription = "Accumulo volume utility") - static class VolumesCommand { + static class VolumesCommand extends SubCommandOpts { @Parameter(names = {"-l", "--list"}, description = "list volumes currently in use") boolean printErrors = false; } @Parameters(commandDescription = "print out non-default configuration settings") - static class DumpConfigCommand { + static class DumpConfigCommand extends SubCommandOpts { @Parameter(names = {"-a", "--all"}, description = "print the system and all table configurations") boolean allConfiguration = false; @@ -173,13 +175,13 @@ static class DumpConfigCommand { + "necessary."; @Parameters(commandDescription = RV_DEPRECATION_MSG) - static class RandomizeVolumesCommand { + static class RandomizeVolumesCommand extends SubCommandOpts { @Parameter(names = {"-t"}, description = "table to update", required = true) String tableName = null; } @Parameters(commandDescription = "Verify all Tablets are assigned to tablet servers") - static class VerifyTabletAssignmentsCommand { + static class VerifyTabletAssignmentsCommand extends SubCommandOpts { @Parameter(names = {"-v", "--verbose"}, description = "verbose mode (prints locations of tablets)") boolean verbose = false; @@ -194,14 +196,14 @@ static class ChangeSecretCommand {} @Parameters( commandDescription = "List or delete Tablet Server locks. Default with no arguments is to list the locks.") - static class TabletServerLocksCommand { + static class TabletServerLocksCommand extends SubCommandOpts { @Parameter(names = "-delete", description = "specify a tablet server lock to delete") String delete = null; } @Parameters( commandDescription = "Deletes specific instance name or id from zookeeper or cleans up all old instances.") - static class DeleteZooInstanceCommand { + static class DeleteZooInstanceCommand extends SubCommandOpts { @Parameter(names = {"-i", "--instance"}, description = "the instance name or id to delete") String instance; @Parameter(names = {"-c", "--clean"}, @@ -214,7 +216,7 @@ static class DeleteZooInstanceCommand { } @Parameters(commandDescription = "Restore Zookeeper data from a file.") - static class RestoreZooCommand { + static class RestoreZooCommand extends SubCommandOpts { @Parameter(names = "--overwrite") boolean overwrite = false; @@ -224,7 +226,7 @@ static class RestoreZooCommand { @Parameters(commandNames = "fate", commandDescription = "Operations performed on the Manager FaTE system.") - static class FateOpsCommand { + static class FateOpsCommand extends SubCommandOpts { @Parameter(description = "[<txId>...]") List<String> txList = new ArrayList<>(); @@ -256,7 +258,7 @@ static class FateOpsCommand { } @Parameters(commandDescription = "show service status") - public static class ServiceStatusCmdOpts { + public static class ServiceStatusCmdOpts extends SubCommandOpts { @Parameter(names = "--json", description = "provide output in json format (--noHosts ignored)") boolean json = false; @Parameter(names = "--noHosts", @@ -288,7 +290,7 @@ public String description() { public void execute(final String[] args) { boolean everything; - AdminOpts opts = new AdminOpts(); + ServerUtilOpts opts = new ServerUtilOpts(); JCommander cl = new JCommander(opts); cl.setProgramName("accumulo admin"); @@ -346,11 +348,19 @@ public void execute(final String[] args) { cl.parse(args); - if (opts.help || cl.getParsedCommand() == null) { + if (cl.getParsedCommand() == null) { cl.usage(); return; } + if (opts.help || listInstancesOpts.help || pingCommand.help || checkTabletsCommand.help + || stopOpts.help || dumpConfigCommand.help || volumesCommand.help + || verifyTabletAssignmentsOpts.help || deleteZooInstOpts.help || restoreZooOpts.help + || fateOpsCommand.help || tServerLocksOpts.help || serviceStatusCommandOpts.help) { + cl.getCommands().get(cl.getParsedCommand()).usage(); + return; + } + ServerContext context = opts.getServerContext(); AccumuloConfiguration conf = context.getConfiguration(); @@ -389,7 +399,7 @@ public void execute(final String[] args) { } } else if (cl.getParsedCommand().equals("stop")) { - stopTabletServer(context, stopOpts.args, opts.force); + stopTabletServer(context, stopOpts.args, stopOpts.force); } else if (cl.getParsedCommand().equals("dumpConfig")) { printConfig(context, dumpConfigCommand); } else if (cl.getParsedCommand().equals("volumes")) { diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ConvertConfig.java b/server/base/src/main/java/org/apache/accumulo/server/util/ConvertConfig.java index 74b4be6391c..6b8c18ce71d 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/ConvertConfig.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/ConvertConfig.java @@ -81,6 +81,7 @@ private static void writeLine(BufferedWriter w, String value) { public void execute(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs("accumulo convert-config", args); + opts.printUsage(opts.help); File xmlFile = new File(opts.xmlPath); if (!xmlFile.exists()) { diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/DumpZookeeper.java b/server/base/src/main/java/org/apache/accumulo/server/util/DumpZookeeper.java index f3b18eda536..6724a9b9dc9 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/DumpZookeeper.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/DumpZookeeper.java @@ -70,6 +70,7 @@ static class Opts extends ConfigOpts { public void execute(String[] args) throws KeeperException, InterruptedException { Opts opts = new Opts(); opts.parseArgs(DumpZookeeper.class.getName(), args); + opts.printUsage(opts.help); PrintStream out = System.out; zk = new ZooReaderWriter(opts.getSiteConfiguration()); diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ListInstances.java b/server/base/src/main/java/org/apache/accumulo/server/util/ListInstances.java index 131ded3d576..91d9a7a4204 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/ListInstances.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/ListInstances.java @@ -65,6 +65,7 @@ static class Opts extends Help { public static void main(String[] args) { opts.parseArgs(ListInstances.class.getName(), args); + opts.printUsage(opts.help); if (opts.keepers == null) { var siteConfig = SiteConfiguration.auto(); diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/RandomWriter.java b/server/base/src/main/java/org/apache/accumulo/server/util/RandomWriter.java index 8ca2e0a1949..9c7e4a80f2c 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/RandomWriter.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/RandomWriter.java @@ -100,6 +100,7 @@ public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.principal = "root"; opts.parseArgs(RandomWriter.class.getName(), args); + opts.printUsage(opts.help); Span span = TraceUtil.startSpan(RandomWriter.class, "main"); try (Scope scope = span.makeCurrent()) { diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/RemoveEntriesForMissingFiles.java b/server/base/src/main/java/org/apache/accumulo/server/util/RemoveEntriesForMissingFiles.java index f9c05cdba86..233643a6574 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/RemoveEntriesForMissingFiles.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/RemoveEntriesForMissingFiles.java @@ -212,6 +212,7 @@ static int checkTable(ServerContext context, String tableName, boolean fix) thro public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(RemoveEntriesForMissingFiles.class.getName(), args); + opts.printUsage(opts.help); Span span = TraceUtil.startSpan(RemoveEntriesForMissingFiles.class, "main"); try (Scope scope = span.makeCurrent()) { checkAllTables(opts.getServerContext(), opts.fix); diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java b/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java index 4284f8f8d0d..9ed9489e61a 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java @@ -337,6 +337,7 @@ static class Opts extends ServerUtilOpts { public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(TableDiskUsage.class.getName(), args); + opts.printUsage(opts.help); Span span = TraceUtil.startSpan(TableDiskUsage.class, "main"); try (Scope scope = span.makeCurrent()) { try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build()) { diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java b/server/base/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java index b98ef90b340..d332137e51d 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java @@ -63,6 +63,7 @@ public String description() { public void execute(final String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(ZooKeeperMain.class.getName(), args); + opts.printUsage(opts.help); try (var context = new ServerContext(SiteConfiguration.auto())) { if (opts.servers == null) { opts.servers = context.getZooKeepers(); diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java b/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java index 8e37cba708b..55350a5975d 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java @@ -92,6 +92,7 @@ public static void main(String[] args) throws Exception { public void execute(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(keyword(), args); + opts.printUsage(opts.help); if (!opts.zapMaster && !opts.zapManager && !opts.zapTservers) { new JCommander(opts).usage(); diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/AdminCommandsTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/AdminCommandsTest.java index d3f77a34d1a..47181b11655 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/util/AdminCommandsTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/util/AdminCommandsTest.java @@ -86,8 +86,8 @@ public void testDumpConfigCommand() { // not a command, but easy enough to include here @Test - public void testAdminOpts() { - Admin.AdminOpts opts = new Admin.AdminOpts(); + public void testStopOpts() { + Admin.StopCommand opts = new Admin.StopCommand(); assertFalse(opts.force); } } diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java index 8f2fb08bd95..6ad38e166e6 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java @@ -106,6 +106,8 @@ public String description() { public void execute(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs("accumulo wal-info", args); + opts.printUsage(opts.help); + if (opts.files.isEmpty()) { System.err.println("No WAL files were given"); System.exit(1); diff --git a/test/src/main/java/org/apache/accumulo/test/GenerateSequentialRFile.java b/test/src/main/java/org/apache/accumulo/test/GenerateSequentialRFile.java index e3769f7b73d..c2258558b1f 100644 --- a/test/src/main/java/org/apache/accumulo/test/GenerateSequentialRFile.java +++ b/test/src/main/java/org/apache/accumulo/test/GenerateSequentialRFile.java @@ -83,6 +83,7 @@ public void run() { public static void main(String[] args) { Opts opts = new Opts(); opts.parseArgs(GenerateSequentialRFile.class.getName(), args); + opts.printUsage(opts.help); new GenerateSequentialRFile(opts).run(); } } diff --git a/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java b/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java index b074ce2ee8d..76e440ffc23 100644 --- a/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java +++ b/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java @@ -232,6 +232,7 @@ private static void checkKeyValue(long expected, Key k, Value v) throws Exceptio public static void main(String[] args) { Opts opts = new Opts(); opts.parseArgs(TestBinaryRows.class.getName(), args); + opts.printUsage(opts.help); try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build()) { runTest(client, opts); diff --git a/test/src/main/java/org/apache/accumulo/test/TestIngest.java b/test/src/main/java/org/apache/accumulo/test/TestIngest.java index f20cf31afe4..ea390b798b4 100644 --- a/test/src/main/java/org/apache/accumulo/test/TestIngest.java +++ b/test/src/main/java/org/apache/accumulo/test/TestIngest.java @@ -250,6 +250,7 @@ public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(TestIngest.class.getSimpleName(), args); + opts.printUsage(opts.help); try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build()) { ingest(client, opts.getIngestPrams()); diff --git a/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java b/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java index 3caab70909d..ef43ce2ff5f 100644 --- a/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java +++ b/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java @@ -77,6 +77,7 @@ public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(TestMultiTableIngest.class.getName(), args); + opts.printUsage(opts.help); // create the test table within accumulo try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build()) { for (int i = 0; i < opts.tables; i++) { diff --git a/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java b/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java index 0b031ae87ab..d5c17740f63 100644 --- a/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java +++ b/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java @@ -135,6 +135,7 @@ public static void main(String[] args) { TestOpts opts = new TestOpts(); opts.parseArgs(TestRandomDeletes.class.getName(), args); + opts.printUsage(opts.help); log.info("starting random delete test"); diff --git a/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java b/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java index 092ea14a750..de5e70dc7ec 100644 --- a/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java +++ b/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java @@ -90,6 +90,7 @@ public VerifyParams getVerifyParams() { public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(VerifyIngest.class.getName(), args); + opts.printUsage(opts.help); Span span = TraceUtil.startSpan(VerifyIngest.class, "main"); try (Scope scope = span.makeCurrent()) { diff --git a/test/src/main/java/org/apache/accumulo/test/mapreduce/RowHash.java b/test/src/main/java/org/apache/accumulo/test/mapreduce/RowHash.java index 0ee08985f8a..74c2a092d2c 100644 --- a/test/src/main/java/org/apache/accumulo/test/mapreduce/RowHash.java +++ b/test/src/main/java/org/apache/accumulo/test/mapreduce/RowHash.java @@ -78,6 +78,7 @@ public int run(String[] args) throws Exception { job.setJarByClass(this.getClass()); Opts opts = new Opts(); opts.parseArgs(RowHash.class.getName(), args); + opts.printUsage(opts.help); job.setInputFormatClass(org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.class); org.apache.accumulo.core.client.ClientConfiguration clientConf = diff --git a/test/src/main/java/org/apache/accumulo/test/performance/NullTserver.java b/test/src/main/java/org/apache/accumulo/test/performance/NullTserver.java index 8b7230448c3..f6868da7479 100644 --- a/test/src/main/java/org/apache/accumulo/test/performance/NullTserver.java +++ b/test/src/main/java/org/apache/accumulo/test/performance/NullTserver.java @@ -322,6 +322,7 @@ static class Opts extends Help { public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(NullTserver.class.getName(), args); + opts.printUsage(opts.help); // modify metadata int zkTimeOut = diff --git a/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java b/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java index 63ec7fcf113..fa9576ceaeb 100644 --- a/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java +++ b/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java @@ -109,6 +109,7 @@ public static void main(String[] args) throws Exception { final CollectOptions opts = new CollectOptions(); opts.parseArgs(CollectTabletStats.class.getName(), args); + opts.printUsage(opts.help); String[] columnsTmp = {}; if (opts.columns != null) { diff --git a/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java b/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java index 381f60f0f3d..0644cf3a2b1 100644 --- a/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java +++ b/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java @@ -140,6 +140,7 @@ public SiteConfiguration getSiteConfiguration() { public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(CertUtils.class.getName(), args); + opts.printUsage(opts.help); String operation = opts.operation.get(0); String keyPassword = opts.keystorePassword;