You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Arun C Murthy (JIRA)" <ji...@apache.org> on 2007/05/24 00:01:16 UTC

[jira] Created: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

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
            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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Raghu Angadi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498728 ] 

Raghu Angadi commented on HADOOP-1425:
--------------------------------------

I think ToolBase should/need not be a base class. No subclass extends or add any functionality. I think all we need is a utility method that  that invokes parseArgs() in ToolBase. Then, any one who wants to process args in a consistent way can use the utility, instead of having to be a subclass.


> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Raghu Angadi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498735 ] 

Raghu Angadi commented on HADOOP-1425:
--------------------------------------

When I had to use it, main problem was that it requires a subclass to implement {{run()}}. I don't see how requiring {{run()}} is anyway related to what ToolBase does. Requiring {{run()}} expects a certain structure to subclass.

All its interesting funcionality is implemented in {{static private}} members, which certainly says something about a class. At least we should make {{parseGeneralOptions()}} public. Then users won't be forced to subclass to get its functionality.


> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498824 ] 

Doug Cutting commented on HADOOP-1425:
--------------------------------------

> The problem with ToolBase in my opinion is it is the wrong abstraction.

That's a little strong, I think.  It's the right abstraction for some things, but perhaps not everything.  If your class is already subclassing something else, then ToolBase may not be not right for you.  I'm sorry you have trouble remembering the difference between 'run' and 'doMain'.  Perhaps these could be better named?  Do you also find Thread#start() and Thread#run() confusing?  These are analogous with those.

> All I am recommending is to make parseGeneralOptions() public.

That's fine with me.  Still, unless a class is already subclassing something else and cannot use ToolBase, I'd rather see something like my first example above (subclassing ToolBase) than my second example above (which doesn't subclass and is more complicated).  Lines of code aren't everything, but, when all else is equal, fewer are better, no?


> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12525069 ] 

Enis Soztutar commented on HADOOP-1425:
---------------------------------------

bq. Should we also remove the deprecated ToolBase.java at this time?

I really don't like keeping deprecated code for long, but i think we can live with that for sometime. I will open an issue later for removing such code. 

> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch, example_tools_v1.1.patch
>
>
> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Raghu Angadi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498742 ] 

Raghu Angadi commented on HADOOP-1425:
--------------------------------------

bq. [...] implement run(String[]), which is passed the non-generic parameters from the command line. How would you achieve this without subclassing ToolBase [...]

Simple:
{code}
//...
  String[] myArgs = ToolBase.parseGeneralOptions(conf, cmdLine); // only change is parseGeneralOptions() is made public.
  parseArgs(myArgs);
    //....
{code}
Am I missing something obvious here?


> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499164 ] 

Doug Cutting commented on HADOOP-1425:
--------------------------------------

Enis's proposal looks good to me.  +1

> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499211 ] 

Enis Soztutar commented on HADOOP-1425:
---------------------------------------

I have created a seperate issue HADOOP-1436, for this discussion, since this issues is about examples. I think we should wait for HADOOP-1436 before this issue. 

> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Raghu Angadi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498762 ] 

Raghu Angadi commented on HADOOP-1425:
--------------------------------------

hmm.. Do you see any functional difference between above example in DFSAdmin.java and the following code?
{code}
  Configuration conf;
  Configuration getConf() { return conf;}

  public static void main(String[] argv) throws Exception {
    conf = new Confguration();
    int res = this.run( ToolBase.parseGeneralOptions(conf, argv));
    System.exit(res);
  }
{code}

I am not sure what other functionality does ToolBase give other than invoking parseGeneralOptions().

> 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.


[jira] Updated: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Enis Soztutar updated HADOOP-1425:
----------------------------------

        Fix Version/s: 0.15.0
    Affects Version/s: 0.15.0
               Status: Patch Available  (was: Open)

> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch
>
>
> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498732 ] 

Doug Cutting commented on HADOOP-1425:
--------------------------------------

ToolBase does more than parse arguments.  It also builds a Configuration.  Subclasses can use getConf() to access the configuration and must implement run(String[]), which is passed the non-generic parameters from the command line.  How would you achieve this without subclassing ToolBase and without replicating logic from ToolBase?  Also, why is it a burden to subclass ToolBase?

> 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.


[jira] Assigned: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Enis Soztutar reassigned HADOOP-1425:
-------------------------------------

    Assignee: Enis Soztutar

> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498853 ] 

Doug Cutting commented on HADOOP-1425:
--------------------------------------

Owen, your example is not equivalent.  In particular, it doesn't pass remaining command line parameters to the application, nor does it handle exeptions.

Here's an attempt at making an equivalent example in the style you seem to propose:
{code}
public class Foo {
  public static void runMyCommand(Options options) throws Exception{
     Foo foo = new Foo(Options.getConfiguration());
     ...
  }
  public static void main(String[] argv) throws Exception {
     try {
       Foo.runMyCommand(new OptionParser().parse(argv));
     } catch (Exception e) {
        System.exit(-1);
     }
  }
}
{code}

Is the problem simply that 'doMain' is poorly named?  Would the example be less confusing if things were named analagously with Thread?
{code}
public class Foo extends ToolBase {
  public run(String[] args) { ... }
  public static void main(String[] argv) throws Exception {
    System.exit(new Foo().start(argv));
  }
}
{code}
The real shame, it seems to me, is that a boilerplate static main is required.  It would be much simpler if things just implemented Tool.  But then we'd always have to run things through a framework.  It'd be 'java org.apache.hadoop.util.RunTool org.apache.hadoop.foo.FooTool ...'.  However if we adopted something like HADOOP-435, where we always used an executable jar, this could be reduced to 'java -jar hadoop.jar org.apache.hadoop.foo.FooTool ...', or, if the tool was registered, it could just be ''java -jar hadoop.jar foo ...'.  Or we could simply change bin/hadoop to always run things with RunTool, so it'd be 'bin/hadoop foo ...' as today.

> 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.


[jira] Updated: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Enis Soztutar updated HADOOP-1425:
----------------------------------

    Attachment: example_tools_v1.0.patch

> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch
>
>
> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Raghu Angadi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498832 ] 

Raghu Angadi commented on HADOOP-1425:
--------------------------------------

> Lines of code aren't everything, but, when all else is equal, fewer are better, no?

Its very hard to resist responding to this :-). I will try. 


> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Raghu Angadi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499229 ] 

Raghu Angadi commented on HADOOP-1425:
--------------------------------------

+1 for HADOOP-1436.


> 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.


[jira] Updated: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated HADOOP-1425:
---------------------------------

    Resolution: Fixed
        Status: Resolved  (was: Patch Available)

I just committed this.  Thanks, Enis!

> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch, example_tools_v1.1.patch
>
>
> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Owen O'Malley (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498807 ] 

Owen O'Malley commented on HADOOP-1425:
---------------------------------------

The problem with ToolBase in my opinion is it is the wrong abstraction. ToolBase doesn't really provide any useful ones. Using mixins (acquiring functionality via inheritance) is usually problematic and especially in Java where you can only have one parent class. This can been seen by people getting confused about where the various mains are and how they are being called. Every time, I look at one of those ToolBase-children, I need to untangle where the run() method is versus doMain() and which is which. It would be much better if was just a library that used cli or cli2 that let the application add parameters, but defined a "standard hadoop" set of options. The only downside to that approach is that it is nice to be able to handle  commonexceptions in the doMain.

> 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.


[jira] Updated: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Enis Soztutar updated HADOOP-1425:
----------------------------------

    Attachment: example_tools_v1.1.patch

Fixed javadoc warning.


> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch, example_tools_v1.1.patch
>
>
> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Arun C Murthy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498740 ] 

Arun C Murthy commented on HADOOP-1425:
---------------------------------------

I'm with Raghu on this one...

One option would add a convenience method (in Configuration.java?) to parse the generic arguments to build the Configuration  and return a String[] of the non-generic arguments... that would also solve one of my peeves with ToolBase:

$ BigMapOutput -D parameter=value -input <path> -output <path>
works, whereas:
$ BigMapOutput  -input <path> -output <path> -D parameter=value
doesnt work as expected (i.e. the config doesn't have the parameter set to the value).

> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Hadoop QA (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12525260 ] 

Hadoop QA commented on HADOOP-1425:
-----------------------------------

-1, build or testing failed

2 attempts failed to build and test the latest attachment http://issues.apache.org/jira/secure/attachment/12365165/example_tools_v1.1.patch against trunk revision r573088.

Test results:   http://lucene.zones.apache.org:8080/hudson/job/Hadoop-Patch/694/testReport/
Console output: http://lucene.zones.apache.org:8080/hudson/job/Hadoop-Patch/694/console

Please note that this message is automatically generated and may represent a problem with the automation system and not the patch.

> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch, example_tools_v1.1.patch
>
>
> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498756 ] 

Doug Cutting commented on HADOOP-1425:
--------------------------------------

> just like we create conf anywhere, new Configuration()

But the point of ToolBase is so that all command-line programs support options like -D, -conf, -fs, etc.  Your example does not support these standard options.


> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Raghu Angadi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498814 ] 

Raghu Angadi commented on HADOOP-1425:
--------------------------------------

Its not just about number of lines..  My main complaint is same as Owen's: in the current form, ToolBase is not a good abstraction.

I am not really asking for getting rid of ToolBase, if it suits well in some cases, users can use it. Its just not obvious to me. When I first saw {{doMain()}} I wondered why I need to implement {{run()}} and invoke it so indirectly.

 All I am recommending is to make parseGeneralOptions() public.


> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
    [ 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 : 

{code}
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) 
      ((Configurable)tool).setConf(conf);
    
    try {
      tool.run(args);
    }
    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);
  }
}

{code}

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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Owen O'Malley (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498833 ] 

Owen O'Malley commented on HADOOP-1425:
---------------------------------------

I would make the trivial example be:

{code}
public class Foo {
  public static void main(String[] argv) throws Exception {
     JobClient.runJob(new OptionParser().fillInConfiguration(new JobConf(), argv));
  } 
}
{code}

JobClient likely should have another method that calls System.exit with the result of the run, but that is neither here nor there. By making it a straight library, you have made the code easier to understand with well separated areas of concern. There are also easy ways to add additional parameters, etc.

> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498745 ] 

Doug Cutting commented on HADOOP-1425:
--------------------------------------

> Raghu: Am I missing something obvious here?

How did you create 'conf'?

> Arun: 'BigMapOutput -input <path> -output <path> -D parameter=value' doesnt work as expected

Then perhaps we should change ToolBase to scan and remove all -D parameters?


> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499035 ] 

Enis Soztutar commented on HADOOP-1425:
---------------------------------------

Apart from the above code, I just cannot understand the lines in ToolBase#processGeneralOptions(): 
{code}
    if (line.hasOption("conf")) {
      conf.addFinalResource(new Path(line.getOptionValue("conf")));
    }
{code}

shouldn't we create a NEW configuration object from the given option value. Let's say we have conf/hadop-default.xml and conf/hadoop-site.xml in our main code, and also we have /tmp/foo_dir/conf/hadoop-site.xml. Then running 

foo -conf /tmp/foo_dir/conf 

will populate the configuratio from all the three files : conf/hadoop-default.xml,  conf/hadoop-site.xml, and /tmp/foo_dir/conf/hadoop-site.xml. However although some of the parameters in conf/hadoop-site.xml will be overriden by /etc/foo_dir/conf/hadoo-site.xml, the parameters not listed in the latter will stay the same. Do we want such a thing? i assume the use cases for -conf option will only want parameters from the given conf directory.  



> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12524919 ] 

Doug Cutting commented on HADOOP-1425:
--------------------------------------

Should we also remove the deprecated ToolBase.java at this time?

> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch
>
>
> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Raghu Angadi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498770 ] 

Raghu Angadi commented on HADOOP-1425:
--------------------------------------

btw, ToolBase seems to have a bug where it parses argument "fs" option before "conf" option. ie, if both {{--fs}} and {{--conf}} are specified, {{fs.default.name}} in conf file takes precedence instead of configuration file. But any {{-D}} option would override corresponding values in configuration file.


> 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.


[jira] Updated: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Enis Soztutar updated HADOOP-1425:
----------------------------------

    Status: Patch Available  (was: Open)

> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch, example_tools_v1.1.patch
>
>
> 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.


[jira] Updated: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Enis Soztutar updated HADOOP-1425:
----------------------------------

    Attachment: example_tools_v1.0.patch

This patch alters all the MR examples to implement Tool/ToolRunner framework. 
Adds help massage to {{GenericOptionsParser}}. 
Updates BigMapOutput. 

> 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
>            Assignee: Enis Soztutar
>            Priority: Minor
>         Attachments: example_tools_v1.0.patch
>
>
> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Hadoop QA (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12524872 ] 

Hadoop QA commented on HADOOP-1425:
-----------------------------------

-1, new javadoc warnings

The javadoc tool appears to have generated warning messages when testing the latest attachment http://issues.apache.org/jira/secure/attachment/12365074/example_tools_v1.0.patch against trunk revision r572580.

Test results:   http://lucene.zones.apache.org:8080/hudson/job/Hadoop-Patch/676/testReport/
Console output: http://lucene.zones.apache.org:8080/hudson/job/Hadoop-Patch/676/console

Please note that this message is automatically generated and may represent a problem with the automation system and not the patch.

> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch
>
>
> 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.


[jira] Updated: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Enis Soztutar updated HADOOP-1425:
----------------------------------

    Status: Open  (was: Patch Available)

> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch, example_tools_v1.1.patch
>
>
> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Raghu Angadi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498751 ] 

Raghu Angadi commented on HADOOP-1425:
--------------------------------------

bq. How did you create 'conf'?
just like we create conf anywhere, {{new Configuration();}}, for e.g.. ToolBase does not create conf.

Actual use case in DFSAdmin.java:

{code}
  /**
   * main() has some simple utility methods.
   * @param argv Command line parameters.
   * @exception Exception if the filesystem does not exist.
   */
  public static void main(String[] argv) throws Exception {
    int res = new DFSAdmin().doMain(new Configuration(), argv);
    System.exit(res);
  }
{code}

Note that ToolBase forces the subclass to call {{doMain()}} and implement {{run()}}.




> 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.


[jira] Commented: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12498806 ] 

Doug Cutting commented on HADOOP-1425:
--------------------------------------

Oops.  You're right.  The conf was handled correctly in your examples all along.  Don't know how I missed that.  Sorry.

>  Do you see any functional difference between above example in DFSAdmin.java and the following code?

The latter has twice as many lines?  Also, you can't reference 'this' in a static method, and the config in that example is never visible to the instance.

An advantage of extending ToolBase is that it causes tools to implement the Tool interface.  If someone were ever to, e.g., implement a Hadoop command shell, then Tool#run() would be what's desired, not a static main method.  This might also simplify things like HADOOP-435, where we replace the command dispatch in bin/hadoop with Java.  Might it also be nice if you could, e.g., specify multiple commands per line, something like: 'bin/hadoop fs -cp foo bar \; job -submit my.job'?  Maybe I'm just grasping at straws now...

Why does ToolBase#doMain() take a Configuration anyway?  If we added a version of 'ToolBase#doMain(String[])' method that creates the Configuration, then tools could look as simple as:
{code}
public class Foo extends ToolBase {
  public run(String[] args) { ... }
  public static void main(String[] argv) throws Exception {
    System.exit(new Foo().doMain(argv));
  }
}
{code}
I can see no way of eliminating the boilerplate 'main' implementation.

If we don't subclass ToolBase, then the simplest I can imagine is:
{code}
public class Foo implements Tool extends Configured {
  public Foo(Configuration) { super(conf); }
  public run(String[] args) { ... }
  public static void main(String[] argv) throws Exception {
    Configuration conf = new Configuration();
    String[] options = ToolBase.parseGeneralOptions(conf, argv);
    System.exit(new Foo(conf).run(options));
  }
}
{code}
Can you make it simpler?  Note that 'implements Tool' and 'extends Configured' are not required.  If 'extends Configured' is dropped however then a 'private Configuration' field would need to be added and set in the constructor.

> 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.


[jira] Updated: (HADOOP-1425) Rework the various programs in 'examples' to extend ToolBase

Posted by "Enis Soztutar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Enis Soztutar updated HADOOP-1425:
----------------------------------

    Attachment:     (was: example_tools_v1.0.patch)

> 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
>    Affects Versions: 0.15.0
>            Reporter: Arun C Murthy
>            Assignee: Enis Soztutar
>            Priority: Minor
>             Fix For: 0.15.0
>
>         Attachments: example_tools_v1.0.patch
>
>
> 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.