[英]Hadoop Map Reduce - Read HDFS File - FileAlreadyExists error
[英]Is not possible write from the map to hadoop file system (HDFS)
我正在尝试直接从mapper在hadoop文件系统中编写纯文本文件。
我这样做如下:
public void createFile(Configuration conf) throws IOException{
FileSystem fs = FileSystem.get(conf);
Path filenamePath = new Path(conf.get("mapred.output.dir")+"/_"+conf.get("mapred.task.id"), "tree.txt");
try {
if (fs.exists(filenamePath)) {
// remove the file first
fs.delete(filenamePath);
}
FSDataOutputStream out = fs.create(filenamePath);
out.writeUTF("hello, world!");
out.close();
} catch (IOException ioe) {
System.err.println("IOException during operation: " + ioe.toString());
System.exit(1);
}
}
而且它不会在伪分布式模式下写入任何内容。 但是,在独立环境中写得很完美。
问题出在哪儿?
我正在使用Amazon Elastic MapReduce(EMR),并且必须通过URI获取FileSystem才能使用S3中的文件。
FileSystem fs = FileSystem.get(uri, conf);
那可能对您没有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.