Skip to content

Commit

Permalink
Using usageHelp instead of deprecated help in picocli commands (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
navina authored Oct 25, 2022
1 parent 7518b3d commit 382d177
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class RawIndexBenchmark {
description = "Number of consecutive docIds to lookup")
private int _numConsecutiveLookups = DEFAULT_NUM_CONSECUTIVE_LOOKUP;

@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, help = true,
@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, usageHelp = true,
description = "print this message")
private boolean _help = false;

Expand Down Expand Up @@ -302,7 +302,11 @@ public static void main(String[] args)
throws Exception {
RawIndexBenchmark benchmark = new RawIndexBenchmark();
CommandLine commandLine = new CommandLine(benchmark);
commandLine.parseArgs(args);
CommandLine.ParseResult result = commandLine.parseArgs(args);
if (commandLine.isUsageHelpRequested() || result.matchedArgs().size() == 0) {
commandLine.usage(System.out);
return;
}
benchmark.run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class AutoAddInvertedIndexTool extends AbstractBaseCommand implements Com
+ AutoAddInvertedIndex.DEFAULT_MAX_NUM_INVERTED_INDEX_ADDED)
private int _maxNumInvertedIndex = AutoAddInvertedIndex.DEFAULT_MAX_NUM_INVERTED_INDEX_ADDED;

@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, help = true,
@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, usageHelp = true,
description = "Print this message.")
private boolean _help = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class PinotToolLauncher {
SUBCOMMAND_MAP.put("SegmentDump", new SegmentDumpTool());
}

@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, help = true,
@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, usageHelp = true,
description = "Print this message.")
boolean _help = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@ public class SegmentDumpTool extends AbstractBaseCommand implements Command {
@CommandLine.Option(names = {"-dumpStarTree"})
private boolean _dumpStarTree = false;

public void doMain(String[] args)
throws Exception {
CommandLine commandLine = new CommandLine(this);
commandLine.parseArgs(args);
dump();
}
@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, usageHelp = true,
description = "Print this message.")
private boolean _help = false;

private void dump()
throws Exception {
Expand Down Expand Up @@ -149,7 +146,14 @@ private void dumpStarTree()

public static void main(String[] args)
throws Exception {
new SegmentDumpTool().doMain(args);
SegmentDumpTool tool = new SegmentDumpTool();
CommandLine commandLine = new CommandLine(tool);
CommandLine.ParseResult result = commandLine.parseArgs(args);
if (commandLine.isUsageHelpRequested() || result.matchedArgs().size() == 0) {
commandLine.usage(System.out);
return;
}
tool.execute();
}

public String getName() {
Expand All @@ -170,6 +174,6 @@ public String description() {

@Override
public boolean getHelp() {
return false;
return _help;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class UpdateSegmentState extends AbstractBaseCommand implements Command {
@CommandLine.Option(names = {"-fix"}, required = false, description = "Update IDEALSTATE values (OFFLINE->ONLINE).")
private boolean _fix = false;

@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, help = true,
@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, usageHelp = true,
description = "Print this message.")
private boolean _help = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ValidateTableRetention extends AbstractBaseCommand implements Comma
+ " default: " + TableRetentionValidator.DEFAULT_DURATION_IN_DAYS_THRESHOLD)
private long _durationInDaysThreshold = TableRetentionValidator.DEFAULT_DURATION_IN_DAYS_THRESHOLD;

@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, help = true,
@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, usageHelp = true,
description = "Print this message.")
private boolean _help = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public class RealtimeProvisioningHelperCommand extends AbstractBaseAdminCommand
description = "Maximum memory per host that can be used for pinot data (e.g. 250G, 100M). Default 48g")
private String _maxUsableHostMemory = "48G";

@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, help = true)
@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, usageHelp = true)
private boolean _help = false;

public RealtimeProvisioningHelperCommand setTableConfigFile(String tableConfigFile) {
Expand Down Expand Up @@ -186,7 +186,7 @@ public boolean getHelp() {
@Override
public void printExamples() {
StringBuilder builder = new StringBuilder();
builder.append("\n\nThis command allows you to estimate the capacity needed for provisioning realtime hosts")
builder.append("\n\nThis command allows you to estimate the capacity needed for provisioning realtime hosts. ")
.append("It assumes that there is no upper limit to the amount of memory you can mmap").append(
"\nIf you have a hybrid table, then consult the push frequency setting in your offline table specify it in "
+ "the -pushFrequency argument").append(
Expand All @@ -197,7 +197,7 @@ public void printExamples() {
"\nDoing so will let this program assume that you are willing to take a page hit when querying older data")
.append("\nand optimize memory and number of hosts accordingly.")
.append("\n See https://docs.pinot.apache.org/operators/operating-pinot/tuning/realtime for details");
System.out.println(builder.toString());
System.out.println(builder);
}

@Override
Expand Down Expand Up @@ -345,4 +345,17 @@ private <T> T deserialize(File file, Class<T> clazz) {
String.format("Cannot read schema file '%s' to '%s' object.", file, clazz.getSimpleName()), e);
}
}

public static void main(String[] args)
throws IOException {
RealtimeProvisioningHelperCommand rtProvisioningHelper = new RealtimeProvisioningHelperCommand();
CommandLine cmdLine = new CommandLine(rtProvisioningHelper);
CommandLine.ParseResult result = cmdLine.parseArgs(args);
if (result.isUsageHelpRequested() || result.matchedArgs().size() == 0) {
cmdLine.usage(System.out);
rtProvisioningHelper.printUsage();
return;
}
rtProvisioningHelper.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class PerfBenchmarkRunner extends AbstractBaseCommand implements Command
description = "Comma separated bloom filter columns to be created (non-batch load).")
private String _bloomFilterColumns;

@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, help = true,
@CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = false, usageHelp = true,
description = "Print this message.")
private boolean _help = false;

Expand Down Expand Up @@ -193,12 +193,11 @@ public static void main(String[] args)
throws Exception {
PerfBenchmarkRunner perfBenchmarkRunner = new PerfBenchmarkRunner();
CommandLine commandLine = new CommandLine(perfBenchmarkRunner);
commandLine.parseArgs(args);

if (perfBenchmarkRunner._help) {
perfBenchmarkRunner.printUsage();
} else {
perfBenchmarkRunner.execute();
CommandLine.ParseResult result = commandLine.parseArgs(args);
if (result.isUsageHelpRequested() || result.matchedArgs().size() == 0) {
commandLine.usage(System.out);
return;
}
commandLine.execute();
}
}
4 changes: 2 additions & 2 deletions pinot-tools/src/main/resources/conf/pinot-tools-log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
-->
<Configuration>
<Appenders>
<Console name="console" target="SYSTEM_OUT"/>
<Console name="console" target="SYSTEM_OUT" follow="true" />
</Appenders>
<Loggers>
<Root level="info" additivity="false">
<Root level="info">
<AppenderRef ref="console"/>
</Root>
<Logger name="org.apache.pinot" level="info" additivity="false"/>
Expand Down

0 comments on commit 382d177

Please sign in to comment.