Skip to content

Commit

Permalink
[Issue 4106] [pulsar-testclient] Improve usage hints for pulsar-perf …
Browse files Browse the repository at this point in the history
…subcommands (apache#4107)

* Improve usage hints for pulsar-perf subcommands.

* Change word prop to tenant
  • Loading branch information
murong00 authored and merlimat committed Apr 24, 2019
1 parent 5e96a9c commit 1c7b12d
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static class Arguments {
@Parameter(names = { "-u", "--proxy-url" }, description = "Pulsar Proxy URL, e.g., \"ws://localhost:8080/\"", required = true)
public String proxyURL;

@Parameter(description = "/persistent/my-property/my-ns/my-topic", required = true)
@Parameter(description = "persistent://tenant/ns/my-topic", required = true)
public List<String> topics;

@Parameter(names = { "-r", "--rate" }, description = "Publish rate msg/s across topics")
Expand Down Expand Up @@ -111,12 +111,12 @@ static class Arguments {
public Arguments loadArguments(String[] args) {
Arguments arguments = new Arguments();
jc = new JCommander(arguments);
jc.setProgramName("pulsar-perf-websocket-producer");
jc.setProgramName("pulsar-perf websocket-producer");

try {
jc.parse(args);
} catch (ParameterException e) {
log.error(e.getMessage());
System.out.println(e.getMessage());
jc.usage();
System.exit(-1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import com.beust.jcommander.ParameterException;
import org.apache.pulsar.broker.TimeAverageBrokerData;
import org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl;
import org.apache.pulsar.policies.data.loadbalancer.LoadReport;
Expand Down Expand Up @@ -428,6 +429,9 @@ private synchronized void printBrokerData(final String broker, final LocalBroker

// JCommander arguments class.
private static class Arguments {
@Parameter(names = { "-h", "--help" }, description = "Help message", help = true)
boolean help;

@Parameter(names = { "--connect-string" }, description = "Zookeeper connect string", required = true)
public String connectString = null;
}
Expand Down Expand Up @@ -465,16 +469,20 @@ public void start() {
* @param args
* Arguments for the monitor.
*/
public static void main(String[] args) {
public static void main(String[] args) throws Exception {
final Arguments arguments = new Arguments();
final JCommander jc = new JCommander(arguments);
jc.setProgramName("pulsar-perf monitor-brokers");

try {
final Arguments arguments = new Arguments();
final JCommander jc = new JCommander(arguments);
jc.parse(args);
final ZooKeeper zkClient = new ZooKeeper(arguments.connectString, ZOOKEEPER_TIMEOUT_MILLIS, null);
final BrokerMonitor monitor = new BrokerMonitor(zkClient);
monitor.start();
} catch (Exception ex) {
throw new RuntimeException(ex);
} catch (ParameterException e) {
System.out.println(e.getMessage());
jc.usage();
System.exit(-1);
}
final ZooKeeper zkClient = new ZooKeeper(arguments.connectString, ZOOKEEPER_TIMEOUT_MILLIS, null);
final BrokerMonitor monitor = new BrokerMonitor(zkClient);
monitor.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,13 @@ public LoadSimulationClient(final MainArguments arguments) throws Exception {
public static void main(String[] args) throws Exception {
final MainArguments mainArguments = new MainArguments();
final JCommander jc = new JCommander(mainArguments);
jc.setProgramName("pulsar-perf simulation-client");
try {
jc.parse(args);
} catch (ParameterException e) {
System.out.println(e.getMessage());
jc.usage();
throw e;
System.exit(-1);
}
(new LoadSimulationClient(mainArguments)).run();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public class LoadSimulationController {

// JCommander arguments for starting a controller via main.
private static class MainArguments {
@Parameter(names = { "-h", "--help" }, description = "Help message", help = true)
boolean help;

@Parameter(names = { "--cluster" }, description = "Cluster to test on", required = true)
String cluster;

Expand Down Expand Up @@ -711,12 +714,13 @@ public void run() throws Exception {
public static void main(String[] args) throws Exception {
final MainArguments arguments = new MainArguments();
final JCommander jc = new JCommander(arguments);
jc.setProgramName("pulsar-perf simulation-controller");
try {
jc.parse(args);
} catch (Exception ex) {
System.out.println(ex.getMessage());
jc.usage();
ex.printStackTrace();
System.exit(1);
System.exit(-1);
}
(new LoadSimulationController(arguments)).run();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static class Arguments {
@Parameter(names = { "--threads" }, description = "Number of threads writing")
public int numThreads = 1;

@Parameter(names = { "-zk", "--zookeeperServers" }, description = "ZooKeeper connection string")
@Parameter(names = { "-zk", "--zookeeperServers" }, description = "ZooKeeper connection string", required = true)
public String zookeeperServers;

@Parameter(names = { "-o", "--max-outstanding" }, description = "Max number of outstanding requests")
Expand Down Expand Up @@ -129,7 +129,7 @@ public static void main(String[] args) throws Exception {

final Arguments arguments = new Arguments();
JCommander jc = new JCommander(arguments);
jc.setProgramName("pulsar-perf-producer");
jc.setProgramName("pulsar-perf managed-ledger");

try {
jc.parse(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static class Arguments {
public static void main(String[] args) throws Exception {
final Arguments arguments = new Arguments();
JCommander jc = new JCommander(arguments);
jc.setProgramName("pulsar-perf-consumer");
jc.setProgramName("pulsar-perf consume");

try {
jc.parse(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static void main(String[] args) throws Exception {

final Arguments arguments = new Arguments();
JCommander jc = new JCommander(arguments);
jc.setProgramName("pulsar-perf-producer");
jc.setProgramName("pulsar-perf produce");

try {
jc.parse(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static class Arguments {
public static void main(String[] args) throws Exception {
final Arguments arguments = new Arguments();
JCommander jc = new JCommander(arguments);
jc.setProgramName("pulsar-perf-reader");
jc.setProgramName("pulsar-perf read");

try {
jc.parse(args);
Expand Down

0 comments on commit 1c7b12d

Please sign in to comment.