/// <exception cref="System.IO.IOException"/> public virtual LogParams GetLogFilePath(JobID oldJobID, TaskAttemptID oldTaskAttemptID ) { JobId jobId = TypeConverter.ToYarn(oldJobID); GetJobReportRequest request = recordFactory.NewRecordInstance <GetJobReportRequest >(); request.SetJobId(jobId); JobReport report = ((GetJobReportResponse)Invoke("getJobReport", typeof(GetJobReportRequest ), request)).GetJobReport(); if (EnumSet.Of(JobState.Succeeded, JobState.Failed, JobState.Killed, JobState.Error ).Contains(report.GetJobState())) { if (oldTaskAttemptID != null) { GetTaskAttemptReportRequest taRequest = recordFactory.NewRecordInstance <GetTaskAttemptReportRequest >(); taRequest.SetTaskAttemptId(TypeConverter.ToYarn(oldTaskAttemptID)); TaskAttemptReport taReport = ((GetTaskAttemptReportResponse)Invoke("getTaskAttemptReport" , typeof(GetTaskAttemptReportRequest), taRequest)).GetTaskAttemptReport(); if (taReport.GetContainerId() == null || taReport.GetNodeManagerHost() == null) { throw new IOException("Unable to get log information for task: " + oldTaskAttemptID ); } return(new LogParams(taReport.GetContainerId().ToString(), taReport.GetContainerId ().GetApplicationAttemptId().GetApplicationId().ToString(), NodeId.NewInstance(taReport .GetNodeManagerHost(), taReport.GetNodeManagerPort()).ToString(), report.GetUser ())); } else { if (report.GetAMInfos() == null || report.GetAMInfos().Count == 0) { throw new IOException("Unable to get log information for job: " + oldJobID); } AMInfo amInfo = report.GetAMInfos()[report.GetAMInfos().Count - 1]; return(new LogParams(amInfo.GetContainerId().ToString(), amInfo.GetAppAttemptId() .GetApplicationId().ToString(), NodeId.NewInstance(amInfo.GetNodeManagerHost(), amInfo.GetNodeManagerPort()).ToString(), report.GetUser())); } } else { throw new IOException("Cannot get log path for a in-progress job"); } }
private void VerifyTaskAttemptReport(TaskAttemptReport tar) { NUnit.Framework.Assert.AreEqual(TaskAttemptState.Running, tar.GetTaskAttemptState ()); NUnit.Framework.Assert.IsNotNull("TaskAttemptReport is null", tar); NUnit.Framework.Assert.AreEqual(MRApp.NmHost, tar.GetNodeManagerHost()); NUnit.Framework.Assert.AreEqual(MRApp.NmPort, tar.GetNodeManagerPort()); NUnit.Framework.Assert.AreEqual(MRApp.NmHttpPort, tar.GetNodeManagerHttpPort()); NUnit.Framework.Assert.AreEqual(1, tar.GetContainerId().GetApplicationAttemptId() .GetAttemptId()); }
public TaskAttemptInfo(TaskAttempt ta, TaskType type, bool isRunning) { TaskAttemptReport report = ta.GetReport(); this.type = type.ToString(); this.id = MRApps.ToString(ta.GetID()); this.nodeHttpAddress = ta.GetNodeHttpAddress(); this.startTime = report.GetStartTime(); this.finishTime = report.GetFinishTime(); this.assignedContainerId = ConverterUtils.ToString(report.GetContainerId()); this.assignedContainer = report.GetContainerId(); this.progress = report.GetProgress() * 100; this.status = report.GetStateString(); this.state = report.GetTaskAttemptState(); this.elapsedTime = Times.Elapsed(this.startTime, this.finishTime, isRunning); if (this.elapsedTime == -1) { this.elapsedTime = 0; } this.diagnostics = report.GetDiagnosticInfo(); this.rack = ta.GetNodeRackName(); }
public virtual void TestAttemptsBlock() { AppContext ctx = Org.Mockito.Mockito.Mock <AppContext>(); AppForTest app = new AppForTest(ctx); Task task = GetTask(0); IDictionary <TaskAttemptId, TaskAttempt> attempts = new Dictionary <TaskAttemptId, TaskAttempt>(); TaskAttempt attempt = Org.Mockito.Mockito.Mock <TaskAttempt>(); TaskAttemptId taId = new TaskAttemptIdPBImpl(); taId.SetId(0); taId.SetTaskId(task.GetID()); Org.Mockito.Mockito.When(attempt.GetID()).ThenReturn(taId); Org.Mockito.Mockito.When(attempt.GetNodeHttpAddress()).ThenReturn("Node address"); ApplicationId appId = ApplicationIdPBImpl.NewInstance(0, 5); ApplicationAttemptId appAttemptId = ApplicationAttemptIdPBImpl.NewInstance(appId, 1); ContainerId containerId = ContainerIdPBImpl.NewContainerId(appAttemptId, 1); Org.Mockito.Mockito.When(attempt.GetAssignedContainerID()).ThenReturn(containerId ); Org.Mockito.Mockito.When(attempt.GetAssignedContainerMgrAddress()).ThenReturn("assignedContainerMgrAddress" ); Org.Mockito.Mockito.When(attempt.GetNodeRackName()).ThenReturn("nodeRackName"); long taStartTime = 100002L; long taFinishTime = 100012L; long taShuffleFinishTime = 100010L; long taSortFinishTime = 100011L; TaskAttemptState taState = TaskAttemptState.Succeeded; Org.Mockito.Mockito.When(attempt.GetLaunchTime()).ThenReturn(taStartTime); Org.Mockito.Mockito.When(attempt.GetFinishTime()).ThenReturn(taFinishTime); Org.Mockito.Mockito.When(attempt.GetShuffleFinishTime()).ThenReturn(taShuffleFinishTime ); Org.Mockito.Mockito.When(attempt.GetSortFinishTime()).ThenReturn(taSortFinishTime ); Org.Mockito.Mockito.When(attempt.GetState()).ThenReturn(taState); TaskAttemptReport taReport = Org.Mockito.Mockito.Mock <TaskAttemptReport>(); Org.Mockito.Mockito.When(taReport.GetStartTime()).ThenReturn(taStartTime); Org.Mockito.Mockito.When(taReport.GetFinishTime()).ThenReturn(taFinishTime); Org.Mockito.Mockito.When(taReport.GetShuffleFinishTime()).ThenReturn(taShuffleFinishTime ); Org.Mockito.Mockito.When(taReport.GetSortFinishTime()).ThenReturn(taSortFinishTime ); Org.Mockito.Mockito.When(taReport.GetContainerId()).ThenReturn(containerId); Org.Mockito.Mockito.When(taReport.GetProgress()).ThenReturn(1.0f); Org.Mockito.Mockito.When(taReport.GetStateString()).ThenReturn("Processed 128/128 records <p> \n" ); Org.Mockito.Mockito.When(taReport.GetTaskAttemptState()).ThenReturn(taState); Org.Mockito.Mockito.When(taReport.GetDiagnosticInfo()).ThenReturn(string.Empty); Org.Mockito.Mockito.When(attempt.GetReport()).ThenReturn(taReport); attempts[taId] = attempt; Org.Mockito.Mockito.When(task.GetAttempts()).ThenReturn(attempts); app.SetTask(task); Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = Org.Mockito.Mockito.Mock <Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job >(); Org.Mockito.Mockito.When(job.GetUserName()).ThenReturn("User"); app.SetJob(job); TestBlocks.AttemptsBlockForTest block = new TestBlocks.AttemptsBlockForTest(this, app); block.AddParameter(AMParams.TaskType, "r"); PrintWriter pWriter = new PrintWriter(data); HtmlBlock.Block html = new BlockForTest(new TestBlocks.HtmlBlockForTest(this), pWriter , 0, false); block.Render(html); pWriter.Flush(); // should be printed information about attempts NUnit.Framework.Assert.IsTrue(data.ToString().Contains("0 attempt_0_0001_r_000000_0" )); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("SUCCEEDED")); NUnit.Framework.Assert.IsFalse(data.ToString().Contains("Processed 128/128 records <p> \n" )); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("Processed 128\\/128 records <p> \\n" )); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("_0005_01_000001:attempt_0_0001_r_000000_0:User:"******"100002")); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("100010")); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("100011")); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("100012")); }