我正在使用ToolRunner来运行我的工作
public class ToolRunner1 extends Configured implements Tool {
public static void main(String[] args) throws Exception {
System.out.println("In main");
int exitCode = ToolRunner.run(new ToolRunner1(), args);
System.exit(exitCode);
}
@Override
public int run(String [] args) throws Exception {
Configuration conf = getConf();
FileSystem fs = FileSystem.get(conf);
Path p1 = new Path(conf.get("input1")); //Receving a NULL Value
Path p2 = new Path(conf.get("input2")); //Receving a NULL Value
Path p3 = new Path(conf.get("output")); //Receving a NULL Value
if (fs.exists(p3)) {
fs.delete(p3, true);
}
Job job = new Job(conf, "ToolRunner");
job.setJarByClass(ToolRunner1.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job,p1);
FileOutputFormat.setOutputPath(job, p3);
boolean success = job.waitForCompletion(true);
return(success ? 0 : 1);
}
}我执行的命令:
hadoop jar toolru.jar -D input1=/home/sreeveni/myfiles/tab -D input2=/home/sreeveni/myfiles/tab -D output =/home/sreeveni/myfiles/OUT/Toll但得到了
Exception in thread "main" java.lang.IllegalArgumentException: Can not create a Path from a null string我做错什么了吗?请建议一下。
按照克里斯的建议编辑了,我更新了代码。并在eclipse中运行良好,当我将jar移植到集群时,它会产生相同的错误。
hadoop jar toolru.jar tool.ToolRunner1 -D input1=/home/sreeveni/myfiles/tab -D input2=/home/sreeveni/myfiles/tab -D output =/home/sreeveni/myfiles/OUT/Toll发布于 2014-05-19 05:20:28
我想你想:
Configuration conf = getConf();而不是
Configuration conf = new Configuration();发布于 2014-05-20 08:32:13
尝试这样做,而不是使用-D选项,使用命令行参数,然后使用String [] args创建路径(新路径(Args)等)。
这可能为您提供关于-D选项使用的线索(无论-D选项是否可用于用户定义的密钥值对,还是只用于添加配置(core-*.xml)级别的更改)。
你是如何在eclipse中执行的?您能给出在运行期间应用的参数(运行配置)吗?
https://stackoverflow.com/questions/23729924
复制相似问题