eclipse在windows上启动的java客户端无法连接到远程hadoop

zy1mlcev  于 2021-05-29  发布在  Hadoop
关注(0)|答案(0)|浏览(309)

我无法将eclipse在windows上启动的java客户端连接到远程hdfs服务器。
我的hdfs服务器运行在cloudera express 5.12.1和hadoop 2.6.0上。它在mac os上工作,但在windows上出现以下错误:

Exception in thread "main" java.io.EOFException: End of File Exception between local host is: *HOST_IP*; destination host is: *DESTINATION_IP*:8020; : java.io.EOFException; For more details see:  http://wiki.apache.org/hadoop/EOFException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

以下是我的java客户端代码:

package wordcount;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

public class Main {
    public static void main(String[] args) throws Exception {
      InsertFile();
    }

    public static void InsertFile() throws Exception
    {
        Configuration conf = new Configuration();
        conf.set("fs.defaultFS", "hdfs://niko:8020");
        FileSystem fs = FileSystem.get(conf);
        FileStatus[] fsStatus = fs.listStatus(new Path("/"));
        for(int i = 0; i < fsStatus.length; i++) {
            System.out.println(fsStatus[i].getPath().toString());
        }
    } 
}

以及我为maven使用的pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.niko</groupId>
    <artifactId>WorldCount</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <repositories>
    <repository>
      <id>cloudera</id>
      <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
    </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>2.6.0-cdh5.12.1</version>
        </dependency>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
  </dependencies>
</project>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题