Java Code Examples for org.apache.hadoop.fs.permission.FsPermission#equals()

The following examples show how to use org.apache.hadoop.fs.permission.FsPermission#equals() . 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: 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 2
Source File: LogAggregationService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void createDir(FileSystem fs, Path path, FsPermission fsPerm)
    throws IOException {
  FsPermission dirPerm = new FsPermission(fsPerm);
  fs.mkdirs(path, dirPerm);
  FsPermission umask = FsPermission.getUMask(fs.getConf());
  if (!dirPerm.equals(dirPerm.applyUMask(umask))) {
    fs.setPermission(path, new FsPermission(fsPerm));
  }
}
 
Example 3
Source File: DockerContainerExecutor.java    From hadoop with Apache License 2.0 5 votes vote down vote up
protected void createDir(Path dirPath, FsPermission perms,
                         boolean createParent, String user) 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: DefaultContainerExecutor.java    From hadoop with Apache License 2.0 5 votes vote down vote up
protected void createDir(Path dirPath, FsPermission perms,
    boolean createParent, String user) throws IOException {
  lfs.mkdir(dirPath, perms, createParent);
  if (!perms.equals(perms.applyUMask(lfs.getUMask()))) {
    lfs.setPermission(dirPath, perms);
  }
}
 
Example 6
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 7
Source File: LogAggregationService.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void createDir(FileSystem fs, Path path, FsPermission fsPerm)
    throws IOException {
  FsPermission dirPerm = new FsPermission(fsPerm);
  fs.mkdirs(path, dirPerm);
  FsPermission umask = FsPermission.getUMask(fs.getConf());
  if (!dirPerm.equals(dirPerm.applyUMask(umask))) {
    fs.setPermission(path, new FsPermission(fsPerm));
  }
}
 
Example 8
Source File: DockerContainerExecutor.java    From big-c with Apache License 2.0 5 votes vote down vote up
protected void createDir(Path dirPath, FsPermission perms,
                         boolean createParent, String user) throws IOException {
  lfs.mkdir(dirPath, perms, createParent);
  if (!perms.equals(perms.applyUMask(lfs.getUMask()))) {
    lfs.setPermission(dirPath, perms);
  }
}
 
Example 9
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);
    }
  }
}
 
Example 10
Source File: DefaultContainerExecutor.java    From big-c with Apache License 2.0 5 votes vote down vote up
protected void createDir(Path dirPath, FsPermission perms,
    boolean createParent, String user) throws IOException {
  lfs.mkdir(dirPath, perms, createParent);
  if (!perms.equals(perms.applyUMask(lfs.getUMask()))) {
    lfs.setPermission(dirPath, perms);
  }
}
 
Example 11
Source File: MasterFileSystem.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure the directories under rootDir have good permissions. Create if necessary.
 * @param p
 * @throws IOException
 */
private void checkSubDir(final Path p, final String dirPermsConfName) throws IOException {
  FileSystem fs = p.getFileSystem(conf);
  FsPermission dirPerms = new FsPermission(conf.get(dirPermsConfName, "700"));
  if (!fs.exists(p)) {
    if (isSecurityEnabled) {
      if (!fs.mkdirs(p, secureRootSubDirPerms)) {
        throw new IOException("HBase directory '" + p + "' creation failure.");
      }
    } else {
      if (!fs.mkdirs(p)) {
        throw new IOException("HBase directory '" + p + "' creation failure.");
      }
    }
  }
  else {
    if (isSecurityEnabled && !dirPerms.equals(fs.getFileStatus(p).getPermission())) {
      // check whether the permission match
      LOG.warn("Found HBase directory permissions NOT matching expected permissions for "
          + p.toString() + " permissions=" + fs.getFileStatus(p).getPermission()
          + ", expecting " + dirPerms + ". Automatically setting the permissions. "
          + "You can change the permissions by setting \"" + dirPermsConfName + "\" in hbase-site.xml "
          + "and restarting the master");
      fs.setPermission(p, dirPerms);
    }
  }
}
 
Example 12
Source File: FSDownload.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void createDir(Path path, FsPermission perm) throws IOException {
  files.mkdir(path, perm, false);
  if (!perm.equals(files.getUMask().applyUMask(perm))) {
    files.setPermission(path, perm);
  }
}
 
Example 13
Source File: FSDownload.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void createDir(Path path, FsPermission perm) throws IOException {
  files.mkdir(path, perm, false);
  if (!perm.equals(files.getUMask().applyUMask(perm))) {
    files.setPermission(path, perm);
  }
}