public virtual void TestRecovery()
        {
            FilePath[] localLogDirs       = GetLocalLogDirFiles(this.GetType().FullName, 2);
            string     localLogDirsString = localLogDirs[0].GetAbsolutePath() + "," + localLogDirs
                                            [1].GetAbsolutePath();

            conf.Set(YarnConfiguration.NmLogDirs, localLogDirsString);
            conf.SetBoolean(YarnConfiguration.LogAggregationEnabled, false);
            conf.SetLong(YarnConfiguration.NmLogRetainSeconds, YarnConfiguration.DefaultNmLogRetainSeconds
                         );
            dirsHandler.Init(conf);
            NMStateStoreService stateStore = new NMMemoryStateStoreService();

            stateStore.Init(conf);
            stateStore.Start();
            TestNonAggregatingLogHandler.NonAggregatingLogHandlerWithMockExecutor logHandler =
                new TestNonAggregatingLogHandler.NonAggregatingLogHandlerWithMockExecutor(this,
                                                                                          dispatcher, mockDelService, dirsHandler, stateStore);
            logHandler.Init(conf);
            logHandler.Start();
            logHandler.Handle(new LogHandlerAppStartedEvent(appId, user, null, ContainerLogsRetentionPolicy
                                                            .AllContainers, null));
            logHandler.Handle(new LogHandlerContainerFinishedEvent(container11, 0));
            logHandler.Handle(new LogHandlerAppFinishedEvent(appId));
            // simulate a restart and verify deletion is rescheduled
            logHandler.Close();
            logHandler = new TestNonAggregatingLogHandler.NonAggregatingLogHandlerWithMockExecutor
                             (this, dispatcher, mockDelService, dirsHandler, stateStore);
            logHandler.Init(conf);
            logHandler.Start();
            ArgumentCaptor <Runnable> schedArg = ArgumentCaptor.ForClass <Runnable>();

            Org.Mockito.Mockito.Verify(logHandler.mockSched).Schedule(schedArg.Capture(), Matchers.AnyLong
                                                                          (), Matchers.Eq(TimeUnit.Milliseconds));
            // execute the runnable and verify another restart has nothing scheduled
            schedArg.GetValue().Run();
            logHandler.Close();
            logHandler = new TestNonAggregatingLogHandler.NonAggregatingLogHandlerWithMockExecutor
                             (this, dispatcher, mockDelService, dirsHandler, stateStore);
            logHandler.Init(conf);
            logHandler.Start();
            Org.Mockito.Mockito.Verify(logHandler.mockSched, Org.Mockito.Mockito.Never()).Schedule
                (Matchers.Any <Runnable>(), Matchers.AnyLong(), Matchers.Any <TimeUnit>());
            logHandler.Close();
        }
        public virtual void TestDelayedDelete()
        {
            FilePath[] localLogDirs       = GetLocalLogDirFiles(this.GetType().FullName, 2);
            string     localLogDirsString = localLogDirs[0].GetAbsolutePath() + "," + localLogDirs
                                            [1].GetAbsolutePath();

            conf.Set(YarnConfiguration.NmLogDirs, localLogDirsString);
            conf.SetBoolean(YarnConfiguration.LogAggregationEnabled, false);
            conf.SetLong(YarnConfiguration.NmLogRetainSeconds, YarnConfiguration.DefaultNmLogRetainSeconds
                         );
            dirsHandler.Init(conf);
            NonAggregatingLogHandler logHandler = new TestNonAggregatingLogHandler.NonAggregatingLogHandlerWithMockExecutor
                                                      (this, dispatcher, mockDelService, dirsHandler);

            logHandler.Init(conf);
            logHandler.Start();
            logHandler.Handle(new LogHandlerAppStartedEvent(appId, user, null, ContainerLogsRetentionPolicy
                                                            .AllContainers, null));
            logHandler.Handle(new LogHandlerContainerFinishedEvent(container11, 0));
            logHandler.Handle(new LogHandlerAppFinishedEvent(appId));
            Path[] localAppLogDirs = new Path[2];
            localAppLogDirs[0] = new Path(localLogDirs[0].GetAbsolutePath(), appId.ToString()
                                          );
            localAppLogDirs[1] = new Path(localLogDirs[1].GetAbsolutePath(), appId.ToString()
                                          );
            ScheduledThreadPoolExecutor mockSched = ((TestNonAggregatingLogHandler.NonAggregatingLogHandlerWithMockExecutor
                                                      )logHandler).mockSched;

            Org.Mockito.Mockito.Verify(mockSched).Schedule(Matchers.Any <Runnable>(), Matchers.Eq
                                                               (10800l), Matchers.Eq(TimeUnit.Seconds));
            logHandler.Close();
            for (int i = 0; i < localLogDirs.Length; i++)
            {
                FileUtils.DeleteDirectory(localLogDirs[i]);
            }
        }