org.apache.hadoop.hbase.util
Class AbstractHBaseTool

java.lang.Object
  extended by org.apache.hadoop.hbase.util.AbstractHBaseTool
All Implemented Interfaces:
org.apache.hadoop.conf.Configurable, org.apache.hadoop.util.Tool

@InterfaceAudience.Private
public abstract class AbstractHBaseTool
extends Object
implements org.apache.hadoop.util.Tool

Common base class used for HBase command-line tools. Simplifies workflow and command-line argument parsing.


Field Summary
protected  String[] cmdLineArgs
           
protected  org.apache.hadoop.conf.Configuration conf
           
protected static int EXIT_FAILURE
           
protected static int EXIT_SUCCESS
           
 
Constructor Summary
AbstractHBaseTool()
           
 
Method Summary
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 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()
           
protected  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 abstract  void processOptions(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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXIT_SUCCESS

protected static final int EXIT_SUCCESS
See Also:
Constant Field Values

EXIT_FAILURE

protected static final int EXIT_FAILURE
See Also:
Constant Field Values

conf

protected org.apache.hadoop.conf.Configuration conf

cmdLineArgs

protected String[] cmdLineArgs
Constructor Detail

AbstractHBaseTool

public AbstractHBaseTool()
Method Detail

addOptions

protected abstract void addOptions()
Override this to add command-line options using addOptWithArg(java.lang.String, java.lang.String) and similar methods.


processOptions

protected abstract void processOptions(org.apache.commons.cli.CommandLine cmd)
This method is called to process the options after they have been parsed.


doWork

protected abstract int doWork()
                       throws Exception
The "main function" of the tool

Throws:
Exception

getConf

public org.apache.hadoop.conf.Configuration getConf()
Specified by:
getConf in interface org.apache.hadoop.conf.Configurable

setConf

public void setConf(org.apache.hadoop.conf.Configuration conf)
Specified by:
setConf in interface org.apache.hadoop.conf.Configurable

run

public final int run(String[] args)
              throws IOException
Specified by:
run in interface org.apache.hadoop.util.Tool
Throws:
IOException

parseArgs

protected org.apache.commons.cli.CommandLine parseArgs(String[] args)
                                                throws org.apache.commons.cli.ParseException
Throws:
org.apache.commons.cli.ParseException

printUsage

protected void printUsage()

printUsage

protected void printUsage(String usageStr,
                          String usageHeader,
                          String usageFooter)

addRequiredOptWithArg

protected void addRequiredOptWithArg(String opt,
                                     String description)

addRequiredOptWithArg

protected void addRequiredOptWithArg(String shortOpt,
                                     String longOpt,
                                     String description)

addOptNoArg

protected void addOptNoArg(String opt,
                           String description)

addOptNoArg

protected void addOptNoArg(String shortOpt,
                           String longOpt,
                           String description)

addOptWithArg

protected void addOptWithArg(String opt,
                             String description)

addOptWithArg

protected void addOptWithArg(String shortOpt,
                             String longOpt,
                             String description)

parseLong

public static long parseLong(String s,
                             long minValue,
                             long maxValue)
Parse a number and enforce a range.


parseInt

public static int parseInt(String s,
                           int minValue,
                           int maxValue)

doStaticMain

protected void doStaticMain(String[] args)
Call this from the concrete tool class's main function.



Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.