public virtual void TestJobHistoryEventHandlerIsFirstServiceToStop() { MRApp app = new TestJobHistoryEvents.MRAppWithSpecialHistoryHandler(1, 0, true, this .GetType().FullName, true); Configuration conf = new Configuration(); app.Init(conf); Org.Apache.Hadoop.Service.Service[] services = Sharpen.Collections.ToArray(app.GetServices (), new Org.Apache.Hadoop.Service.Service[0]); // Verifying that it is the last to be added is same as verifying that it is // the first to be stopped. CompositeService related tests already validate // this. NUnit.Framework.Assert.AreEqual("JobHistoryEventHandler", services[services.Length - 1].GetName()); }
public virtual void TestEventsFlushOnStop() { Configuration conf = new Configuration(); MRApp app = new TestJobHistoryEvents.MRAppWithSpecialHistoryHandler(1, 0, 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(); Log.Info("JOBID is " + TypeConverter.FromYarn(jobId).ToString()); app.WaitForState(job, JobState.Succeeded); // make sure all events are flushed app.WaitForState(Service.STATE.Stopped); /* * Use HistoryContext to read logged events and verify the number of * completed maps */ HistoryContext context = new JobHistory(); ((JobHistory)context).Init(conf); Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job parsedJob = context.GetJob(jobId); NUnit.Framework.Assert.AreEqual("CompletedMaps not correct", 1, parsedJob.GetCompletedMaps ()); IDictionary <TaskId, Task> tasks = parsedJob.GetTasks(); NUnit.Framework.Assert.AreEqual("No of tasks not correct", 1, tasks.Count); VerifyTask(tasks.Values.GetEnumerator().Next()); IDictionary <TaskId, Task> maps = parsedJob.GetTasks(TaskType.Map); NUnit.Framework.Assert.AreEqual("No of maps not correct", 1, maps.Count); NUnit.Framework.Assert.AreEqual("Job state not currect", JobState.Succeeded, parsedJob .GetState()); }