![](/img/trans.png)
[英]java.lang.IllegalArgumentException: Can not create a Path from a null string
[英]Can not create a Path from a null string in Hadoop
我正在使用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 IDE正常工作當我將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
我想你要:
Configuration conf = getConf();
代替
Configuration conf = new Configuration();
嘗試此操作,而不是使用-D選項,請使用命令行參數,然后使用String [] args創建路徑(新Path(args [0])等)。
這可能為您提供有關-D選項用法的線索(-D選項可用於用戶定義的鍵值對,還是僅提供該選項以添加配置(core-*。xml)級別更改)。
您如何在日食中執行? 您能否給出在運行(運行配置)期間應用的參數?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.