无法使用spring hadoop连接到远程hdfs

时间:2016-04-14 15:35:52

标签: spring hadoop hdfs

我刚从Hadoop开始,我试图通过Spring Hadoop从远程hdfs(docker容器中的远程hdfs,可从localhost:32783访问)读取但是我收到以下错误:

org.springframework.data.hadoop.HadoopException: 
Cannot list resources Failed on local exception: 
java.io.EOFException; Host Details : local host is: "user/127.0.1.1";    
destination host is: "localhost":32783;

我正试图使用​​以下代码阅读文件:

    HdfsClient hdfsClient = new HdfsClient();

    Configuration conf = new Configuration();
    conf.set("fs.defaultFS","hdfs://localhost:32783");
    FileSystem fs = FileSystem.get(conf);
    SimplerFileSystem sFs = new SimplerFileSystem(fs);
    hdfsClient.setsFs(sFs);

    String filePath = "/tmp/tmpTestReadTest.txt";
    String output = hdfsClient.readFile(filePath);

hdfsClient.readFile(filePath)的作用如下:

public class HdfsClient {

        private SimplerFileSystem sFs;

        public String readFile(String filePath) throws IOException {

            FSDataInputStream inputStream = this.sFs.open(filePath);
            output =  getStringFromInputStream(inputStream.getWrappedStream());
            inputStream.close();
        }

        return output;
}

有什么猜测为什么我无法从远程hdfs读取?删除conf.set(" fs.defaultFS"," hdfs:// localhost:32783");我可以阅读,但只能从本地文件路径。

我理解" hdfs:// localhost:32783"是正确的,因为通过随机uri更改它会导致连接拒绝错误

我的hadoop配置有什么问题吗?

谢谢!

0 个答案:

没有答案