Hadoop使用Java以递归方式将fsPermission设置为dir

Ume*_*cha 4 java hadoop hdfs

嗨,我有测试程序,在这个路径上将文件加载到hdfs user/user1/data/app/type/file.gz现在这个测试程序由多个用户多次运行.所以我想将文件权限设置为rwx,以便任何人都可以删除此文件.我有以下代码

fs.setPermission(new Path("user/user1/data"),new FsPermission(FsAction.ALL,FsAction.ALL,FsAction.ALL)) 
Run Code Online (Sandbox Code Playgroud)

上面的行给drwxrwxrwx了所有目录,但是对于file.gz它给出了许可,-rw-r--r--为什么呢?由于这个原因,除了我之外的另一个用户无法通过测试程序删除此文件.我可以通过测试程序删除文件,因为我有充分的感情.

请指导.我是Hadoop的新手.提前致谢.

Ume*_*cha 8

使用FsShell API解决了我的dir权限问题.它可能不是最佳方式,但因为我正在为测试代码解决它应该没问题.

      FsShell shell=new FsShell(conf);
      try {
        shell.run(new String[]{"-chmod","-R","777","user/usr1/data"});
      }
     catch (  Exception e) {
        LOG.error("Couldnt change the file permissions ",e);
        throw new IOException(e);
      }
Run Code Online (Sandbox Code Playgroud)