You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Haoming Zhang <ha...@outlook.com> on 2015/02/19 22:03:59 UTC

How to get Hadoop's Generic Options value

Hi,

 


        As you know, Hadoop support the Generic Options. For example you can use "-files" to specify files to be copied to the map reduce cluster.




But how to get the value of Generic Options? For example, I have a command that is :



  hadoop jar job.jar JobClass -files
  /home/MapReduce/testFile.json input output



I'm using the generic option "-files", and the value of 
this option is "/home/MapReduce/testFile.json", so how can I get this 
value?




I tried GenericOptionsParser class like this:


String option = new GenericOptionsParser(conf, args).getCommandLine().getOptionValue("files");

But the result was NULL. I also changed the parameter of .getOptionValue() to "-files", got NULL as well.




And I also tried the code like this:


String[] toolArgs = new GenericOptionsParser(conf, args).getRemainingArgs();

But the above code only get all the remaining command options other 
than the generic options, that is the contrary of my expectation.


Any suggestion will be great appreciated!


Thanks,
Haoming



     		 	   		  

Re: How to get Hadoop's Generic Options value

Posted by Rajesh Kartha <ka...@gmail.com>.
Here is an example:
https://adhoop.wordpress.com/2012/02/16/generate-a-list-of-anagrams-round-3/

-Rajesh

On Thu, Feb 19, 2015 at 9:32 PM, Haoming Zhang <ha...@outlook.com>
wrote:

> Thanks guys,
>
> I will try your solutions later and update the result!
>
> ------------------------------
> From: unmeshabiju@gmail.com
> Date: Fri, 20 Feb 2015 10:04:38 +0530
> Subject: Re: How to get Hadoop's Generic Options value
> To: user@hadoop.apache.org
>
>
> Try implementing your program
>
> public class YourDriver extends Configured implements Tool {
>
> main()
> run()
> }
>
> Then supply your file using -D option.
>
> Thanks
> Unmesha Biju
>
>
>

Re: How to get Hadoop's Generic Options value

Posted by Rajesh Kartha <ka...@gmail.com>.
Here is an example:
https://adhoop.wordpress.com/2012/02/16/generate-a-list-of-anagrams-round-3/

-Rajesh

On Thu, Feb 19, 2015 at 9:32 PM, Haoming Zhang <ha...@outlook.com>
wrote:

> Thanks guys,
>
> I will try your solutions later and update the result!
>
> ------------------------------
> From: unmeshabiju@gmail.com
> Date: Fri, 20 Feb 2015 10:04:38 +0530
> Subject: Re: How to get Hadoop's Generic Options value
> To: user@hadoop.apache.org
>
>
> Try implementing your program
>
> public class YourDriver extends Configured implements Tool {
>
> main()
> run()
> }
>
> Then supply your file using -D option.
>
> Thanks
> Unmesha Biju
>
>
>

Re: How to get Hadoop's Generic Options value

Posted by Rajesh Kartha <ka...@gmail.com>.
Here is an example:
https://adhoop.wordpress.com/2012/02/16/generate-a-list-of-anagrams-round-3/

-Rajesh

On Thu, Feb 19, 2015 at 9:32 PM, Haoming Zhang <ha...@outlook.com>
wrote:

> Thanks guys,
>
> I will try your solutions later and update the result!
>
> ------------------------------
> From: unmeshabiju@gmail.com
> Date: Fri, 20 Feb 2015 10:04:38 +0530
> Subject: Re: How to get Hadoop's Generic Options value
> To: user@hadoop.apache.org
>
>
> Try implementing your program
>
> public class YourDriver extends Configured implements Tool {
>
> main()
> run()
> }
>
> Then supply your file using -D option.
>
> Thanks
> Unmesha Biju
>
>
>

Re: How to get Hadoop's Generic Options value

Posted by Rajesh Kartha <ka...@gmail.com>.
Here is an example:
https://adhoop.wordpress.com/2012/02/16/generate-a-list-of-anagrams-round-3/

-Rajesh

On Thu, Feb 19, 2015 at 9:32 PM, Haoming Zhang <ha...@outlook.com>
wrote:

> Thanks guys,
>
> I will try your solutions later and update the result!
>
> ------------------------------
> From: unmeshabiju@gmail.com
> Date: Fri, 20 Feb 2015 10:04:38 +0530
> Subject: Re: How to get Hadoop's Generic Options value
> To: user@hadoop.apache.org
>
>
> Try implementing your program
>
> public class YourDriver extends Configured implements Tool {
>
> main()
> run()
> }
>
> Then supply your file using -D option.
>
> Thanks
> Unmesha Biju
>
>
>

RE: How to get Hadoop's Generic Options value

Posted by Haoming Zhang <ha...@outlook.com>.
Thanks guys,

I will try your solutions later and update the result!

From: unmeshabiju@gmail.com
Date: Fri, 20 Feb 2015 10:04:38 +0530
Subject: Re: How to get Hadoop's Generic Options value
To: user@hadoop.apache.org

Try implementing your program 
public class YourDriver extends Configured implements Tool {

main()run()}
Then supply your file using -D option.
ThanksUnmesha Biju


 		 	   		  

RE: How to get Hadoop's Generic Options value

Posted by Haoming Zhang <ha...@outlook.com>.
Thanks guys,

I will try your solutions later and update the result!

From: unmeshabiju@gmail.com
Date: Fri, 20 Feb 2015 10:04:38 +0530
Subject: Re: How to get Hadoop's Generic Options value
To: user@hadoop.apache.org

Try implementing your program 
public class YourDriver extends Configured implements Tool {

main()run()}
Then supply your file using -D option.
ThanksUnmesha Biju


 		 	   		  

RE: How to get Hadoop's Generic Options value

Posted by Haoming Zhang <ha...@outlook.com>.
Thanks guys,

I will try your solutions later and update the result!

From: unmeshabiju@gmail.com
Date: Fri, 20 Feb 2015 10:04:38 +0530
Subject: Re: How to get Hadoop's Generic Options value
To: user@hadoop.apache.org

Try implementing your program 
public class YourDriver extends Configured implements Tool {

main()run()}
Then supply your file using -D option.
ThanksUnmesha Biju


 		 	   		  

RE: How to get Hadoop's Generic Options value

Posted by Haoming Zhang <ha...@outlook.com>.
Thanks guys,

I will try your solutions later and update the result!

From: unmeshabiju@gmail.com
Date: Fri, 20 Feb 2015 10:04:38 +0530
Subject: Re: How to get Hadoop's Generic Options value
To: user@hadoop.apache.org

Try implementing your program 
public class YourDriver extends Configured implements Tool {

main()run()}
Then supply your file using -D option.
ThanksUnmesha Biju


 		 	   		  

Re: How to get Hadoop's Generic Options value

Posted by unmesha sreeveni <un...@gmail.com>.
Try implementing your program

public class YourDriver extends Configured implements Tool {

main()
run()
}

Then supply your file using -D option.

Thanks
Unmesha Biju

Re: How to get Hadoop's Generic Options value

Posted by unmesha sreeveni <un...@gmail.com>.
Try implementing your program

public class YourDriver extends Configured implements Tool {

main()
run()
}

Then supply your file using -D option.

Thanks
Unmesha Biju

Re: How to get Hadoop's Generic Options value

Posted by unmesha sreeveni <un...@gmail.com>.
Try implementing your program

public class YourDriver extends Configured implements Tool {

main()
run()
}

Then supply your file using -D option.

Thanks
Unmesha Biju

Re: How to get Hadoop's Generic Options value

Posted by unmesha sreeveni <un...@gmail.com>.
Try implementing your program

public class YourDriver extends Configured implements Tool {

main()
run()
}

Then supply your file using -D option.

Thanks
Unmesha Biju

Re: How to get Hadoop's Generic Options value

Posted by 杨浩 <ya...@gmail.com>.
why not trying
>
>   -D files=/home/MapReduce/testFile.json


2015-02-20 5:03 GMT+08:00 Haoming Zhang <ha...@outlook.com>:

> Hi,
>
>
> As you know, Hadoop support the Generic Options
> <http://hadoop.apache.org/docs/r1.2.1/commands_manual.html#Generic+Options>.
> For example you can use "-files" to specify files to be copied to the map
> reduce cluster.
>
>
> But how to get the value of Generic Options? For example, I have a command
> that is :
>
> hadoop jar job.jar JobClass -files /home/MapReduce/testFile.json input
> output
>
> I'm using the generic option "-files", and the value of this option is
> "/home/MapReduce/testFile.json", so how can I get this value?
>
>
> I tried GenericOptionsParser
> <http://hadoop.apache.org/docs/r1.2.1/api/org/apache/hadoop/util/GenericOptionsParser.html>
> class like this:
>
> String option = new GenericOptionsParser(conf, args).getCommandLine().getOptionValue("files");
>
> But the result was NULL. I also changed the parameter of .getOptionValue()
> to "-files", got NULL as well.
>
>
> And I also tried the code like this:
>
> String[] toolArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
>
> But the above code only get all the remaining command options other than
> the generic options, that is the contrary of my expectation.
>
>
> Any suggestion will be great appreciated!
>
>
> Thanks,
> Haoming
>
>

Re: How to get Hadoop's Generic Options value

Posted by 杨浩 <ya...@gmail.com>.
why not trying
>
>   -D files=/home/MapReduce/testFile.json


2015-02-20 5:03 GMT+08:00 Haoming Zhang <ha...@outlook.com>:

> Hi,
>
>
> As you know, Hadoop support the Generic Options
> <http://hadoop.apache.org/docs/r1.2.1/commands_manual.html#Generic+Options>.
> For example you can use "-files" to specify files to be copied to the map
> reduce cluster.
>
>
> But how to get the value of Generic Options? For example, I have a command
> that is :
>
> hadoop jar job.jar JobClass -files /home/MapReduce/testFile.json input
> output
>
> I'm using the generic option "-files", and the value of this option is
> "/home/MapReduce/testFile.json", so how can I get this value?
>
>
> I tried GenericOptionsParser
> <http://hadoop.apache.org/docs/r1.2.1/api/org/apache/hadoop/util/GenericOptionsParser.html>
> class like this:
>
> String option = new GenericOptionsParser(conf, args).getCommandLine().getOptionValue("files");
>
> But the result was NULL. I also changed the parameter of .getOptionValue()
> to "-files", got NULL as well.
>
>
> And I also tried the code like this:
>
> String[] toolArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
>
> But the above code only get all the remaining command options other than
> the generic options, that is the contrary of my expectation.
>
>
> Any suggestion will be great appreciated!
>
>
> Thanks,
> Haoming
>
>

Re: How to get Hadoop's Generic Options value

Posted by 杨浩 <ya...@gmail.com>.
why not trying
>
>   -D files=/home/MapReduce/testFile.json


2015-02-20 5:03 GMT+08:00 Haoming Zhang <ha...@outlook.com>:

> Hi,
>
>
> As you know, Hadoop support the Generic Options
> <http://hadoop.apache.org/docs/r1.2.1/commands_manual.html#Generic+Options>.
> For example you can use "-files" to specify files to be copied to the map
> reduce cluster.
>
>
> But how to get the value of Generic Options? For example, I have a command
> that is :
>
> hadoop jar job.jar JobClass -files /home/MapReduce/testFile.json input
> output
>
> I'm using the generic option "-files", and the value of this option is
> "/home/MapReduce/testFile.json", so how can I get this value?
>
>
> I tried GenericOptionsParser
> <http://hadoop.apache.org/docs/r1.2.1/api/org/apache/hadoop/util/GenericOptionsParser.html>
> class like this:
>
> String option = new GenericOptionsParser(conf, args).getCommandLine().getOptionValue("files");
>
> But the result was NULL. I also changed the parameter of .getOptionValue()
> to "-files", got NULL as well.
>
>
> And I also tried the code like this:
>
> String[] toolArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
>
> But the above code only get all the remaining command options other than
> the generic options, that is the contrary of my expectation.
>
>
> Any suggestion will be great appreciated!
>
>
> Thanks,
> Haoming
>
>

Re: How to get Hadoop's Generic Options value

Posted by 杨浩 <ya...@gmail.com>.
why not trying
>
>   -D files=/home/MapReduce/testFile.json


2015-02-20 5:03 GMT+08:00 Haoming Zhang <ha...@outlook.com>:

> Hi,
>
>
> As you know, Hadoop support the Generic Options
> <http://hadoop.apache.org/docs/r1.2.1/commands_manual.html#Generic+Options>.
> For example you can use "-files" to specify files to be copied to the map
> reduce cluster.
>
>
> But how to get the value of Generic Options? For example, I have a command
> that is :
>
> hadoop jar job.jar JobClass -files /home/MapReduce/testFile.json input
> output
>
> I'm using the generic option "-files", and the value of this option is
> "/home/MapReduce/testFile.json", so how can I get this value?
>
>
> I tried GenericOptionsParser
> <http://hadoop.apache.org/docs/r1.2.1/api/org/apache/hadoop/util/GenericOptionsParser.html>
> class like this:
>
> String option = new GenericOptionsParser(conf, args).getCommandLine().getOptionValue("files");
>
> But the result was NULL. I also changed the parameter of .getOptionValue()
> to "-files", got NULL as well.
>
>
> And I also tried the code like this:
>
> String[] toolArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
>
> But the above code only get all the remaining command options other than
> the generic options, that is the contrary of my expectation.
>
>
> Any suggestion will be great appreciated!
>
>
> Thanks,
> Haoming
>
>