【发布时间】:2014-07-18 21:00:02
【问题描述】:
我在 hadoop 中有一个文件:/home/hduser/IH/input/imageslocalpaths.txt(我已经使用 hadoop fs -ls IH/input/imageslocalpaths.txt 检查了它是否存在)。 当我跑步时:
hadoop jar IH.jar IH/input/imageslocalpaths.txt
我明白了:
Input path does not exist: hdfs://localhost:54310/user/hduser/IH%2Finput%2Fimageslocalpaths.txt
谁能告诉我如何阻止 Hadoop 将斜杠更改为 %2F 或其他解决方法?
(我已经尝试了完整路径,但 hadoop 只是将它添加到 /user/hduser 的末尾,给 /user/hduser/user/hduser... 仍然使用 %2F)。
这里请求的是我的主要内容(你想要其他位吗?)
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
Configuration conf2 = new Configuration();
conf.set("fs.defaultFS", "hdfs://localhost:54310");
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
Job job1 = new Job(conf, "MergeImages");
job1.setJarByClass(ImageHandlerMain.class);
job1.setMapperClass(BinaryFilesToHadoopSequenceFileMapper.class);
job1.setOutputKeyClass(Text.class);
job1.setOutputValueClass(BytesWritable.class);
FileInputFormat.addInputPath(job1, new Path(URLEncoder.encode(otherArgs[0],"UTF-8")));
job1.setInputFormatClass(TextInputFormat.class);
FileOutputFormat.setOutputPath(job1, new Path(URLEncoder.encode(otherArgs[1],"UTF-8"))); //put result into intermediate folder
job1.setInputFormatClass(TextInputFormat.class);
job1.setOutputFormatClass(SequenceFileOutputFormat.class);
ControlledJob cJob1 = new ControlledJob(conf);
cJob1.setJob(job1);
Job job2 = new Job(conf2,"FindDuplicates");
job2.setJarByClass(ImageHandlerMain.class);
job2.setMapperClass(ImagePHashMapper.class);
job2.setReducerClass(ImageDupsReducer.class);
job2.setOutputKeyClass(Text.class);
job2.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job2, new Path(URLEncoder.encode(otherArgs[1],"UTF-8") + "/part-r-00000")); //get the part-r-00000 file from the intermediate folder
FileOutputFormat.setOutputPath(job2, new Path(otherArgs[2])); //put result into output folder
job2.setInputFormatClass(SequenceFileInputFormat.class);
ControlledJob cJob2 = new ControlledJob(conf2);
cJob2.setJob(job2);
JobControl jobctrl = new JobControl("jobctrl");
jobctrl.addJob(cJob1);
jobctrl.addJob(cJob2);
cJob2.addDependingJob(cJob1);
jobctrl.run();
}
【问题讨论】:
-
请分享生成jar文件的java代码?