org.apache.hadoop.util
Class ToolBase

java.lang.Object
  extended by org.apache.hadoop.util.ToolBase
All Implemented Interfaces:
Configurable, Tool
Direct Known Subclasses:
CopyFiles, DFSck, DFSShell, JobClient

public abstract class ToolBase
extends Object
implements Tool

This is a base class to support generic commonad options. Generic command options allow a user to specify a namenode, a job tracker etc. Generic options supported are -conf specify an application configuration file -D use value for given property -fs specify a namenode -jt specify a job tracker The general command line syntax is bin/hadoop command [genericOptions] [commandOptions] For every tool that inherits from ToolBase, generic options are handled by ToolBase while command options are passed to the tool. Generic options handling is implemented using Common CLI. Tools that inherit from ToolBase in Hadoop are DFSShell, DFSck, JobClient, and CopyFiles. Examples using generic options are bin/hadoop dfs -fs darwin:8020 -ls /data list /data directory in dfs with namenode darwin:8020 bin/hadoop dfs -D fs.default.name=darwin:8020 -ls /data list /data directory in dfs with namenode darwin:8020 bin/hadoop dfs -conf hadoop-site.xml -ls /data list /data directory in dfs with conf specified in hadoop-site.xml bin/hadoop job -D mapred.job.tracker=darwin:50020 -submit job.xml submit a job to job tracker darwin:50020 bin/hadoop job -jt darwin:50020 -submit job.xml submit a job to job tracker darwin:50020 bin/hadoop job -jt local -submit job.xml submit a job to local runner

Author:
hairong

Field Summary
 Configuration conf
           
static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
ToolBase()
           
 
Method Summary
 void doMain(Configuration conf, String[] args)
          Work as a main program: execute a command and handle exception if any
 int executeCommand(Configuration conf, String[] args)
          Execute a command
 Configuration getConf()
          Return the configuration used by this object.
 void setConf(Configuration conf)
          Set the configuration to be used by this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.util.Tool
run
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

conf

public Configuration conf
Constructor Detail

ToolBase

public ToolBase()
Method Detail

setConf

public void setConf(Configuration conf)
Description copied from interface: Configurable
Set the configuration to be used by this object.

Specified by:
setConf in interface Configurable

getConf

public Configuration getConf()
Description copied from interface: Configurable
Return the configuration used by this object.

Specified by:
getConf in interface Configurable

executeCommand

public int executeCommand(Configuration conf,
                          String[] args)
                   throws Exception
Execute a command

Parameters:
conf - Application default configuration
args - User-specified arguments
Returns:
Exit code
Throws:
Exception

doMain

public final void doMain(Configuration conf,
                         String[] args)
Work as a main program: execute a command and handle exception if any

Parameters:
conf - Application default configuration
args - User-specified arguments


Copyright © 2006 The Apache Software Foundation