【问题标题】:Copying files from HDFS to local file system with JAVA使用 JAVA 将文件从 HDFS 复制到本地文件系统
【发布时间】:2012-02-29 06:05:43
【问题描述】:

我正在尝试将文件从 HDFS 复制到本地文件系统以进行预处理。下面的代码应该根据文档工作。尽管它没有给出任何错误消息并且 mapreduce 作业运行顺利,但我在本地硬盘驱动器上看不到任何输出。你认为问题是什么?谢谢。

        try {
            Path phdfs_input = new Path("hdfs://master:54310/user/hduser/conninput/"+value.toString());
            Path plocal_input = new Path("/home/hduser/Desktop/"+avlue.toString());
            FileSystem fs = FileSystem.get(context.getConfiguration());
            fs.copyToLocalFile(phdfs_input, plocal_input);

           /* String localoutput_file = "/home/hduser/Destop/output/"+value.toString();
            String cmd1[] = {"mafia", "-mfi", ".5", "-ascii", "~/Desktop/"+value.toString(), localoutput_file };
            File mafia_dir = new File("/home/hduser/");
            ShellCommandExecutor s = new ShellCommandExecutor(cmd1, mafia_dir);*/
        } catch (Exception e) {
            e.printStackTrace();
        }

【问题讨论】:

    标签: hadoop mapreduce hdfs


    【解决方案1】:

    尝试在Path 构造函数中使用/user/hduser/conninput/"+value.toString(),而不是提供master:54310 部分。它应该从Configuration 中找出master:54310

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-24
      • 1970-01-01
      • 2015-03-28
      • 2014-08-29
      • 1970-01-01
      • 2012-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多