use of org.apache.hbase.thirdparty.org.apache.commons.cli.AlreadySelectedException in project hbase by apache.
the class LoadTestTool method newParser.
@Override
protected CommandLineParser newParser() {
// Validate in parse() to get helpful error messages instead of exploding in processOptions()
return new DefaultParser() {
@Override
public CommandLine parse(Options opts, String[] args, Properties props, boolean stop) throws ParseException {
CommandLine cl = super.parse(opts, args, props, stop);
boolean isReadWriteUpdate = cmd.hasOption(OPT_READ) || cmd.hasOption(OPT_WRITE) || cmd.hasOption(OPT_UPDATE);
boolean isInitOnly = cmd.hasOption(OPT_INIT_ONLY);
if (!isInitOnly && !isReadWriteUpdate) {
throw new MissingOptionException("Must specify either -" + OPT_INIT_ONLY + " or at least one of -" + OPT_READ + ", -" + OPT_WRITE + ", -" + OPT_UPDATE);
}
if (isInitOnly && isReadWriteUpdate) {
throw new AlreadySelectedException(OPT_INIT_ONLY + " cannot be specified with any of -" + OPT_READ + ", -" + OPT_WRITE + ", -" + OPT_UPDATE);
}
if (isReadWriteUpdate && !cmd.hasOption(OPT_NUM_KEYS)) {
throw new MissingOptionException(OPT_NUM_KEYS + " must be specified in read/write mode.");
}
return cl;
}
};
}
Aggregations