private void ConstructTaskAttemptCompletionEvents() { LoadAllTasks(); completionEvents = new List <TaskAttemptCompletionEvent>(); IList <TaskAttempt> allTaskAttempts = new List <TaskAttempt>(); int numMapAttempts = 0; foreach (KeyValuePair <TaskId, Task> taskEntry in tasks) { Task task = taskEntry.Value; foreach (KeyValuePair <TaskAttemptId, TaskAttempt> taskAttemptEntry in task.GetAttempts ()) { TaskAttempt taskAttempt = taskAttemptEntry.Value; allTaskAttempts.AddItem(taskAttempt); if (task.GetType() == TaskType.Map) { ++numMapAttempts; } } } allTaskAttempts.Sort(new _IComparer_237()); mapCompletionEvents = new AList <TaskAttemptCompletionEvent>(numMapAttempts); int eventId = 0; foreach (TaskAttempt taskAttempt_1 in allTaskAttempts) { TaskAttemptCompletionEvent tace = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <TaskAttemptCompletionEvent >(); int attemptRunTime = -1; if (taskAttempt_1.GetLaunchTime() != 0 && taskAttempt_1.GetFinishTime() != 0) { attemptRunTime = (int)(taskAttempt_1.GetFinishTime() - taskAttempt_1.GetLaunchTime ()); } // Default to KILLED TaskAttemptCompletionEventStatus taceStatus = TaskAttemptCompletionEventStatus.Killed; string taStateString = taskAttempt_1.GetState().ToString(); try { taceStatus = TaskAttemptCompletionEventStatus.ValueOf(taStateString); } catch (Exception) { Log.Warn("Cannot constuct TACEStatus from TaskAtemptState: [" + taStateString + "] for taskAttemptId: [" + taskAttempt_1.GetID() + "]. Defaulting to KILLED"); } tace.SetAttemptId(taskAttempt_1.GetID()); tace.SetAttemptRunTime(attemptRunTime); tace.SetEventId(eventId++); tace.SetMapOutputServerAddress(taskAttempt_1.GetAssignedContainerMgrAddress()); tace.SetStatus(taceStatus); completionEvents.AddItem(tace); if (taskAttempt_1.GetID().GetTaskId().GetTaskType() == TaskType.Map) { mapCompletionEvents.AddItem(tace); } } }
private static TaskAttemptCompletionEvent CreateTce(int eventId, bool isMap, TaskAttemptCompletionEventStatus status) { JobId jid = MRBuilderUtils.NewJobId(12345, 1, 1); TaskId tid = MRBuilderUtils.NewTaskId(jid, 0, isMap ? TaskType.Map : TaskType.Reduce ); TaskAttemptId attemptId = MRBuilderUtils.NewTaskAttemptId(tid, 0); RecordFactory recordFactory = RecordFactoryProvider.GetRecordFactory(null); TaskAttemptCompletionEvent tce = recordFactory.NewRecordInstance <TaskAttemptCompletionEvent >(); tce.SetEventId(eventId); tce.SetAttemptId(attemptId); tce.SetStatus(status); return(tce); }