cli.addOption("jobconf", false,
"\"n1=v1,n2=v2,..\" Optional. Add or override a JobConf property.",
"key=val");
Parser parser = cli.createParser();
try {
CommandLine results = parser.parse(args);
JobConf conf = new JobConf();
if (results.hasOption("-conf")) {
conf.addResource(new Path((String) results.getValue("-conf")));
}
if (results.hasOption("-input")) {
conf.setInputPath(new Path((String) results.getValue("-input")));
}
if (results.hasOption("-output")) {
conf.setOutputPath(new Path((String) results.getValue("-output")));
}
if (results.hasOption("-jar")) {
conf.setJar((String) results.getValue("-jar"));
}
if (results.hasOption("-inputformat")) {
setIsJavaRecordReader(conf, true);
conf.setInputFormat(getClass(results, "-inputformat", conf,
InputFormat.class));
}
if (results.hasOption("-javareader")) {
setIsJavaRecordReader(conf, true);
}
if (results.hasOption("-map")) {
setIsJavaMapper(conf, true);
conf.setMapperClass(getClass(results, "-map", conf, Mapper.class));
}
if (results.hasOption("-partitioner")) {
conf.setPartitionerClass(getClass(results, "-partitioner", conf,
Partitioner.class));
}
if (results.hasOption("-reduce")) {
setIsJavaReducer(conf, true);
conf.setReducerClass(getClass(results, "-reduce", conf, Reducer.class));
}
if (results.hasOption("-reduces")) {
conf.setNumReduceTasks(Integer.parseInt((String)
results.getValue("-reduces")));
}
if (results.hasOption("-writer")) {
setIsJavaRecordWriter(conf, true);
conf.setOutputFormat(getClass(results, "-writer", conf,
OutputFormat.class));
}
if (results.hasOption("-program")) {
setExecutable(conf, (String) results.getValue("-program"));
}
if (results.hasOption("-jobconf")) {
String options = (String)results.getValue("-jobconf");
StringTokenizer tokenizer = new StringTokenizer(options, ",");
while (tokenizer.hasMoreTokens()) {
String keyVal = tokenizer.nextToken().trim();
String[] keyValSplit = keyVal.split("=");
conf.set(keyValSplit[0], keyValSplit[1]);