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

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  org.apache.hadoop.conf.Configuration conf
           
 
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 addOptWithArg(String opt, String description)
           
protected  void addRequiredOptWithArg(String opt, 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()
           
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 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

conf

protected org.apache.hadoop.conf.Configuration conf
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

addRequiredOptWithArg

protected void addRequiredOptWithArg(String opt,
                                     String description)

addOptNoArg

protected void addOptNoArg(String opt,
                           String description)

addOptWithArg

protected void addOptWithArg(String opt,
                             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 © 2013 The Apache Software Foundation. All Rights Reserved.