예제 #1
0
 internal CompletedTaskAttempt(TaskId taskId, JobHistoryParser.TaskAttemptInfo attemptInfo
                               )
 {
     this.attemptInfo = attemptInfo;
     this.attemptId   = TypeConverter.ToYarn(attemptInfo.GetAttemptId());
     if (attemptInfo.GetTaskStatus() != null)
     {
         this.state = TaskAttemptState.ValueOf(attemptInfo.GetTaskStatus());
     }
     else
     {
         this.state       = TaskAttemptState.Killed;
         localDiagMessage = "Attmpt state missing from History : marked as KILLED";
         diagnostics.AddItem(localDiagMessage);
     }
     if (attemptInfo.GetError() != null)
     {
         diagnostics.AddItem(attemptInfo.GetError());
     }
 }
예제 #2
0
 /// <exception cref="System.Exception"/>
 public virtual void TestHistoryParsingForFailedAttempts()
 {
     Log.Info("STARTING testHistoryParsingForFailedAttempts");
     try
     {
         Configuration conf = new Configuration();
         conf.SetClass(CommonConfigurationKeysPublic.NetTopologyNodeSwitchMappingImplKey,
                       typeof(TestJobHistoryParsing.MyResolver), typeof(DNSToSwitchMapping));
         RackResolver.Init(conf);
         MRApp app = new TestJobHistoryParsing.MRAppWithHistoryWithFailedAttempt(2, 1, 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();
         app.WaitForState(job, JobState.Succeeded);
         // make sure all events are flushed
         app.WaitForState(Service.STATE.Stopped);
         JobHistory jobHistory = new JobHistory();
         jobHistory.Init(conf);
         HistoryFileManager.HistoryFileInfo fileInfo = jobHistory.GetJobFileInfo(jobId);
         JobHistoryParser         parser;
         JobHistoryParser.JobInfo jobInfo;
         lock (fileInfo)
         {
             Path historyFilePath  = fileInfo.GetHistoryFile();
             FSDataInputStream @in = null;
             FileContext       fc  = null;
             try
             {
                 fc  = FileContext.GetFileContext(conf);
                 @in = fc.Open(fc.MakeQualified(historyFilePath));
             }
             catch (IOException ioe)
             {
                 Log.Info("Can not open history file: " + historyFilePath, ioe);
                 throw (new Exception("Can not open History File"));
             }
             parser  = new JobHistoryParser(@in);
             jobInfo = parser.Parse();
         }
         Exception parseException = parser.GetParseException();
         NUnit.Framework.Assert.IsNull("Caught an expected exception " + parseException, parseException
                                       );
         int noOffailedAttempts = 0;
         IDictionary <TaskID, JobHistoryParser.TaskInfo> allTasks = jobInfo.GetAllTasks();
         foreach (Task task in job.GetTasks().Values)
         {
             JobHistoryParser.TaskInfo taskInfo = allTasks[TypeConverter.FromYarn(task.GetID()
                                                                                  )];
             foreach (TaskAttempt taskAttempt in task.GetAttempts().Values)
             {
                 JobHistoryParser.TaskAttemptInfo taskAttemptInfo = taskInfo.GetAllTaskAttempts()[
                     TypeConverter.FromYarn((taskAttempt.GetID()))];
                 // Verify rack-name for all task attempts
                 NUnit.Framework.Assert.AreEqual("rack-name is incorrect", taskAttemptInfo.GetRackname
                                                     (), RackName);
                 if (taskAttemptInfo.GetTaskStatus().Equals("FAILED"))
                 {
                     noOffailedAttempts++;
                 }
             }
         }
         NUnit.Framework.Assert.AreEqual("No of Failed tasks doesn't match.", 2, noOffailedAttempts
                                         );
     }
     finally
     {
         Log.Info("FINISHED testHistoryParsingForFailedAttempts");
     }
 }