コード例 #1
0
 /// <summary>test clean old history files.</summary>
 /// <remarks>
 /// test clean old history files. Files should be deleted after 1 week by
 /// default.
 /// </remarks>
 /// <exception cref="System.Exception"/>
 public virtual void TestDeleteFileInfo()
 {
     Log.Info("STARTING testDeleteFileInfo");
     try
     {
         Configuration conf = new Configuration();
         conf.SetClass(CommonConfigurationKeysPublic.NetTopologyNodeSwitchMappingImplKey,
                       typeof(TestJobHistoryParsing.MyResolver), typeof(DNSToSwitchMapping));
         RackResolver.Init(conf);
         MRApp app = new TestJobHistoryEvents.MRAppWithHistory(1, 1, true, this.GetType().
                                                               FullName, true);
         app.Submit(conf);
         Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.GetContext().GetAllJobs().Values
                                                          .GetEnumerator().Next();
         JobId jobId = job.GetID();
         app.WaitForState(job, JobState.Succeeded);
         // make sure all events are flushed
         app.WaitForState(Service.STATE.Stopped);
         HistoryFileManager hfm = new HistoryFileManager();
         hfm.Init(conf);
         HistoryFileManager.HistoryFileInfo fileInfo = hfm.GetFileInfo(jobId);
         hfm.InitExisting();
         // wait for move files form the done_intermediate directory to the gone
         // directory
         while (fileInfo.IsMovePending())
         {
             Sharpen.Thread.Sleep(300);
         }
         NUnit.Framework.Assert.IsNotNull(hfm.jobListCache.Values());
         // try to remove fileInfo
         hfm.Clean();
         // check that fileInfo does not deleted
         NUnit.Framework.Assert.IsFalse(fileInfo.IsDeleted());
         // correct live time
         hfm.SetMaxHistoryAge(-1);
         hfm.Clean();
         hfm.Stop();
         NUnit.Framework.Assert.IsTrue("Thread pool shutdown", hfm.moveToDoneExecutor.IsTerminated
                                           ());
         // should be deleted !
         NUnit.Framework.Assert.IsTrue("file should be deleted ", fileInfo.IsDeleted());
     }
     finally
     {
         Log.Info("FINISHED testDeleteFileInfo");
     }
 }
コード例 #2
0
ファイル: JobHistory.cs プロジェクト: orf53975/hadoop.net
 /// <exception cref="System.Exception"/>
 protected override void ServiceStop()
 {
     Log.Info("Stopping JobHistory");
     if (scheduledExecutor != null)
     {
         Log.Info("Stopping History Cleaner/Move To Done");
         scheduledExecutor.Shutdown();
         bool interrupted = false;
         long currentTime = Runtime.CurrentTimeMillis();
         while (!scheduledExecutor.IsShutdown() && Runtime.CurrentTimeMillis() > currentTime
                + 1000l && !interrupted)
         {
             try
             {
                 Sharpen.Thread.Sleep(20);
             }
             catch (Exception)
             {
                 interrupted = true;
             }
         }
         if (!scheduledExecutor.IsShutdown())
         {
             Log.Warn("HistoryCleanerService/move to done shutdown may not have " + "succeeded, Forcing a shutdown"
                      );
             scheduledExecutor.ShutdownNow();
         }
     }
     if (storage != null && storage is Org.Apache.Hadoop.Service.Service)
     {
         ((Org.Apache.Hadoop.Service.Service)storage).Stop();
     }
     if (hsManager != null)
     {
         hsManager.Stop();
     }
     base.ServiceStop();
 }