Hi, I have a Hadoop program in which main() reads in some command line
args:
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf,
args).getRemainingArgs();
if (otherArgs.length != 3) {
System.err.println("Usage: subsearch <in> <out>
<pattern>");
System.exit(2);
}
FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
pattern = otherArgs[2];
....
}
Here pattern is declared as a static String class variable.
When I run the program using the local tracker, it runs fine and uses
the value of pattern. However, if I run the code in distributed mode,
I get a NullPointerException - as far as I can tell, pattern is
turning out to be null in this case.
If I hard code the value of pattern in to the code that uses it, the
program runs fine.
So my question is: if I need to use an argument, specified on the
command line, do I need to do anything special to the variable holding
it? In other words, the simple assignment
pattern = otherArgs[2];
seems to lead to an NPE when run in distributed mode.
Any pointers would be appreciated
Thanks,
-------------------------------------------------------------------
Rajarshi Guha <[email protected]>
GPG Fingerprint: D070 5427 CC5B 7938 929C DD13 66A1 922C 51E7 9E84
-------------------------------------------------------------------
Q: What's polite and works for the phone company?
A: A deferential operator.