private void makeDoneSubdir(Path path) throws IOException {
   try {
     doneDirFc.getFileStatus(path);
     existingDoneSubdirs.add(path);
   } catch (FileNotFoundException fnfE) {
     try {
       FsPermission fsp = new FsPermission(JobHistoryUtils.HISTORY_DONE_DIR_PERMISSION);
       doneDirFc.mkdir(path, fsp, true);
       FileStatus fsStatus = doneDirFc.getFileStatus(path);
       /* LOG.info("Perms after creating "+fsStatus.getPermission().toShort()+", Expected: "+fsp.toShort()) */
       LOG.perms_after_creating_expected(
               String.valueOf(fsStatus.getPermission().toShort()), String.valueOf(fsp.toShort()))
           .tag("methodCall")
           .info();
       if (fsStatus.getPermission().toShort() != fsp.toShort()) {
         /* LOG.info("Explicitly setting permissions to : "+fsp.toShort()+", "+fsp) */
         LOG.explicitly_setting_permissions(String.valueOf(fsp.toShort()), fsp.toString())
             .tag("methodCall")
             .info();
         doneDirFc.setPermission(path, fsp);
       }
       existingDoneSubdirs.add(path);
     } catch (FileAlreadyExistsException faeE) { // Nothing to do.
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * Changes permission of a path.
  *
  * @param path path to set permission
  * @param permission permission set to path
  * @throws IOException if the path failed to be changed permission
  */
 @Override
 public void setPermission(Path path, FsPermission permission) throws IOException {
   LOG.info("setMode({},{})", path, permission.toString());
   AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path));
   SetAttributeOptions options =
       SetAttributeOptions.defaults().setMode(new Mode(permission.toShort())).setRecursive(false);
   try {
     mFileSystem.setAttribute(uri, options);
   } catch (AlluxioException e) {
     throw new IOException(e);
   }
 }
  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()) */
        LOG.perms_after_creating_expected(
                String.valueOf(fsStatus.getPermission().toShort()), String.valueOf(fsp.toShort()))
            .tag("methodCall")
            .info();
        if (fsStatus.getPermission().toShort() != fsp.toShort()) {
          /* LOG.info("Explicitly setting permissions to : "+fsp.toShort()+", "+fsp) */
          LOG.explicitly_setting_permissions(String.valueOf(fsp.toShort()), fsp.toString())
              .tag("methodCall")
              .info();
          fc.setPermission(path, fsp);
        }
      } catch (FileAlreadyExistsException e) {
        /* LOG.info("Directory: ["+path+"] already exists.") */
        LOG.directory_already_exists(path.toString()).info();
      }
    }
  }