use of org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter in project hbase by apache.
the class RESTServer method printUsageAndExit.
private static void printUsageAndExit(Options options, int exitCode) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("hbase rest start", "", options, "\nTo run the REST server as a daemon, execute " + "hbase-daemon.sh start|stop rest [-i <port>] [-p <port>] [-ro]\n", true);
System.exit(exitCode);
}
use of org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter in project hbase by apache.
the class ProcedureWALPrettyPrinter method run.
/**
* Pass one or more log file names and formatting options and it will dump out
* a text version of the contents on <code>stdout</code>.
*
* @param args
* Command line arguments
* @throws IOException
* Thrown upon file system errors etc.
*/
@Override
public int run(final String[] args) throws IOException {
// create options
Options options = new Options();
options.addOption("h", "help", false, "Output help message");
options.addOption("f", "file", true, "File to print");
final List<Path> files = new ArrayList<>();
try {
CommandLine cmd = new DefaultParser().parse(options, args);
if (cmd.hasOption("f")) {
files.add(new Path(cmd.getOptionValue("f")));
}
if (files.isEmpty() || cmd.hasOption("h")) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("ProcedureWALPrettyPrinter ", options, true);
return (-1);
}
} catch (ParseException e) {
LOG.error("Failed to parse commandLine arguments", e);
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("ProcedureWALPrettyPrinter ", options, true);
return (-1);
}
// get configuration, file system, and process the given files
for (Path file : files) {
processFile(getConf(), file);
}
return (0);
}
use of org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter in project hbase by apache.
the class RowCounter method printUsage.
@Override
protected void printUsage(final String usageStr, final String usageHeader, final String usageFooter) {
HelpFormatter helpFormatter = new HelpFormatter();
helpFormatter.setWidth(120);
helpFormatter.setOptionComparator(new AbstractHBaseTool.OptionsOrderComparator());
helpFormatter.setLongOptSeparator("=");
helpFormatter.printHelp(usageStr, usageHeader, options, usageFooter);
}
use of org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter in project hbase by apache.
the class WALPrettyPrinter method run.
/**
* Pass one or more log file names and formatting options and it will dump out
* a text version of the contents on <code>stdout</code>.
*
* @param args
* Command line arguments
* @throws IOException
* Thrown upon file system errors etc.
*/
public static void run(String[] args) throws IOException {
// create options
Options options = new Options();
options.addOption("h", "help", false, "Output help message");
options.addOption("j", "json", false, "Output JSON");
options.addOption("p", "printvals", false, "Print values");
options.addOption("t", "tables", true, "Table names (comma separated) to filter by; eg: test1,test2,test3 ");
options.addOption("r", "region", true, "Region to filter by. Pass encoded region name; e.g. '9192caead6a5a20acb4454ffbc79fa14'");
options.addOption("s", "sequence", true, "Sequence to filter by. Pass sequence number.");
options.addOption("k", "outputOnlyRowKey", false, "Print only row keys");
options.addOption("w", "row", true, "Row to filter by. Pass row name.");
options.addOption("f", "rowPrefix", true, "Row prefix to filter by.");
options.addOption("g", "goto", true, "Position to seek to in the file");
WALPrettyPrinter printer = new WALPrettyPrinter();
CommandLineParser parser = new PosixParser();
List<?> files = null;
try {
CommandLine cmd = parser.parse(options, args);
files = cmd.getArgList();
if (files.isEmpty() || cmd.hasOption("h")) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("WAL <filename...>", options, true);
System.exit(-1);
}
// configure the pretty printer using command line options
if (cmd.hasOption("p")) {
printer.enableValues();
}
if (cmd.hasOption("j")) {
printer.enableJSON();
}
if (cmd.hasOption("k")) {
printer.setOutputOnlyRowKey();
}
if (cmd.hasOption("t")) {
printer.setTableFilter(cmd.getOptionValue("t"));
}
if (cmd.hasOption("r")) {
printer.setRegionFilter(cmd.getOptionValue("r"));
}
if (cmd.hasOption("s")) {
printer.setSequenceFilter(Long.parseLong(cmd.getOptionValue("s")));
}
if (cmd.hasOption("w")) {
if (cmd.hasOption("f")) {
throw new ParseException("Row and Row-prefix cannot be supplied together");
}
printer.setRowFilter(cmd.getOptionValue("w"));
}
if (cmd.hasOption("f")) {
if (cmd.hasOption("w")) {
throw new ParseException("Row and Row-prefix cannot be supplied together");
}
printer.setRowPrefixFilter(cmd.getOptionValue("f"));
}
if (cmd.hasOption("g")) {
printer.setPosition(Long.parseLong(cmd.getOptionValue("g")));
}
} catch (ParseException e) {
LOG.error("Failed to parse commandLine arguments", e);
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("HFile filename(s) ", options, true);
System.exit(-1);
}
// get configuration, file system, and process the given files
Configuration conf = HBaseConfiguration.create();
CommonFSUtils.setFsDefault(conf, CommonFSUtils.getRootDir(conf));
// begin output
printer.beginPersistentOutput();
for (Object f : files) {
Path file = new Path((String) f);
FileSystem fs = file.getFileSystem(conf);
if (!fs.exists(file)) {
System.err.println("ERROR, file doesnt exist: " + file);
return;
}
printer.processFile(conf, file);
}
printer.endPersistentOutput();
}
use of org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter in project hbase by apache.
the class ThriftServer method printUsageAndExit.
protected void printUsageAndExit(Options options, int exitCode) throws ExitCodeException {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("Thrift", null, options, "To start the Thrift server run 'hbase-daemon.sh start thrift' or " + "'hbase thrift'\n" + "To shutdown the thrift server run 'hbase-daemon.sh stop " + "thrift' or send a kill signal to the thrift server pid", true);
throw new ExitCodeException(exitCode, "");
}
Aggregations