@Test public void testCreateDirectories() throws IOException { conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077"); String dirA = new File(testDir, "dirA").getPath(); String dirB = new File(dirA, "dirB").getPath(); String dirC = new File(testDir, "dirC").getPath(); Path pathC = new Path(dirC); FsPermission permDirC = new FsPermission((short)0710); localFs.mkdir(pathC, null, true); localFs.setPermission(pathC, permDirC); String[] dirs = { dirA, dirB, dirC }; DirectoryCollection dc = new DirectoryCollection(dirs, conf.getFloat( YarnConfiguration.NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE, YarnConfiguration.DEFAULT_NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE)); FsPermission defaultPerm = FsPermission.getDefault() .applyUMask(new FsPermission((short)FsPermission.DEFAULT_UMASK)); boolean createResult = dc.createNonExistentDirs(localFs, defaultPerm); Assert.assertTrue(createResult); FileStatus status = localFs.getFileStatus(new Path(dirA)); Assert.assertEquals("local dir parent not created with proper permissions", defaultPerm, status.getPermission()); status = localFs.getFileStatus(new Path(dirB)); Assert.assertEquals("local dir not created with proper permissions", defaultPerm, status.getPermission()); status = localFs.getFileStatus(pathC); Assert.assertEquals("existing local directory permissions modified", permDirC, status.getPermission()); }
synchronized boolean createNonExistentDirs(FileContext localFs, FsPermission perm) { boolean failed = false; for (final String dir : localDirs) { try { createDir(localFs, new Path(dir), perm); } catch (IOException e) { LOG.warn("Unable to create directory " + dir + " error " + e.getMessage() + ", removing from the list of valid directories."); localDirs.remove(dir); errorDirs.add(dir); numFailures++; failed = true; } } return !failed; }
DirectoryCollection { synchronized boolean createNonExistentDirs(FileContext localFs, FsPermission perm) { boolean failed = false; for (final String dir : localDirs) { try { createDir(localFs, new Path(dir), perm); } catch (IOException e) { LOG.warn("Unable to create directory " + dir + " error " + e.getMessage() + ", removing from the list of valid directories."); localDirs.remove(dir); errorDirs.add(dir); numFailures++; failed = true; } } return !failed; } }
DirectoryCollection { synchronized boolean createNonExistentDirs(FileContext localFs, FsPermission perm) { boolean failed = false; for (final String dir : localDirs) { try { createDir(localFs, new Path(dir), perm); } catch (IOException e) { LOG.warn("Unable to create directory " + dir + " error " + e.getMessage() + ", removing from the list of valid directories."); localDirs.remove(dir); errorDirs.add(dir); numFailures++; failed = true; } } return !failed; } DirectoryCollection(String[] dirs);  DirectoryCollection(String[] dirs, float utilizationPercentageCutOff);  DirectoryCollection(String[] dirs, long utilizationSpaceCutOff);  DirectoryCollection(String[] dirs, 
      float utilizationPercentageCutOff,
      long utilizationSpaceCutOff); }
DirectoryCollection { synchronized boolean createNonExistentDirs(FileContext localFs, FsPermission perm) { boolean failed = false; for (final String dir : localDirs) { try { createDir(localFs, new Path(dir), perm); } catch (IOException e) { LOG.warn("Unable to create directory " + dir + " error " + e.getMessage() + ", removing from the list of valid directories."); localDirs.remove(dir); errorDirs.add(dir); numFailures++; failed = true; } } return !failed; } DirectoryCollection(String[] dirs);  DirectoryCollection(String[] dirs, float utilizationPercentageCutOff);  DirectoryCollection(String[] dirs, long utilizationSpaceCutOff);  DirectoryCollection(String[] dirs, 
      float utilizationPercentageCutOff,
      long utilizationSpaceCutOff); float getDiskUtilizationPercentageCutoff(); void setDiskUtilizationPercentageCutoff(
      float diskUtilizationPercentageCutoff); long getDiskUtilizationSpaceCutoff(); void setDiskUtilizationSpaceCutoff(long diskUtilizationSpaceCutoff); int getGoodDirsDiskUtilizationPercentage(); }
DirectoryCollection { synchronized boolean createNonExistentDirs(FileContext localFs, FsPermission perm) { boolean failed = false; for (final String dir : localDirs) { try { createDir(localFs, new Path(dir), perm); } catch (IOException e) { LOG.warn("Unable to create directory " + dir + " error " + e.getMessage() + ", removing from the list of valid directories."); localDirs.remove(dir); errorDirs.add(dir); numFailures++; failed = true; } } return !failed; } DirectoryCollection(String[] dirs);  DirectoryCollection(String[] dirs, float utilizationPercentageCutOff);  DirectoryCollection(String[] dirs, long utilizationSpaceCutOff);  DirectoryCollection(String[] dirs, 
      float utilizationPercentageCutOff,
      long utilizationSpaceCutOff); float getDiskUtilizationPercentageCutoff(); void setDiskUtilizationPercentageCutoff(
      float diskUtilizationPercentageCutoff); long getDiskUtilizationSpaceCutoff(); void setDiskUtilizationSpaceCutoff(long diskUtilizationSpaceCutoff); int getGoodDirsDiskUtilizationPercentage();  }