Java Code Examples for org.apache.hadoop.fs.FileContext#setPermission()

The following examples show how to use org.apache.hadoop.fs.FileContext#setPermission() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistoryFileManager.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private void mkdir(FileContext fc, Path path, FsPermission fsp)
    throws IOException {
  if (!fc.util().exists(path)) {
    try {
      fc.mkdir(path, fsp, true);

      FileStatus fsStatus = fc.getFileStatus(path);
      LOG.info("Perms after creating " + fsStatus.getPermission().toShort()
          + ", Expected: " + fsp.toShort());
      if (fsStatus.getPermission().toShort() != fsp.toShort()) {
        LOG.info("Explicitly setting permissions to : " + fsp.toShort()
            + ", " + fsp);
        fc.setPermission(path, fsp);
      }
    } catch (FileAlreadyExistsException e) {
      LOG.info("Directory: [" + path + "] already exists.");
    }
  }
}
 
Example 2
Source File: HistoryFileManager.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void mkdir(FileContext fc, Path path, FsPermission fsp)
    throws IOException {
  if (!fc.util().exists(path)) {
    try {
      fc.mkdir(path, fsp, true);

      FileStatus fsStatus = fc.getFileStatus(path);
      LOG.info("Perms after creating " + fsStatus.getPermission().toShort()
          + ", Expected: " + fsp.toShort());
      if (fsStatus.getPermission().toShort() != fsp.toShort()) {
        LOG.info("Explicitly setting permissions to : " + fsp.toShort()
            + ", " + fsp);
        fc.setPermission(path, fsp);
      }
    } catch (FileAlreadyExistsException e) {
      LOG.info("Directory: [" + path + "] already exists.");
    }
  }
}
 
Example 3
Source File: ContainerLocalizer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static void createDir(FileContext lfs, Path dirPath,
    FsPermission perms, boolean createParent) throws IOException {
  lfs.mkdir(dirPath, perms, createParent);
  if (!perms.equals(perms.applyUMask(lfs.getUMask()))) {
    lfs.setPermission(dirPath, perms);
  }
}
 
Example 4
Source File: DirectoryCollection.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void createDir(FileContext localFs, Path dir, FsPermission perm)
    throws IOException {
  if (dir == null) {
    return;
  }
  try {
    localFs.getFileStatus(dir);
  } catch (FileNotFoundException e) {
    createDir(localFs, dir.getParent(), perm);
    localFs.mkdir(dir, perm, false);
    if (!perm.equals(perm.applyUMask(localFs.getUMask()))) {
      localFs.setPermission(dir, perm);
    }
  }
}
 
Example 5
Source File: ContainerLocalizer.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static void createDir(FileContext lfs, Path dirPath,
    FsPermission perms, boolean createParent) throws IOException {
  lfs.mkdir(dirPath, perms, createParent);
  if (!perms.equals(perms.applyUMask(lfs.getUMask()))) {
    lfs.setPermission(dirPath, perms);
  }
}
 
Example 6
Source File: DirectoryCollection.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void createDir(FileContext localFs, Path dir, FsPermission perm)
    throws IOException {
  if (dir == null) {
    return;
  }
  try {
    localFs.getFileStatus(dir);
  } catch (FileNotFoundException e) {
    createDir(localFs, dir.getParent(), perm);
    localFs.mkdir(dir, perm, false);
    if (!perm.equals(perm.applyUMask(localFs.getUMask()))) {
      localFs.setPermission(dir, perm);
    }
  }
}