private void ValidateCounters(Counters counters) { IEnumerator <CounterGroup> it = counters.GetEnumerator(); while (it.HasNext()) { CounterGroup group = it.Next(); Log.Info("Group " + group.GetDisplayName()); IEnumerator <Counter> itc = group.GetEnumerator(); while (itc.HasNext()) { Log.Info("Counter is " + itc.Next().GetDisplayName()); } } NUnit.Framework.Assert.AreEqual(1, counters.CountCounters()); }
public virtual void TestRedirect() { Configuration conf = new YarnConfiguration(); conf.Set(MRConfig.FrameworkName, MRConfig.YarnFrameworkName); conf.Set(YarnConfiguration.RmAddress, Rmaddress); conf.Set(JHAdminConfig.MrHistoryAddress, Hshostaddress); // Start the RM. TestClientRedirect.RMService rmService = new TestClientRedirect.RMService(this, "test" ); rmService.Init(conf); rmService.Start(); // Start the AM. TestClientRedirect.AMService amService = new TestClientRedirect.AMService(this); amService.Init(conf); amService.Start(conf); // Start the HS. TestClientRedirect.HistoryService historyService = new TestClientRedirect.HistoryService (this); historyService.Init(conf); historyService.Start(conf); Log.Info("services started"); Cluster cluster = new Cluster(conf); JobID jobID = new JobID("201103121733", 1); Counters counters = cluster.GetJob(jobID).GetCounters(); ValidateCounters(counters); NUnit.Framework.Assert.IsTrue(amContact); Log.Info("Sleeping for 5 seconds before stop for" + " the client socket to not get EOF immediately.." ); Sharpen.Thread.Sleep(5000); //bring down the AM service amService.Stop(); Log.Info("Sleeping for 5 seconds after stop for" + " the server to exit cleanly.." ); Sharpen.Thread.Sleep(5000); amRestarting = true; // Same client //results are returned from fake (not started job) counters = cluster.GetJob(jobID).GetCounters(); NUnit.Framework.Assert.AreEqual(0, counters.CountCounters()); Job job = cluster.GetJob(jobID); TaskID taskId = new TaskID(jobID, TaskType.Map, 0); TaskAttemptID tId = new TaskAttemptID(taskId, 0); //invoke all methods to check that no exception is thrown job.KillJob(); job.KillTask(tId); job.FailTask(tId); job.GetTaskCompletionEvents(0, 100); job.GetStatus(); job.GetTaskDiagnostics(tId); job.GetTaskReports(TaskType.Map); job.GetTrackingURL(); amRestarting = false; amService = new TestClientRedirect.AMService(this); amService.Init(conf); amService.Start(conf); amContact = false; //reset counters = cluster.GetJob(jobID).GetCounters(); ValidateCounters(counters); NUnit.Framework.Assert.IsTrue(amContact); // Stop the AM. It is not even restarting. So it should be treated as // completed. amService.Stop(); // Same client counters = cluster.GetJob(jobID).GetCounters(); ValidateCounters(counters); NUnit.Framework.Assert.IsTrue(hsContact); rmService.Stop(); historyService.Stop(); }