Copying files from HDFS to local file system with

2019-07-17 06:18发布

I am trying to copy files from HDFS to local filesystem for preprocessing. The below code should work according to the documentation. Although it doesn't give any error messages and the mapreduce job runs smoothly I can not see any output on my local hard drive. What do you think the problem is? Thanks.

        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();
        }

1条回答
成全新的幸福
2楼-- · 2019-07-17 07:12

Try using /user/hduser/conninput/"+value.toString() in the Path constructor instead of providing the master:54310 part. It should figure out master:54310 from the Configuration.

查看更多
登录 后发表回答