public static void setMode(Resource resource,
      FileSystem dfs, Path pathHadoop) throws IOException {

    if (resource.getMode() != null) {
      FsPermission permission = new FsPermission((short)Integer.parseInt(resource.getMode(), 8));
      dfs.setPermission(pathHadoop, permission);

      // Recursive
      
        // Get the list of sub-directories and files
        HashSet<String> resultSet = new HashSet<String>();
        
        if (resource.isRecursiveChmod())
          resource.fillDirectoryList(dfs, resource.getTarget(), resultSet);
        
        if(resource.isChangePermissionOnParents())
          resource.fillInParentDirectories(dfs, resource.getTarget(), resultSet);

        for (String path : resultSet) {
          dfs.setPermission(new Path(path), permission);
        }

    }
  }
Used to:
  1) copy files/directories from localFS to hadoopFs
  2) create empty
  3) download files/directories from hadoopFs to localFS
files/directories in hadoopFs
contrib/fast-hdfs-resource/src/main/java/org/apache/ambari/fast_hdfs_resource/Resource.java