public virtual void TestCreateDirectories()
        {
            conf.Set(CommonConfigurationKeys.FsPermissionsUmaskKey, "077");
            string       dirA     = new FilePath(testDir, "dirA").GetPath();
            string       dirB     = new FilePath(dirA, "dirB").GetPath();
            string       dirC     = new FilePath(testDir, "dirC").GetPath();
            Path         pathC    = new Path(dirC);
            FsPermission permDirC = new FsPermission((short)0x1c8);

            localFs.Mkdir(pathC, null, true);
            localFs.SetPermission(pathC, permDirC);
            string[]            dirs = new string[] { dirA, dirB, dirC };
            DirectoryCollection dc   = new DirectoryCollection(dirs, conf.GetFloat(YarnConfiguration
                                                                                   .NmMaxPerDiskUtilizationPercentage, YarnConfiguration.DefaultNmMaxPerDiskUtilizationPercentage
                                                                                   ));
            FsPermission defaultPerm = FsPermission.GetDefault().ApplyUMask(new FsPermission(
                                                                                (short)FsPermission.DefaultUmask));
            bool createResult = dc.CreateNonExistentDirs(localFs, defaultPerm);

            NUnit.Framework.Assert.IsTrue(createResult);
            FileStatus status = localFs.GetFileStatus(new Path(dirA));

            NUnit.Framework.Assert.AreEqual("local dir parent not created with proper permissions"
                                            , defaultPerm, status.GetPermission());
            status = localFs.GetFileStatus(new Path(dirB));
            NUnit.Framework.Assert.AreEqual("local dir not created with proper permissions",
                                            defaultPerm, status.GetPermission());
            status = localFs.GetFileStatus(pathC);
            NUnit.Framework.Assert.AreEqual("existing local directory permissions modified",
                                            permDirC, status.GetPermission());
        }
        /// <summary>Method which initializes the timertask and its interval time.</summary>
        /// <exception cref="System.Exception"/>
        protected override void ServiceInit(Configuration config)
        {
            // Clone the configuration as we may do modifications to dirs-list
            Configuration conf = new Configuration(config);

            diskHealthCheckInterval = conf.GetLong(YarnConfiguration.NmDiskHealthCheckIntervalMs
                                                   , YarnConfiguration.DefaultNmDiskHealthCheckIntervalMs);
            monitoringTimerTask        = new LocalDirsHandlerService.MonitoringTimerTask(this, conf);
            isDiskHealthCheckerEnabled = conf.GetBoolean(YarnConfiguration.NmDiskHealthCheckEnable
                                                         , true);
            minNeededHealthyDisksFactor = conf.GetFloat(YarnConfiguration.NmMinHealthyDisksFraction
                                                        , YarnConfiguration.DefaultNmMinHealthyDisksFraction);
            lastDisksCheckTime = Runtime.CurrentTimeMillis();
            base.ServiceInit(conf);
            FileContext localFs;

            try
            {
                localFs = FileContext.GetLocalFSFileContext(config);
            }
            catch (IOException e)
            {
                throw new YarnRuntimeException("Unable to get the local filesystem", e);
            }
            FsPermission perm            = new FsPermission((short)0x1ed);
            bool         createSucceeded = localDirs.CreateNonExistentDirs(localFs, perm);

            createSucceeded &= logDirs.CreateNonExistentDirs(localFs, perm);
            if (!createSucceeded)
            {
                UpdateDirsAfterTest();
            }
            // Check the disk health immediately to weed out bad directories
            // before other init code attempts to use them.
            CheckDirs();
        }