hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Enis Soztutar (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase
Date Fri, 25 May 2007 09:03:16 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498992

Enis Soztutar commented on HADOOP-1425:

i agree that it should not be necessary to subclass ToolBase to use general hadoop commands.
currently Toolbase alllows us to get the modified configuration, and get the rest of the arguments
w/o general hadoop arguments. So why not we implement HadoopCommandLineParser which takes
String[] in its constructor and have to methods to get the (modified) configuration the rest
of the arguments. 
The code will look like : 

public class HadoopCommandLineParser {
  public HadoopCommandLineParser(args) {}
  public Configuration getConf() {}
  public String[] getArgs() {}

public class ToolRunner() {
  public static void run(Tool tool, String[] args) {
    HadoopCommandLineParser parser = new HadoopCommandLineParser(args);
    //get a conf object
    Configuration conf = parser.getConf(); 
    //get the args w/o general hadoop args
    String[] toolArgs = parser.getArgs();  
    if(tool instanceof Configurable) 
    try {
    catch (Exception ex) {
      //do smt with the exception

public class Foo implements Tool, Configurable{

  public int run(String[] args) throws Exception {
    //do smt interesting
  public static void main(String[] args) {
    ToolRunner.run(new Foo(), args);


The above code shows a simple mechanism to build a tool to run the commands (namely ToolRunner),
and it also enables running the classes directly. 

Alternatively, we would also want to use cli in Foo also, so maybe we can change {{HadoopCommandLineParser#getArgs()
}} to return {{CommandLine}} instead, which also requires that we change the signitures signiture
{{ToolRunner#run(Tool, Options)}} and {{Tool#run(CommandLine)}}

> Rework the various programs in 'examples' to extend ToolBase 
> -------------------------------------------------------------
>                 Key: HADOOP-1425
>                 URL: https://issues.apache.org/jira/browse/HADOOP-1425
>             Project: Hadoop
>          Issue Type: Improvement
>          Components: examples
>            Reporter: Arun C Murthy
>         Assigned To: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.14.0
> Ensuring all 'examples' extend ToolBase will make it easy to tweak various config params
(via -D switches for e.g.) while running the programs... 

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message