Exemplo n.º 1
0
 private Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job LoadJob(HistoryFileManager.HistoryFileInfo
                                                            fileInfo)
 {
     try
     {
         Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = fileInfo.LoadJob();
         if (Log.IsDebugEnabled())
         {
             Log.Debug("Adding " + job.GetID() + " to loaded job cache");
         }
         // We can clobber results here, but that should be OK, because it only
         // means that we may have two identical copies of the same job floating
         // around for a while.
         loadedJobCache[job.GetID()] = job;
         return(job);
     }
     catch (IOException e)
     {
         throw new YarnRuntimeException("Could not find/load job: " + fileInfo.GetJobId(),
                                        e);
     }
 }
Exemplo n.º 2
0
        public virtual void TestRefreshLoadedJobCache()
        {
            HistoryFileManager historyManager = Org.Mockito.Mockito.Mock <HistoryFileManager>(
                );

            jobHistory = Org.Mockito.Mockito.Spy(new JobHistory());
            Org.Mockito.Mockito.DoReturn(historyManager).When(jobHistory).CreateHistoryFileManager
                ();
            Configuration conf = new Configuration();

            // Set the cache size to 2
            conf.Set(JHAdminConfig.MrHistoryLoadedJobCacheSize, "2");
            jobHistory.Init(conf);
            jobHistory.Start();
            CachedHistoryStorage storage = Org.Mockito.Mockito.Spy((CachedHistoryStorage)jobHistory
                                                                   .GetHistoryStorage());

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job[] jobs = new Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job
                                                                [3];
            JobId[] jobIds = new JobId[3];
            for (int i = 0; i < 3; i++)
            {
                jobs[i]   = Org.Mockito.Mockito.Mock <Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job>();
                jobIds[i] = Org.Mockito.Mockito.Mock <JobId>();
                Org.Mockito.Mockito.When(jobs[i].GetID()).ThenReturn(jobIds[i]);
            }
            HistoryFileManager.HistoryFileInfo fileInfo = Org.Mockito.Mockito.Mock <HistoryFileManager.HistoryFileInfo
                                                                                    >();
            Org.Mockito.Mockito.When(historyManager.GetFileInfo(Any <JobId>())).ThenReturn(fileInfo
                                                                                           );
            Org.Mockito.Mockito.When(fileInfo.LoadJob()).ThenReturn(jobs[0]).ThenReturn(jobs[
                                                                                            1]).ThenReturn(jobs[2]);
            // getFullJob will put the job in the cache if it isn't there
            for (int i_1 = 0; i_1 < 3; i_1++)
            {
                storage.GetFullJob(jobs[i_1].GetID());
            }
            IDictionary <JobId, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job> jobCache = storage
                                                                                       .GetLoadedJobCache();

            // job0 should have been purged since cache size is 2
            NUnit.Framework.Assert.IsFalse(jobCache.Contains(jobs[0].GetID()));
            NUnit.Framework.Assert.IsTrue(jobCache.Contains(jobs[1].GetID()) && jobCache.Contains
                                              (jobs[2].GetID()));
            // Setting cache size to 3
            conf.Set(JHAdminConfig.MrHistoryLoadedJobCacheSize, "3");
            Org.Mockito.Mockito.DoReturn(conf).When(storage).CreateConf();
            Org.Mockito.Mockito.When(fileInfo.LoadJob()).ThenReturn(jobs[0]).ThenReturn(jobs[
                                                                                            1]).ThenReturn(jobs[2]);
            jobHistory.RefreshLoadedJobCache();
            for (int i_2 = 0; i_2 < 3; i_2++)
            {
                storage.GetFullJob(jobs[i_2].GetID());
            }
            jobCache = storage.GetLoadedJobCache();
            // All three jobs should be in cache since its size is now 3
            for (int i_3 = 0; i_3 < 3; i_3++)
            {
                NUnit.Framework.Assert.IsTrue(jobCache.Contains(jobs[i_3].GetID()));
            }
        }