Exemple #1
0
        public virtual void TestFailedTransitions()
        {
            mockTask = new _MockTaskImpl_648(jobId, partition, dispatcher.GetEventHandler(),
                                             remoteJobConfFile, conf, taskAttemptListener, jobToken, credentials, clock, startCount
                                             , metrics, appContext, TaskType.Map);
            TaskId taskId = GetNewTaskID();

            ScheduleTaskAttempt(taskId);
            LaunchTaskAttempt(GetLastAttempt().GetAttemptId());
            // add three more speculative attempts
            mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType
                                                  .TAddSpecAttempt));
            LaunchTaskAttempt(GetLastAttempt().GetAttemptId());
            mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType
                                                  .TAddSpecAttempt));
            LaunchTaskAttempt(GetLastAttempt().GetAttemptId());
            mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType
                                                  .TAddSpecAttempt));
            LaunchTaskAttempt(GetLastAttempt().GetAttemptId());
            NUnit.Framework.Assert.AreEqual(4, taskAttempts.Count);
            // have the first attempt fail, verify task failed due to no retries
            TestTaskImpl.MockTaskAttemptImpl taskAttempt = taskAttempts[0];
            taskAttempt.SetState(TaskAttemptState.Failed);
            mockTask.Handle(new TaskTAttemptEvent(taskAttempt.GetAttemptId(), TaskEventType.TAttemptFailed
                                                  ));
            NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState());
            // verify task can no longer be killed
            mockTask.Handle(new TaskEvent(taskId, TaskEventType.TKill));
            NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState());
            // verify speculative doesn't launch new tasks
            mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType
                                                  .TAddSpecAttempt));
            mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType
                                                  .TAttemptLaunched));
            NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState());
            NUnit.Framework.Assert.AreEqual(4, taskAttempts.Count);
            // verify attempt events from active tasks don't knock task out of FAILED
            taskAttempt = taskAttempts[1];
            taskAttempt.SetState(TaskAttemptState.CommitPending);
            mockTask.Handle(new TaskTAttemptEvent(taskAttempt.GetAttemptId(), TaskEventType.TAttemptCommitPending
                                                  ));
            NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState());
            taskAttempt.SetState(TaskAttemptState.Failed);
            mockTask.Handle(new TaskTAttemptEvent(taskAttempt.GetAttemptId(), TaskEventType.TAttemptFailed
                                                  ));
            NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState());
            taskAttempt = taskAttempts[2];
            taskAttempt.SetState(TaskAttemptState.Succeeded);
            mockTask.Handle(new TaskTAttemptEvent(taskAttempt.GetAttemptId(), TaskEventType.TAttemptSucceeded
                                                  ));
            NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState());
            taskAttempt = taskAttempts[3];
            taskAttempt.SetState(TaskAttemptState.Killed);
            mockTask.Handle(new TaskTAttemptEvent(taskAttempt.GetAttemptId(), TaskEventType.TAttemptKilled
                                                  ));
            NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState());
        }
Exemple #2
0
        public virtual void TestCountersWithSpeculation()
        {
            mockTask = new _MockTaskImpl_715(jobId, partition, dispatcher.GetEventHandler(),
                                             remoteJobConfFile, conf, taskAttemptListener, jobToken, credentials, clock, startCount
                                             , metrics, appContext, TaskType.Map);
            TaskId taskId = GetNewTaskID();

            ScheduleTaskAttempt(taskId);
            LaunchTaskAttempt(GetLastAttempt().GetAttemptId());
            UpdateLastAttemptState(TaskAttemptState.Running);
            TestTaskImpl.MockTaskAttemptImpl baseAttempt = GetLastAttempt();
            // add a speculative attempt
            mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType
                                                  .TAddSpecAttempt));
            LaunchTaskAttempt(GetLastAttempt().GetAttemptId());
            UpdateLastAttemptState(TaskAttemptState.Running);
            TestTaskImpl.MockTaskAttemptImpl specAttempt = GetLastAttempt();
            NUnit.Framework.Assert.AreEqual(2, taskAttempts.Count);
            Counters specAttemptCounters = new Counters();
            Counter  cpuCounter          = specAttemptCounters.FindCounter(TaskCounter.CpuMilliseconds);

            cpuCounter.SetValue(1000);
            specAttempt.SetCounters(specAttemptCounters);
            // have the spec attempt succeed but second attempt at 1.0 progress as well
            CommitTaskAttempt(specAttempt.GetAttemptId());
            specAttempt.SetProgress(1.0f);
            specAttempt.SetState(TaskAttemptState.Succeeded);
            mockTask.Handle(new TaskTAttemptEvent(specAttempt.GetAttemptId(), TaskEventType.TAttemptSucceeded
                                                  ));
            NUnit.Framework.Assert.AreEqual(TaskState.Succeeded, mockTask.GetState());
            baseAttempt.SetProgress(1.0f);
            Counters taskCounters = mockTask.GetCounters();

            NUnit.Framework.Assert.AreEqual("wrong counters for task", specAttemptCounters, taskCounters
                                            );
        }