@InterfaceAudience.Private public abstract class AbstractHBaseTool extends Object implements org.apache.hadoop.util.Tool
Modifier and Type | Class and Description |
---|---|
private class |
AbstractHBaseTool.OptionsOrderComparator |
Modifier and Type | Field and Description |
---|---|
protected String[] |
cmdLineArgs |
protected org.apache.hadoop.conf.Configuration |
conf |
static int |
EXIT_FAILURE |
static int |
EXIT_SUCCESS |
private static org.apache.hbase.thirdparty.org.apache.commons.cli.Option |
HELP_OPTION |
private static org.slf4j.Logger |
LOG |
static String |
LONG_HELP_OPTION |
protected org.apache.hbase.thirdparty.org.apache.commons.cli.Options |
options |
private int |
optionsCount |
private HashMap<org.apache.hbase.thirdparty.org.apache.commons.cli.Option,Integer> |
optionsOrder |
static String |
SHORT_HELP_OPTION |
Constructor and Description |
---|
AbstractHBaseTool() |
Modifier and Type | Method and Description |
---|---|
protected void |
addOption(org.apache.hbase.thirdparty.org.apache.commons.cli.Option option) |
protected abstract void |
addOptions()
Override this to add command-line options using
addOptWithArg(java.lang.String, java.lang.String)
and similar methods. |
protected void |
addOptNoArg(String opt,
String description) |
protected void |
addOptNoArg(String shortOpt,
String longOpt,
String description) |
protected void |
addOptWithArg(String opt,
String description) |
protected void |
addOptWithArg(String shortOpt,
String longOpt,
String description) |
protected void |
addRequiredOption(org.apache.hbase.thirdparty.org.apache.commons.cli.Option option) |
protected void |
addRequiredOptWithArg(String opt,
String description) |
protected void |
addRequiredOptWithArg(String shortOpt,
String longOpt,
String description) |
protected void |
doStaticMain(String[] args)
Call this from the concrete tool class's main function.
|
protected abstract int |
doWork()
The "main function" of the tool
|
org.apache.hadoop.conf.Configuration |
getConf() |
double |
getOptionAsDouble(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd,
String opt,
double defaultValue) |
int |
getOptionAsInt(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd,
String opt,
int defaultValue) |
long |
getOptionAsLong(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd,
String opt,
int defaultValue) |
private boolean |
isHelpCommand(String[] args) |
protected org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser |
newParser()
Create the parser to use for parsing and validating the command line.
|
protected org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine |
parseArgs(String[] args) |
static int |
parseInt(String s,
int minValue,
int maxValue) |
static long |
parseLong(String s,
long minValue,
long maxValue)
Parse a number and enforce a range.
|
protected void |
printUsage() |
protected void |
printUsage(String usageStr,
String usageHeader,
String usageFooter) |
protected void |
processOldArgs(List<String> args)
For backward compatibility.
|
protected abstract void |
processOptions(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd)
This method is called to process the options after they have been parsed.
|
int |
run(String[] args) |
void |
setConf(org.apache.hadoop.conf.Configuration conf) |
public static final int EXIT_SUCCESS
public static final int EXIT_FAILURE
public static final String SHORT_HELP_OPTION
public static final String LONG_HELP_OPTION
private static final org.apache.hbase.thirdparty.org.apache.commons.cli.Option HELP_OPTION
private static final org.slf4j.Logger LOG
protected final org.apache.hbase.thirdparty.org.apache.commons.cli.Options options
protected org.apache.hadoop.conf.Configuration conf
protected String[] cmdLineArgs
private HashMap<org.apache.hbase.thirdparty.org.apache.commons.cli.Option,Integer> optionsOrder
private int optionsCount
public AbstractHBaseTool()
protected abstract void addOptions()
addOptWithArg(java.lang.String, java.lang.String)
and similar methods.protected abstract void processOptions(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd)
protected abstract int doWork() throws Exception
Exception
protected void processOldArgs(List<String> args)
Option
.
(because they don't pass validation, for e.g. "-copy-to". "-" means short name
which doesn't allow '-' in name). This function is to allow tools to have, for time being,
parameters which can't be parsed using Option
.
Overrides should consume all valid legacy arguments. If the param 'args' is not empty on
return, it means there were invalid options, in which case we'll exit from the tool.
Note that it's called before processOptions(CommandLine)
, which means new options'
values will override old ones'.public org.apache.hadoop.conf.Configuration getConf()
getConf
in interface org.apache.hadoop.conf.Configurable
public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf
in interface org.apache.hadoop.conf.Configurable
public int run(String[] args) throws IOException
run
in interface org.apache.hadoop.util.Tool
IOException
protected org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser newParser()
private boolean isHelpCommand(String[] args) throws org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException
org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException
protected org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine parseArgs(String[] args) throws org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException
org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException
protected void printUsage()
protected void printUsage(String usageStr, String usageHeader, String usageFooter)
protected void addOption(org.apache.hbase.thirdparty.org.apache.commons.cli.Option option)
protected void addRequiredOption(org.apache.hbase.thirdparty.org.apache.commons.cli.Option option)
protected void addRequiredOptWithArg(String opt, String description)
protected void addRequiredOptWithArg(String shortOpt, String longOpt, String description)
protected void addOptNoArg(String opt, String description)
protected void addOptNoArg(String shortOpt, String longOpt, String description)
protected void addOptWithArg(String opt, String description)
protected void addOptWithArg(String shortOpt, String longOpt, String description)
public int getOptionAsInt(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd, String opt, int defaultValue)
public long getOptionAsLong(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd, String opt, int defaultValue)
public double getOptionAsDouble(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd, String opt, double defaultValue)
public static long parseLong(String s, long minValue, long maxValue)
protected void doStaticMain(String[] args)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.