2

I want to pass multiple configuration parameters to my Hadoop job through GenericOptionsParser.

With "-D abc=xyz" I can pass one argument and able to retrieve the same from the configuration object but I am not able to pass the multiple argument.

Is it possible to pass multiple argument?If yes how?

0

3 Answers 3

4

Passed the parameters as -D color=yellow -D number=10

Had the following code in the run() method

String color = getConf().get("color");
System.out.println("color = " + color);

String number = getConf().get("number");
System.out.println("number = " + number);

The following was the o/p in the console

color = yellow
number = 10
Sign up to request clarification or add additional context in comments.

2 Comments

in this case I am getting color = yellow number = null
You might have missed something - Nija is also able to do it as mentioned in the other answer.
1

I recently ran in to this issue after upgrading from Hadoop 1.2.1 to Hadoop 2.4.1. The problem is that Hadoop's dependency on commons-cli 1.2 was being omitted due to a conflict with commons-cli 1.1 that was pulled in from Cassandra 2.0.5.

After a quick look through the source it looks like commons-cli options that have an uninitialized number of values (what Hadoop's GenericOptionsParser does) default to a limit of 1 in version 1.1 and no limit in 1.2.

I hope that helps!

Comments

0

I tested passing multiple parameters and I used the -D flag multiple times.

$HADOOP_HOME/bin/hadoop jar /path/to/my.jar -D mapred.heartbeats.in.second=80 -D mapred.map.max.attempts=2 ...`

Doing this changed the values to what I specified in the Job's configuration.

1 Comment

Actually it's the other way. According to the Hadoop - The Definitive Guide - Do not confuse setting Hadoop properties using the -D property=value option to GenericOptionsParser (and ToolRunner) with setting JVM system properties using the -Dproperty=value option to the java command. The syntax for JVM system properties does not allow any whitespace between the D and the property name, whereas GenericOptionsParser requires them to be separated by whitespace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.