我试图在EMR中使用Amazon s3存储。然而,当我目前运行我的代码,我得到多个错误,如使用亚马逊s3作为输入,输出并在EMR地图中存储中间结果reduce作业
java.lang.IllegalArgumentException: This file system object (hdfs://10.254.37.109:9000) does not support access to the request path 's3n://energydata/input/centers_200_10k_norm.csv' You possibly called FileSystem.get(conf) when you should have called FileSystem.get(uri, conf) to obtain a file system supporting your path.
at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:384)
at org.apache.hadoop.hdfs.DistributedFileSystem.getPathName(DistributedFileSystem.java:129)
at org.apache.hadoop.hdfs.DistributedFileSystem.open(DistributedFileSystem.java:154)
at org.apache.hadoop.fs.FileSystem.open(FileSystem.java:429)
at edu.stanford.cs246.hw2.KMeans$CentroidMapper.setup(KMeans.java:112)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:142)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:771)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:375)
at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1132)
at org.apache.hadoop.mapred.Child.main(Child.java:249)
在主要我这样设置我的输入和输出路径,我把S3N:在配置CFILE //energydata/input/centers_200_10k_norm.csv我检索映射器和减速机:
FileSystem fs = FileSystem.get(conf);
conf.set(CFILE, inPath); //inPath in this case is s3n://energydata/input/centers_200_10k_norm.csv
FileInputFormat.addInputPath(job, new Path(inputDir));
FileOutputFormat.setOutputPath(job, new Path(outputDir));
,我尝试访问CFILE其中上述错误发生在我的映射器和减速机的具体例子(S3N://energydata/input/centers_200_10k_norm.csv)。这是我尝试获取路径:
FileSystem fs = FileSystem.get(context.getConfiguration());
Path cFile = new Path(context.getConfiguration().get(CFILE));
DataInputStream d = new DataInputStream(fs.open(cFile)); ---->Error
S3N://energydata/input/centers_200_10k_norm.csv是输入参数的程序之一,当我开始了我的EMR的工作,我指定我的输入和输出目录是s3n:// energydata /输入和s3n:// energydata /输出
我试着做什么在file path in hdfs建议,但我仍然得到错误。任何帮助,将不胜感激。
谢谢!
谢谢。我实际上通过使用下面的代码来修复它:uriStr =“s3n:// energydata/output /”; URI uri = URI.create(uriStr); FileSystem fs = FileSystem.get(uri,context.getConfiguration()); (c.File));如果我们使用了一个新的DataInputStream,那么我们就可以使用这个方法来创建一个新的DataInputStream对象。 – 2013-04-29 16:35:21
是的 - 这也是一个类似的修复。主要的是在OP中,文件系统句柄是默认的句柄。 Path.getFileSystem或FileSystem.get(path,conf)获取特定路径的文件系统 – 2013-04-30 01:42:07