【问题标题】:Unable to create file using Pail DFS无法使用 Pail DFS 创建文件
【发布时间】:2015-08-29 17:08:03
【问题描述】:

这里是新手。尝试使用 Pail 运行 Nathan Marz 的书 Big Data DFS Datastore 中的代码。我究竟做错了什么?尝试连接到 HDFS 虚拟机。尝试用文件替换 hdfs。任何帮助表示赞赏。

public class AppTest
{
    private App app = new App();
    private String path = "hdfs:////192.168.0.101:8080/mypail";

    @Before
    public void init() throws IllegalArgumentException, IOException{
        FileSystem fs = FileSystem.get(new Configuration());
        fs.delete(new Path(path), true);
    }

    @Test public    void testAppAccess() throws IOException{
        Pail pail = Pail.create(path);
          TypedRecordOutputStream os = pail.openWrite();
          os.writeObject(new byte[] {1, 2, 3});
          os.writeObject(new byte[] {1, 2, 3, 4});
          os.writeObject(new byte[] {1, 2, 3, 4, 5});
          os.close();   
   }
}

得到一个错误 -

java.lang.IllegalArgumentException: Wrong FS: hdfs:/192.168.0.101:8080/mypail, expected: file:///
    at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:645)
    at org.apache.hadoop.fs.RawLocalFileSystem.pathToFile(RawLocalFileSystem.java:80)
    at org.apache.hadoop.fs.RawLocalFileSystem.deprecatedGetFileStatus(RawLocalFileSystem.java:529)
    at org.apache.hadoop.fs.RawLocalFileSystem.getFileLinkStatusInternal(RawLocalFileSystem.java:747)

关于将 HDFS 替换为 file:///

java.io.IOException: Mkdirs failed to create file:/192.168.0.101:8080/mypail (exists=false, cwd=file:/Users/joshi/git/projectcsr/projectcsr)
    at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:442)
    at 

【问题讨论】:

    标签: hdfs lambda-architecture


    【解决方案1】:

    我遇到了同样的问题,我解决了!您应该将您的 core-site.xml 添加到 hadoop Configuration 对象,这样应该可以工作:

    Configuration cfg = new Configuration();
    Path core_site_path = new Path("path/to/your/core-site.xml");
    cfg.addResource(core_site_path);
    FileSystem fs = FileSystem.get(cfg);
    

    我想您也可以通过编程方式将属性 fs.defaultFS 添加到 cfg 对象中

    来源: http://opensourceconnections.com/blog/2013/03/24/hdfs-debugging-wrong-fs-expected-file-exception/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-28
      • 2017-07-27
      • 1970-01-01
      • 2016-10-07
      • 2010-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多