コード例 #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
 public virtual void RefreshJobRetentionSettings()
 {
     if (GetServiceState() == Service.STATE.Started)
     {
         conf = CreateConf();
         long maxHistoryAge = conf.GetLong(JHAdminConfig.MrHistoryMaxAgeMs, JHAdminConfig.
                                           DefaultMrHistoryMaxAge);
         hsManager.SetMaxHistoryAge(maxHistoryAge);
         if (futureHistoryCleaner != null)
         {
             futureHistoryCleaner.Cancel(false);
         }
         futureHistoryCleaner = null;
         ScheduleHistoryCleaner();
     }
     else
     {
         Log.Warn("Failed to execute refreshJobRetentionSettings : Job History service is not started"
                  );
     }
 }