예제 #1
0
        public static TaskId NewTaskId(JobId jobId, int id, TaskType taskType)
        {
            TaskId taskId = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <TaskId>();

            taskId.SetJobId(jobId);
            taskId.SetId(id);
            taskId.SetTaskType(taskType);
            return(taskId);
        }
예제 #2
0
        public static TaskId ToYarn(TaskID id)
        {
            TaskId taskId = recordFactory.NewRecordInstance <TaskId>();

            taskId.SetId(id.GetId());
            taskId.SetTaskType(ToYarn(id.GetTaskType()));
            taskId.SetJobId(ToYarn(id.GetJobID()));
            return(taskId);
        }
예제 #3
0
        private TaskId GetNewTaskID()
        {
            TaskId taskId = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <TaskId>();

            taskId.SetId(++taskCounter);
            taskId.SetJobId(jobId);
            taskId.SetTaskType(mockTask.GetType());
            return(taskId);
        }
예제 #4
0
        public static Task NewTask(JobId jid, int i, int m, bool hasFailedTasks)
        {
            TaskId tid = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <TaskId>();

            tid.SetJobId(jid);
            tid.SetId(i);
            tid.SetTaskType(TaskTypes.Next());
            TaskReport report = NewTaskReport(tid);
            IDictionary <TaskAttemptId, TaskAttempt> attempts = NewTaskAttempts(tid, m);

            return(new _Task_370(tid, report, hasFailedTasks, attempts));
        }
예제 #5
0
        //TODO_get.set
        public virtual void TestTaskIDtoString()
        {
            TaskId tid = RecordFactoryProvider.GetRecordFactory(null).NewRecordInstance <TaskId
                                                                                         >();

            tid.SetJobId(RecordFactoryProvider.GetRecordFactory(null).NewRecordInstance <JobId
                                                                                         >());
            tid.GetJobId().SetAppId(ApplicationId.NewInstance(0, 0));
            tid.SetTaskType(TaskType.Map);
            TaskType type = tid.GetTaskType();

            System.Console.Error.WriteLine(type);
            type = TaskType.Reduce;
            System.Console.Error.WriteLine(type);
            System.Console.Error.WriteLine(tid.GetTaskType());
            NUnit.Framework.Assert.AreEqual("task_0_0000_m_000000", MRApps.ToString(tid));
            tid.SetTaskType(TaskType.Reduce);
            NUnit.Framework.Assert.AreEqual("task_0_0000_r_000000", MRApps.ToString(tid));
        }
예제 #6
0
        //Test reports of  JobHistoryServer. History server should get log files from  MRApp and read them
        /// <exception cref="System.Exception"/>
        public virtual void TestReports()
        {
            Configuration config = new Configuration();

            config.SetClass(CommonConfigurationKeysPublic.NetTopologyNodeSwitchMappingImplKey
                            , typeof(TestJobHistoryParsing.MyResolver), typeof(DNSToSwitchMapping));
            RackResolver.Init(config);
            MRApp app = new TestJobHistoryEvents.MRAppWithHistory(1, 1, true, this.GetType().
                                                                  FullName, true);

            app.Submit(config);
            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.GetContext().GetAllJobs().Values
                                                             .GetEnumerator().Next();
            app.WaitForState(job, JobState.Succeeded);
            historyServer = new JobHistoryServer();
            historyServer.Init(config);
            historyServer.Start();
            // search JobHistory  service
            JobHistory jobHistory = null;

            foreach (Org.Apache.Hadoop.Service.Service service in historyServer.GetServices())
            {
                if (service is JobHistory)
                {
                    jobHistory = (JobHistory)service;
                }
            }
            IDictionary <JobId, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job> jobs = jobHistory.
                                                                                   GetAllJobs();

            NUnit.Framework.Assert.AreEqual(1, jobs.Count);
            NUnit.Framework.Assert.AreEqual("job_0_0000", jobs.Keys.GetEnumerator().Next().ToString
                                                ());
            Task                        task           = job.GetTasks().Values.GetEnumerator().Next();
            TaskAttempt                 attempt        = task.GetAttempts().Values.GetEnumerator().Next();
            HistoryClientService        historyService = historyServer.GetClientService();
            MRClientProtocol            protocol       = historyService.GetClientHandler();
            GetTaskAttemptReportRequest gtarRequest    = recordFactory.NewRecordInstance <GetTaskAttemptReportRequest
                                                                                          >();
            // test getTaskAttemptReport
            TaskAttemptId taId = attempt.GetID();

            taId.SetTaskId(task.GetID());
            taId.GetTaskId().SetJobId(job.GetID());
            gtarRequest.SetTaskAttemptId(taId);
            GetTaskAttemptReportResponse response = protocol.GetTaskAttemptReport(gtarRequest
                                                                                  );

            NUnit.Framework.Assert.AreEqual("container_0_0000_01_000000", response.GetTaskAttemptReport
                                                ().GetContainerId().ToString());
            NUnit.Framework.Assert.IsTrue(response.GetTaskAttemptReport().GetDiagnosticInfo()
                                          .IsEmpty());
            // counters
            NUnit.Framework.Assert.IsNotNull(response.GetTaskAttemptReport().GetCounters().GetCounter
                                                 (TaskCounter.PhysicalMemoryBytes));
            NUnit.Framework.Assert.AreEqual(taId.ToString(), response.GetTaskAttemptReport().
                                            GetTaskAttemptId().ToString());
            // test getTaskReport
            GetTaskReportRequest request = recordFactory.NewRecordInstance <GetTaskReportRequest
                                                                            >();
            TaskId taskId = task.GetID();

            taskId.SetJobId(job.GetID());
            request.SetTaskId(taskId);
            GetTaskReportResponse reportResponse = protocol.GetTaskReport(request);

            NUnit.Framework.Assert.AreEqual(string.Empty, reportResponse.GetTaskReport().GetDiagnosticsList
                                                ().GetEnumerator().Next());
            // progress
            NUnit.Framework.Assert.AreEqual(1.0f, reportResponse.GetTaskReport().GetProgress(
                                                ), 0.01);
            // report has corrected taskId
            NUnit.Framework.Assert.AreEqual(taskId.ToString(), reportResponse.GetTaskReport()
                                            .GetTaskId().ToString());
            // Task state should be SUCCEEDED
            NUnit.Framework.Assert.AreEqual(TaskState.Succeeded, reportResponse.GetTaskReport
                                                ().GetTaskState());
            // For invalid jobid, throw IOException
            GetTaskReportsRequest gtreportsRequest = recordFactory.NewRecordInstance <GetTaskReportsRequest
                                                                                      >();

            gtreportsRequest.SetJobId(TypeConverter.ToYarn(JobID.ForName("job_1415730144495_0001"
                                                                         )));
            gtreportsRequest.SetTaskType(TaskType.Reduce);
            try
            {
                protocol.GetTaskReports(gtreportsRequest);
                NUnit.Framework.Assert.Fail("IOException not thrown for invalid job id");
            }
            catch (IOException)
            {
            }
            // Expected
            // test getTaskAttemptCompletionEvents
            GetTaskAttemptCompletionEventsRequest taskAttemptRequest = recordFactory.NewRecordInstance
                                                                       <GetTaskAttemptCompletionEventsRequest>();

            taskAttemptRequest.SetJobId(job.GetID());
            GetTaskAttemptCompletionEventsResponse taskAttemptCompletionEventsResponse = protocol
                                                                                         .GetTaskAttemptCompletionEvents(taskAttemptRequest);

            NUnit.Framework.Assert.AreEqual(0, taskAttemptCompletionEventsResponse.GetCompletionEventCount
                                                ());
            // test getDiagnostics
            GetDiagnosticsRequest diagnosticRequest = recordFactory.NewRecordInstance <GetDiagnosticsRequest
                                                                                       >();

            diagnosticRequest.SetTaskAttemptId(taId);
            GetDiagnosticsResponse diagnosticResponse = protocol.GetDiagnostics(diagnosticRequest
                                                                                );

            // it is strange : why one empty string ?
            NUnit.Framework.Assert.AreEqual(1, diagnosticResponse.GetDiagnosticsCount());
            NUnit.Framework.Assert.AreEqual(string.Empty, diagnosticResponse.GetDiagnostics(0
                                                                                            ));
        }