Ejemplo n.º 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");
     }
 }
Ejemplo n.º 2
0
 public virtual Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job GetFullJob(JobId jobId)
 {
     if (Log.IsDebugEnabled())
     {
         Log.Debug("Looking for Job " + jobId);
     }
     try
     {
         HistoryFileManager.HistoryFileInfo         fileInfo = hsManager.GetFileInfo(jobId);
         Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job result   = null;
         if (fileInfo != null)
         {
             result = loadedJobCache[jobId];
             if (result == null)
             {
                 result = LoadJob(fileInfo);
             }
             else
             {
                 if (fileInfo.IsDeleted())
                 {
                     Sharpen.Collections.Remove(loadedJobCache, jobId);
                     result = null;
                 }
             }
         }
         else
         {
             Sharpen.Collections.Remove(loadedJobCache, jobId);
         }
         return(result);
     }
     catch (IOException e)
     {
         throw new YarnRuntimeException(e);
     }
 }