/// <exception cref="System.Exception"/>
        public virtual void TestCompletedTaskAttempt()
        {
            HistoryFileManager.HistoryFileInfo info = Org.Mockito.Mockito.Mock <HistoryFileManager.HistoryFileInfo
                                                                                >();
            Org.Mockito.Mockito.When(info.GetConfFile()).ThenReturn(fullConfPath);
            completedJob = new CompletedJob(conf, jobId, fullHistoryPath, loadTasks, "user",
                                            info, jobAclsManager);
            TaskId        mt1Id  = MRBuilderUtils.NewTaskId(jobId, 0, TaskType.Map);
            TaskId        rt1Id  = MRBuilderUtils.NewTaskId(jobId, 0, TaskType.Reduce);
            TaskAttemptId mta1Id = MRBuilderUtils.NewTaskAttemptId(mt1Id, 0);
            TaskAttemptId rta1Id = MRBuilderUtils.NewTaskAttemptId(rt1Id, 0);
            Task          mt1    = completedJob.GetTask(mt1Id);
            Task          rt1    = completedJob.GetTask(rt1Id);
            TaskAttempt   mta1   = mt1.GetAttempt(mta1Id);

            NUnit.Framework.Assert.AreEqual(TaskAttemptState.Succeeded, mta1.GetState());
            NUnit.Framework.Assert.AreEqual("localhost:45454", mta1.GetAssignedContainerMgrAddress
                                                ());
            NUnit.Framework.Assert.AreEqual("localhost:9999", mta1.GetNodeHttpAddress());
            TaskAttemptReport mta1Report = mta1.GetReport();

            NUnit.Framework.Assert.AreEqual(TaskAttemptState.Succeeded, mta1Report.GetTaskAttemptState
                                                ());
            NUnit.Framework.Assert.AreEqual("localhost", mta1Report.GetNodeManagerHost());
            NUnit.Framework.Assert.AreEqual(45454, mta1Report.GetNodeManagerPort());
            NUnit.Framework.Assert.AreEqual(9999, mta1Report.GetNodeManagerHttpPort());
            TaskAttempt rta1 = rt1.GetAttempt(rta1Id);

            NUnit.Framework.Assert.AreEqual(TaskAttemptState.Succeeded, rta1.GetState());
            NUnit.Framework.Assert.AreEqual("localhost:45454", rta1.GetAssignedContainerMgrAddress
                                                ());
            NUnit.Framework.Assert.AreEqual("localhost:9999", rta1.GetNodeHttpAddress());
            TaskAttemptReport rta1Report = rta1.GetReport();

            NUnit.Framework.Assert.AreEqual(TaskAttemptState.Succeeded, rta1Report.GetTaskAttemptState
                                                ());
            NUnit.Framework.Assert.AreEqual("localhost", rta1Report.GetNodeManagerHost());
            NUnit.Framework.Assert.AreEqual(45454, rta1Report.GetNodeManagerPort());
            NUnit.Framework.Assert.AreEqual(9999, rta1Report.GetNodeManagerHttpPort());
        }
Example #2
0
        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();
        }
Example #3
0
        public virtual void VerifyTaskAttemptGeneric(TaskAttempt ta, TaskType ttype, string
                                                     id, string state, string type, string rack, string nodeHttpAddress, string diagnostics
                                                     , string assignedContainerId, long startTime, long finishTime, long elapsedTime,
                                                     float progress)
        {
            TaskAttemptId attid     = ta.GetID();
            string        attemptId = MRApps.ToString(attid);

            WebServicesTestUtils.CheckStringMatch("id", attemptId, id);
            WebServicesTestUtils.CheckStringMatch("type", ttype.ToString(), type);
            WebServicesTestUtils.CheckStringMatch("state", ta.GetState().ToString(), state);
            WebServicesTestUtils.CheckStringMatch("rack", ta.GetNodeRackName(), rack);
            WebServicesTestUtils.CheckStringMatch("nodeHttpAddress", ta.GetNodeHttpAddress(),
                                                  nodeHttpAddress);
            string         expectDiag      = string.Empty;
            IList <string> diagnosticsList = ta.GetDiagnostics();

            if (diagnosticsList != null && !diagnostics.IsEmpty())
            {
                StringBuilder b = new StringBuilder();
                foreach (string diag in diagnosticsList)
                {
                    b.Append(diag);
                }
                expectDiag = b.ToString();
            }
            WebServicesTestUtils.CheckStringMatch("diagnostics", expectDiag, diagnostics);
            WebServicesTestUtils.CheckStringMatch("assignedContainerId", ConverterUtils.ToString
                                                      (ta.GetAssignedContainerID()), assignedContainerId);
            NUnit.Framework.Assert.AreEqual("startTime wrong", ta.GetLaunchTime(), startTime);
            NUnit.Framework.Assert.AreEqual("finishTime wrong", ta.GetFinishTime(), finishTime
                                            );
            NUnit.Framework.Assert.AreEqual("elapsedTime wrong", finishTime - startTime, elapsedTime
                                            );
            NUnit.Framework.Assert.AreEqual("progress wrong", ta.GetProgress() * 100, progress
                                            , 1e-3f);
        }
Example #4
0
        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 &lt;p&gt; \\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"));
        }