Exemple #1
0
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 public virtual void VerifyHsTaskAttempt(JSONObject info, TaskAttempt att, TaskType
                                         ttype)
 {
     if (ttype == TaskType.Reduce)
     {
         NUnit.Framework.Assert.AreEqual("incorrect number of elements", 17, info.Length()
                                         );
     }
     else
     {
         NUnit.Framework.Assert.AreEqual("incorrect number of elements", 12, info.Length()
                                         );
     }
     VerifyTaskAttemptGeneric(att, ttype, info.GetString("id"), info.GetString("state"
                                                                               ), info.GetString("type"), info.GetString("rack"), info.GetString("nodeHttpAddress"
                                                                                                                                                 ), info.GetString("diagnostics"), info.GetString("assignedContainerId"), info.GetLong
                                  ("startTime"), info.GetLong("finishTime"), info.GetLong("elapsedTime"), (float)info
                              .GetDouble("progress"));
     if (ttype == TaskType.Reduce)
     {
         VerifyReduceTaskAttemptGeneric(att, info.GetLong("shuffleFinishTime"), info.GetLong
                                            ("mergeFinishTime"), info.GetLong("elapsedShuffleTime"), info.GetLong("elapsedMergeTime"
                                                                                                                  ), info.GetLong("elapsedReduceTime"));
     }
 }
Exemple #2
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        public virtual void VerifyHsJobTaskAttemptCounters(JSONObject info, TaskAttempt att
                                                           )
        {
            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 2, info.Length());
            WebServicesTestUtils.CheckStringMatch("id", MRApps.ToString(att.GetID()), info.GetString
                                                      ("id"));
            // just do simple verification of fields - not data is correct
            // in the fields
            JSONArray counterGroups = info.GetJSONArray("taskAttemptCounterGroup");

            for (int i = 0; i < counterGroups.Length(); i++)
            {
                JSONObject counterGroup = counterGroups.GetJSONObject(i);
                string     name         = counterGroup.GetString("counterGroupName");
                NUnit.Framework.Assert.IsTrue("name not set", (name != null && !name.IsEmpty()));
                JSONArray counters = counterGroup.GetJSONArray("counter");
                for (int j = 0; j < counters.Length(); j++)
                {
                    JSONObject counter     = counters.GetJSONObject(j);
                    string     counterName = counter.GetString("name");
                    NUnit.Framework.Assert.IsTrue("name not set", (counterName != null && !counterName
                                                                   .IsEmpty()));
                    long value = counter.GetLong("value");
                    NUnit.Framework.Assert.IsTrue("value  >= 0", value >= 0);
                }
            }
        }
Exemple #3
0
        public virtual void TestTaskFailWithUnusedContainer()
        {
            MRApp         app         = new TestFail.MRAppWithFailingTaskAndUnusedContainer();
            Configuration conf        = new Configuration();
            int           maxAttempts = 1;

            conf.SetInt(MRJobConfig.MapMaxAttempts, maxAttempts);
            // disable uberization (requires entire job to be reattempted, so max for
            // subtask attempts is overridden to 1)
            conf.SetBoolean(MRJobConfig.JobUbertaskEnable, false);
            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(conf);
            app.WaitForState(job, JobState.Running);
            IDictionary <TaskId, Task> tasks = job.GetTasks();

            NUnit.Framework.Assert.AreEqual("Num tasks is not correct", 1, tasks.Count);
            Task task = tasks.Values.GetEnumerator().Next();

            app.WaitForState(task, TaskState.Scheduled);
            IDictionary <TaskAttemptId, TaskAttempt> attempts = tasks.Values.GetEnumerator().Next
                                                                    ().GetAttempts();

            NUnit.Framework.Assert.AreEqual("Num attempts is not correct", maxAttempts, attempts
                                            .Count);
            TaskAttempt attempt = attempts.Values.GetEnumerator().Next();

            app.WaitForInternalState((TaskAttemptImpl)attempt, TaskAttemptStateInternal.Assigned
                                     );
            app.GetDispatcher().GetEventHandler().Handle(new TaskAttemptEvent(attempt.GetID()
                                                                              , TaskAttemptEventType.TaContainerCompleted));
            app.WaitForState(job, JobState.Failed);
        }
Exemple #4
0
        public virtual void TestCommitPending()
        {
            MRApp app = new MRApp(1, 0, false, this.GetType().FullName, true);

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(new Configuration());
            app.WaitForState(job, JobState.Running);
            NUnit.Framework.Assert.AreEqual("Num tasks not correct", 1, job.GetTasks().Count);
            IEnumerator <Task> it = job.GetTasks().Values.GetEnumerator();
            Task task             = it.Next();

            app.WaitForState(task, TaskState.Running);
            TaskAttempt attempt = task.GetAttempts().Values.GetEnumerator().Next();

            app.WaitForState(attempt, TaskAttemptState.Running);
            //send the commit pending signal to the task
            app.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(attempt.GetID(), TaskAttemptEventType
                                                                           .TaCommitPending));
            //wait for first attempt to commit pending
            app.WaitForState(attempt, TaskAttemptState.CommitPending);
            //re-send the commit pending signal to the task
            app.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(attempt.GetID(), TaskAttemptEventType
                                                                           .TaCommitPending));
            //the task attempt should be still at COMMIT_PENDING
            app.WaitForState(attempt, TaskAttemptState.CommitPending);
            //send the done signal to the task
            app.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(task.GetAttempts()
                                                                           .Values.GetEnumerator().Next().GetID(), TaskAttemptEventType.TaDone));
            app.WaitForState(job, JobState.Succeeded);
        }
Exemple #5
0
 public virtual void VerifyHsTaskCountersXML(NodeList nodes, TaskAttempt att)
 {
     for (int i = 0; i < nodes.GetLength(); i++)
     {
         Element element = (Element)nodes.Item(i);
         WebServicesTestUtils.CheckStringMatch("id", MRApps.ToString(att.GetID()), WebServicesTestUtils
                                               .GetXmlString(element, "id"));
         // just do simple verification of fields - not data is correct
         // in the fields
         NodeList groups = element.GetElementsByTagName("taskAttemptCounterGroup");
         for (int j = 0; j < groups.GetLength(); j++)
         {
             Element counters = (Element)groups.Item(j);
             NUnit.Framework.Assert.IsNotNull("should have counters in the web service info",
                                              counters);
             string name = WebServicesTestUtils.GetXmlString(counters, "counterGroupName");
             NUnit.Framework.Assert.IsTrue("name not set", (name != null && !name.IsEmpty()));
             NodeList counterArr = counters.GetElementsByTagName("counter");
             for (int z = 0; z < counterArr.GetLength(); z++)
             {
                 Element counter     = (Element)counterArr.Item(z);
                 string  counterName = WebServicesTestUtils.GetXmlString(counter, "name");
                 NUnit.Framework.Assert.IsTrue("counter name not set", (counterName != null && !counterName
                                                                        .IsEmpty()));
                 long value = WebServicesTestUtils.GetXmlLong(counter, "value");
                 NUnit.Framework.Assert.IsTrue("value not >= 0", value >= 0);
             }
         }
     }
 }
Exemple #6
0
        public TaskInfo(Task task)
        {
            TaskType ttype = task.GetType();

            this.type = ttype.ToString();
            TaskReport report = task.GetReport();

            this.startTime   = report.GetStartTime();
            this.finishTime  = report.GetFinishTime();
            this.state       = report.GetTaskState();
            this.elapsedTime = Times.Elapsed(this.startTime, this.finishTime, this.state == TaskState
                                             .Running);
            if (this.elapsedTime == -1)
            {
                this.elapsedTime = 0;
            }
            this.progress   = report.GetProgress() * 100;
            this.status     = report.GetStatus();
            this.id         = MRApps.ToString(task.GetID());
            this.taskNum    = task.GetID().GetId();
            this.successful = GetSuccessfulAttempt(task);
            if (successful != null)
            {
                this.successfulAttempt = MRApps.ToString(successful.GetID());
            }
            else
            {
                this.successfulAttempt = string.Empty;
            }
        }
Exemple #7
0
        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);
                }
            }
        }
Exemple #8
0
        public static IDictionary <TaskAttemptId, TaskAttempt> NewTaskAttempts(TaskId tid,
                                                                               int m)
        {
            IDictionary <TaskAttemptId, TaskAttempt> map = Maps.NewHashMap();

            for (int i = 0; i < m; ++i)
            {
                TaskAttempt ta = NewTaskAttempt(tid, i);
                map[ta.GetID()] = ta;
            }
            return(map);
        }
Exemple #9
0
        public virtual void UpdateAttempt(TaskAttemptStatusUpdateEvent.TaskAttemptStatus
                                          status, long timestamp)
        {
            TaskAttemptId attemptID = status.id;
            TaskId        taskID    = attemptID.GetTaskId();
            JobId         jobID     = taskID.GetJobId();

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = context.GetJob(jobID);
            if (job == null)
            {
                return;
            }
            Task task = job.GetTask(taskID);

            if (task == null)
            {
                return;
            }
            long        boxedStart  = startTimes[attemptID];
            long        start       = boxedStart == null ? long.MinValue : boxedStart;
            TaskAttempt taskAttempt = task.GetAttempt(attemptID);

            if (taskAttempt.GetState() == TaskAttemptState.Succeeded)
            {
                bool isNew = false;
                // is this  a new success?
                lock (doneTasks)
                {
                    if (!doneTasks.Contains(task))
                    {
                        doneTasks.AddItem(task);
                        isNew = true;
                    }
                }
                // It's a new completion
                // Note that if a task completes twice [because of a previous speculation
                //  and a race, or a success followed by loss of the machine with the
                //  local data] we only count the first one.
                if (isNew)
                {
                    long finish = timestamp;
                    if (start > 1L && finish > 1L && start <= finish)
                    {
                        long           duration   = finish - start;
                        DataStatistics statistics = DataStatisticsForTask(taskID);
                        if (statistics != null)
                        {
                            statistics.Add(duration);
                        }
                    }
                }
            }
        }
Exemple #10
0
        public virtual JobTaskAttemptCounterInfo GetJobTaskAttemptIdCounters(HttpServletRequest
                                                                             hsr, string jid, string tid, string attId)
        {
            Init();
            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = AMWebServices.GetJobFromJobIdString
                                                                 (jid, ctx);
            CheckAccess(job, hsr);
            Task        task = AMWebServices.GetTaskFromTaskIdString(tid, job);
            TaskAttempt ta   = AMWebServices.GetTaskAttemptFromTaskAttemptString(attId, task);

            return(new JobTaskAttemptCounterInfo(ta));
        }
            /// <exception cref="System.IO.IOException"/>
            private TaskAttempt VerifyAndGetAttempt(TaskAttemptId attemptID, JobACL accessType
                                                    )
            {
                TaskAttempt attempt = this.VerifyAndGetTask(attemptID.GetTaskId(), accessType).GetAttempt
                                          (attemptID);

                if (attempt == null)
                {
                    throw new IOException("Unknown TaskAttempt " + attemptID);
                }
                return(attempt);
            }
Exemple #12
0
        public virtual void TestKillTaskAttempt()
        {
            CountDownLatch latch = new CountDownLatch(1);
            MRApp          app   = new TestKill.BlockingMRApp(2, 0, latch);

            //this will start the job but job won't complete as Task is blocked
            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(new Configuration());
            //wait and vailidate for Job to become RUNNING
            app.WaitForState(job, JobState.Running);
            IDictionary <TaskId, Task> tasks = job.GetTasks();

            NUnit.Framework.Assert.AreEqual("No of tasks is not correct", 2, tasks.Count);
            IEnumerator <Task> it = tasks.Values.GetEnumerator();
            Task task1            = it.Next();
            Task task2            = it.Next();

            //wait for tasks to become running
            app.WaitForState(task1, TaskState.Scheduled);
            app.WaitForState(task2, TaskState.Scheduled);
            //send the kill signal to the first Task's attempt
            TaskAttempt attempt = task1.GetAttempts().Values.GetEnumerator().Next();

            app.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(attempt.GetID(), TaskAttemptEventType
                                                                           .TaKill));
            //unblock
            latch.CountDown();
            //wait and validate for Job to become SUCCEEDED
            //job will still succeed
            app.WaitForState(job, JobState.Succeeded);
            //first Task will have two attempts 1st is killed, 2nd Succeeds
            //both Tasks and Job succeeds
            NUnit.Framework.Assert.AreEqual("Task state not correct", TaskState.Succeeded, task1
                                            .GetReport().GetTaskState());
            NUnit.Framework.Assert.AreEqual("Task state not correct", TaskState.Succeeded, task2
                                            .GetReport().GetTaskState());
            IDictionary <TaskAttemptId, TaskAttempt> attempts = task1.GetAttempts();

            NUnit.Framework.Assert.AreEqual("No of attempts is not correct", 2, attempts.Count
                                            );
            IEnumerator <TaskAttempt> iter = attempts.Values.GetEnumerator();

            NUnit.Framework.Assert.AreEqual("Attempt state not correct", TaskAttemptState.Killed
                                            , iter.Next().GetReport().GetTaskAttemptState());
            NUnit.Framework.Assert.AreEqual("Attempt state not correct", TaskAttemptState.Succeeded
                                            , iter.Next().GetReport().GetTaskAttemptState());
            attempts = task2.GetAttempts();
            NUnit.Framework.Assert.AreEqual("No of attempts is not correct", 1, attempts.Count
                                            );
            iter = attempts.Values.GetEnumerator();
            NUnit.Framework.Assert.AreEqual("Attempt state not correct", TaskAttemptState.Succeeded
                                            , iter.Next().GetReport().GetTaskAttemptState());
        }
        private void VerifyAttempt(TaskAttempt attempt)
        {
            NUnit.Framework.Assert.AreEqual("TaskAttempt state not currect", TaskAttemptState
                                            .Succeeded, attempt.GetState());
            NUnit.Framework.Assert.IsNotNull(attempt.GetAssignedContainerID());
            //Verify the wrong ctor is not being used. Remove after mrv1 is removed.
            ContainerId fakeCid = MRApp.NewContainerId(-1, -1, -1, -1);

            NUnit.Framework.Assert.IsFalse(attempt.GetAssignedContainerID().Equals(fakeCid));
            //Verify complete contianerManagerAddress
            NUnit.Framework.Assert.AreEqual(MRApp.NmHost + ":" + MRApp.NmPort, attempt.GetAssignedContainerMgrAddress
                                                ());
        }
Exemple #14
0
		/// <exception cref="System.Exception"/>
		public virtual void TestSlowNM()
		{
			conf = new Configuration();
			int maxAttempts = 1;
			conf.SetInt(MRJobConfig.MapMaxAttempts, maxAttempts);
			conf.SetBoolean(MRJobConfig.JobUbertaskEnable, false);
			// set timeout low for the test
			conf.SetInt("yarn.rpc.nm-command-timeout", 3000);
			conf.Set(YarnConfiguration.IpcRpcImpl, typeof(HadoopYarnProtoRPC).FullName);
			YarnRPC rpc = YarnRPC.Create(conf);
			string bindAddr = "localhost:0";
			IPEndPoint addr = NetUtils.CreateSocketAddr(bindAddr);
			NMTokenSecretManagerInNM tokenSecretManager = new NMTokenSecretManagerInNM();
			MasterKey masterKey = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord<MasterKey>();
			masterKey.SetBytes(ByteBuffer.Wrap(Sharpen.Runtime.GetBytesForString("key")));
			tokenSecretManager.SetMasterKey(masterKey);
			conf.Set(CommonConfigurationKeysPublic.HadoopSecurityAuthentication, "token");
			server = rpc.GetServer(typeof(ContainerManagementProtocol), new TestContainerLauncher.DummyContainerManager
				(this), addr, conf, tokenSecretManager, 1);
			server.Start();
			MRApp app = new TestContainerLauncher.MRAppWithSlowNM(this, tokenSecretManager);
			try
			{
				Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(conf);
				app.WaitForState(job, JobState.Running);
				IDictionary<TaskId, Task> tasks = job.GetTasks();
				NUnit.Framework.Assert.AreEqual("Num tasks is not correct", 1, tasks.Count);
				Task task = tasks.Values.GetEnumerator().Next();
				app.WaitForState(task, TaskState.Scheduled);
				IDictionary<TaskAttemptId, TaskAttempt> attempts = tasks.Values.GetEnumerator().Next
					().GetAttempts();
				NUnit.Framework.Assert.AreEqual("Num attempts is not correct", maxAttempts, attempts
					.Count);
				TaskAttempt attempt = attempts.Values.GetEnumerator().Next();
				app.WaitForInternalState((TaskAttemptImpl)attempt, TaskAttemptStateInternal.Assigned
					);
				app.WaitForState(job, JobState.Failed);
				string diagnostics = attempt.GetDiagnostics().ToString();
				Log.Info("attempt.getDiagnostics: " + diagnostics);
				NUnit.Framework.Assert.IsTrue(diagnostics.Contains("Container launch failed for "
					 + "container_0_0000_01_000000 : "));
				NUnit.Framework.Assert.IsTrue(diagnostics.Contains("java.net.SocketTimeoutException: 3000 millis timeout while waiting for channel"
					));
			}
			finally
			{
				server.Stop();
				app.Stop();
			}
		}
Exemple #15
0
        private static TaskAttempt[] MakeFirstAttemptWin(EventHandler appEventHandler, Task
                                                         speculatedTask)
        {
            // finish 1st TA, 2nd will be killed
            ICollection <TaskAttempt> attempts = speculatedTask.GetAttempts().Values;

            TaskAttempt[] ta = new TaskAttempt[attempts.Count];
            Sharpen.Collections.ToArray(attempts, ta);
            appEventHandler.Handle(new TaskAttemptEvent(ta[0].GetID(), TaskAttemptEventType.TaDone
                                                        ));
            appEventHandler.Handle(new TaskAttemptEvent(ta[0].GetID(), TaskAttemptEventType.TaContainerCleaned
                                                        ));
            return(ta);
        }
Exemple #16
0
 public virtual void VerifyReduceTaskAttemptGeneric(TaskAttempt ta, long shuffleFinishTime
                                                    , long mergeFinishTime, long elapsedShuffleTime, long elapsedMergeTime, long elapsedReduceTime
                                                    )
 {
     NUnit.Framework.Assert.AreEqual("shuffleFinishTime wrong", ta.GetShuffleFinishTime
                                         (), shuffleFinishTime);
     NUnit.Framework.Assert.AreEqual("mergeFinishTime wrong", ta.GetSortFinishTime(),
                                     mergeFinishTime);
     NUnit.Framework.Assert.AreEqual("elapsedShuffleTime wrong", ta.GetShuffleFinishTime
                                         () - ta.GetLaunchTime(), elapsedShuffleTime);
     NUnit.Framework.Assert.AreEqual("elapsedMergeTime wrong", ta.GetSortFinishTime()
                                     - ta.GetShuffleFinishTime(), elapsedMergeTime);
     NUnit.Framework.Assert.AreEqual("elapsedReduceTime wrong", ta.GetFinishTime() - ta
                                     .GetSortFinishTime(), elapsedReduceTime);
 }
Exemple #17
0
        public virtual void TestAMInfosWithoutRecoveryEnabled()
        {
            int   runCount = 0;
            MRApp app      = new TestRecovery.MRAppWithHistory(1, 0, false, this.GetType().FullName
                                                               , true, ++runCount);
            Configuration conf = new Configuration();

            conf.SetBoolean(MRJobConfig.JobUbertaskEnable, false);
            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(conf);
            app.WaitForState(job, JobState.Running);
            long am1StartTime = app.GetAllAMInfos()[0].GetStartTime();

            NUnit.Framework.Assert.AreEqual("No of tasks not correct", 1, job.GetTasks().Count
                                            );
            IEnumerator <Task> it = job.GetTasks().Values.GetEnumerator();
            Task mapTask          = it.Next();

            app.WaitForState(mapTask, TaskState.Running);
            TaskAttempt taskAttempt = mapTask.GetAttempts().Values.GetEnumerator().Next();

            app.WaitForState(taskAttempt, TaskAttemptState.Running);
            // stop the app
            app.Stop();
            // rerun
            app = new TestRecovery.MRAppWithHistory(1, 0, false, this.GetType().FullName, false
                                                    , ++runCount);
            conf = new Configuration();
            // in rerun the AMInfo will be recovered from previous run even if recovery
            // is not enabled.
            conf.SetBoolean(MRJobConfig.MrAmJobRecoveryEnable, false);
            conf.SetBoolean(MRJobConfig.JobUbertaskEnable, false);
            job = app.Submit(conf);
            app.WaitForState(job, JobState.Running);
            NUnit.Framework.Assert.AreEqual("No of tasks not correct", 1, job.GetTasks().Count
                                            );
            it      = job.GetTasks().Values.GetEnumerator();
            mapTask = it.Next();
            // There should be two AMInfos
            IList <AMInfo> amInfos = app.GetAllAMInfos();

            NUnit.Framework.Assert.AreEqual(2, amInfos.Count);
            AMInfo amInfoOne = amInfos[0];

            NUnit.Framework.Assert.AreEqual(am1StartTime, amInfoOne.GetStartTime());
            app.Stop();
        }
Exemple #18
0
        //@Test
        /// <exception cref="System.Exception"/>
        public virtual void TestCompletedMapsForReduceSlowstart()
        {
            MRApp         app  = new MRApp(2, 1, false, this.GetType().FullName, true);
            Configuration conf = new Configuration();

            //after half of the map completion, reduce will start
            conf.SetFloat(MRJobConfig.CompletedMapsForReduceSlowstart, 0.5f);
            //uberization forces full slowstart (1.0), so disable that
            conf.SetBoolean(MRJobConfig.JobUbertaskEnable, false);
            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(conf);
            app.WaitForState(job, JobState.Running);
            //all maps would be running
            NUnit.Framework.Assert.AreEqual("Num tasks not correct", 3, job.GetTasks().Count);
            IEnumerator <Task> it = job.GetTasks().Values.GetEnumerator();
            Task mapTask1         = it.Next();
            Task mapTask2         = it.Next();
            Task reduceTask       = it.Next();

            // all maps must be running
            app.WaitForState(mapTask1, TaskState.Running);
            app.WaitForState(mapTask2, TaskState.Running);
            TaskAttempt task1Attempt = mapTask1.GetAttempts().Values.GetEnumerator().Next();
            TaskAttempt task2Attempt = mapTask2.GetAttempts().Values.GetEnumerator().Next();

            //before sending the TA_DONE, event make sure attempt has come to
            //RUNNING state
            app.WaitForState(task1Attempt, TaskAttemptState.Running);
            app.WaitForState(task2Attempt, TaskAttemptState.Running);
            // reduces must be in NEW state
            NUnit.Framework.Assert.AreEqual("Reduce Task state not correct", TaskState.New, reduceTask
                                            .GetReport().GetTaskState());
            //send the done signal to the 1st map task
            app.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(mapTask1.GetAttempts
                                                                               ().Values.GetEnumerator().Next().GetID(), TaskAttemptEventType.TaDone));
            //wait for first map task to complete
            app.WaitForState(mapTask1, TaskState.Succeeded);
            //Once the first map completes, it will schedule the reduces
            //now reduce must be running
            app.WaitForState(reduceTask, TaskState.Running);
            //send the done signal to 2nd map and the reduce to complete the job
            app.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(mapTask2.GetAttempts
                                                                               ().Values.GetEnumerator().Next().GetID(), TaskAttemptEventType.TaDone));
            app.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(reduceTask.GetAttempts
                                                                               ().Values.GetEnumerator().Next().GetID(), TaskAttemptEventType.TaDone));
            app.WaitForState(job, JobState.Succeeded);
        }
Exemple #19
0
        public virtual void TestKillTaskWaitKillJobAfterTA_DONE()
        {
            CountDownLatch latch      = new CountDownLatch(1);
            Dispatcher     dispatcher = new TestKill.MyAsyncDispatch(latch, TaskAttemptEventType.
                                                                     TaDone);
            MRApp app = new _MRApp_252(dispatcher, 1, 1, false, this.GetType().FullName, true
                                       );

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(new Configuration());
            JobId jobId = app.GetJobId();

            app.WaitForState(job, JobState.Running);
            NUnit.Framework.Assert.AreEqual("Num tasks not correct", 2, job.GetTasks().Count);
            IEnumerator <Task> it = job.GetTasks().Values.GetEnumerator();
            Task mapTask          = it.Next();
            Task reduceTask       = it.Next();

            app.WaitForState(mapTask, TaskState.Running);
            app.WaitForState(reduceTask, TaskState.Running);
            TaskAttempt mapAttempt = mapTask.GetAttempts().Values.GetEnumerator().Next();

            app.WaitForState(mapAttempt, TaskAttemptState.Running);
            TaskAttempt reduceAttempt = reduceTask.GetAttempts().Values.GetEnumerator().Next(
                );

            app.WaitForState(reduceAttempt, TaskAttemptState.Running);
            // The order in the dispatch event queue, from the oldest to the newest
            // TA_DONE
            // JOB_KILL
            // CONTAINER_REMOTE_CLEANUP ( from TA_DONE's handling )
            // T_KILL ( from JOB_KILL's handling )
            // TA_CONTAINER_CLEANED ( from CONTAINER_REMOTE_CLEANUP's handling )
            // TA_KILL ( from T_KILL's handling )
            // T_ATTEMPT_SUCCEEDED ( from TA_CONTAINER_CLEANED's handling )
            // T_ATTEMPT_KILLED ( from TA_KILL's handling )
            // Finish map
            app.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(mapAttempt.GetID()
                                                                           , TaskAttemptEventType.TaDone));
            // Now kill the job
            app.GetContext().GetEventHandler().Handle(new JobEvent(jobId, JobEventType.JobKill
                                                                   ));
            //unblock
            latch.CountDown();
            app.WaitForInternalState((JobImpl)job, JobStateInternal.Killed);
        }
Exemple #20
0
        private void UpdateStatus(MRApp app, TaskAttempt attempt, Phase phase)
        {
            TaskAttemptStatusUpdateEvent.TaskAttemptStatus status = new TaskAttemptStatusUpdateEvent.TaskAttemptStatus
                                                                        ();
            status.counters        = new Counters();
            status.fetchFailedMaps = new AList <TaskAttemptId>();
            status.id                = attempt.GetID();
            status.mapFinishTime     = 0;
            status.phase             = phase;
            status.progress          = 0.5f;
            status.shuffleFinishTime = 0;
            status.sortFinishTime    = 0;
            status.stateString       = "OK";
            status.taskState         = attempt.GetState();
            TaskAttemptStatusUpdateEvent @event = new TaskAttemptStatusUpdateEvent(attempt.GetID
                                                                                       (), status);

            app.GetContext().GetEventHandler().Handle(@event);
        }
Exemple #21
0
        public virtual void TestSingleTaskCounterView()
        {
            AppContext appContext = new MockAppContext(0, 1, 1, 2);
            IDictionary <string, string> @params = GetTaskParams(appContext);

            @params[AMParams.CounterGroup] = "org.apache.hadoop.mapreduce.FileSystemCounter";
            @params[AMParams.CounterName]  = "HDFS_WRITE_OPS";
            // remove counters from one task attempt
            // to test handling of missing counters
            TaskId taskID = MRApps.ToTaskID(@params[AMParams.TaskId]);

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = appContext.GetJob(taskID.GetJobId
                                                                                   ());
            Task        task    = job.GetTask(taskID);
            TaskAttempt attempt = task.GetAttempts().Values.GetEnumerator().Next();

            attempt.GetReport().SetCounters(null);
            WebAppTests.TestPage <AppContext>(typeof(SingleCounterPage), appContext, @params);
        }
Exemple #22
0
        public virtual void TestAverageReduceTime()
        {
            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = Org.Mockito.Mockito.Mock <CompletedJob
                                                                                       >();
            Task          task1          = Org.Mockito.Mockito.Mock <Task>();
            Task          task2          = Org.Mockito.Mockito.Mock <Task>();
            JobId         jobId          = MRBuilderUtils.NewJobId(1L, 1, 1);
            TaskId        taskId1        = MRBuilderUtils.NewTaskId(jobId, 1, TaskType.Reduce);
            TaskId        taskId2        = MRBuilderUtils.NewTaskId(jobId, 2, TaskType.Reduce);
            TaskAttemptId taskAttemptId1 = MRBuilderUtils.NewTaskAttemptId(taskId1, 1);
            TaskAttemptId taskAttemptId2 = MRBuilderUtils.NewTaskAttemptId(taskId2, 2);
            TaskAttempt   taskAttempt1   = Org.Mockito.Mockito.Mock <TaskAttempt>();
            TaskAttempt   taskAttempt2   = Org.Mockito.Mockito.Mock <TaskAttempt>();
            JobReport     jobReport      = Org.Mockito.Mockito.Mock <JobReport>();

            Org.Mockito.Mockito.When(taskAttempt1.GetState()).ThenReturn(TaskAttemptState.Succeeded
                                                                         );
            Org.Mockito.Mockito.When(taskAttempt1.GetLaunchTime()).ThenReturn(0L);
            Org.Mockito.Mockito.When(taskAttempt1.GetShuffleFinishTime()).ThenReturn(4L);
            Org.Mockito.Mockito.When(taskAttempt1.GetSortFinishTime()).ThenReturn(6L);
            Org.Mockito.Mockito.When(taskAttempt1.GetFinishTime()).ThenReturn(8L);
            Org.Mockito.Mockito.When(taskAttempt2.GetState()).ThenReturn(TaskAttemptState.Succeeded
                                                                         );
            Org.Mockito.Mockito.When(taskAttempt2.GetLaunchTime()).ThenReturn(5L);
            Org.Mockito.Mockito.When(taskAttempt2.GetShuffleFinishTime()).ThenReturn(10L);
            Org.Mockito.Mockito.When(taskAttempt2.GetSortFinishTime()).ThenReturn(22L);
            Org.Mockito.Mockito.When(taskAttempt2.GetFinishTime()).ThenReturn(42L);
            Org.Mockito.Mockito.When(task1.GetType()).ThenReturn(TaskType.Reduce);
            Org.Mockito.Mockito.When(task2.GetType()).ThenReturn(TaskType.Reduce);
            Org.Mockito.Mockito.When(task1.GetAttempts()).ThenReturn(new _Dictionary_120(taskAttemptId1
                                                                                         , taskAttempt1));
            Org.Mockito.Mockito.When(task2.GetAttempts()).ThenReturn(new _Dictionary_123(taskAttemptId2
                                                                                         , taskAttempt2));
            Org.Mockito.Mockito.When(job.GetTasks()).ThenReturn(new _Dictionary_127(taskId1,
                                                                                    task1, taskId2, task2));
            Org.Mockito.Mockito.When(job.GetID()).ThenReturn(jobId);
            Org.Mockito.Mockito.When(job.GetReport()).ThenReturn(jobReport);
            Org.Mockito.Mockito.When(job.GetName()).ThenReturn("TestJobInfo");
            Org.Mockito.Mockito.When(job.GetState()).ThenReturn(JobState.Succeeded);
            JobInfo jobInfo = new JobInfo(job);

            NUnit.Framework.Assert.AreEqual(11L, jobInfo.GetAvgReduceTime());
        }
Exemple #23
0
        public virtual TaskAttemptInfo GetJobTaskAttemptId(HttpServletRequest hsr, string
                                                           jid, string tid, string attId)
        {
            Init();
            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = AMWebServices.GetJobFromJobIdString
                                                                 (jid, ctx);
            CheckAccess(job, hsr);
            Task        task = AMWebServices.GetTaskFromTaskIdString(tid, job);
            TaskAttempt ta   = AMWebServices.GetTaskAttemptFromTaskAttemptString(attId, task);

            if (task.GetType() == TaskType.Reduce)
            {
                return(new ReduceTaskAttemptInfo(ta, task.GetType()));
            }
            else
            {
                return(new TaskAttemptInfo(ta, task.GetType(), false));
            }
        }
Exemple #24
0
        /// <exception cref="System.Exception"/>
        public virtual void WaitForState(TaskAttempt attempt, TaskAttemptState finalState
                                         )
        {
            int timeoutSecs          = 0;
            TaskAttemptReport report = attempt.GetReport();

            while (!finalState.Equals(report.GetTaskAttemptState()) && timeoutSecs++ < 20)
            {
                System.Console.Out.WriteLine("TaskAttempt State is : " + report.GetTaskAttemptState
                                                 () + " Waiting for state : " + finalState + "   progress : " + report.GetProgress
                                                 ());
                report = attempt.GetReport();
                Sharpen.Thread.Sleep(500);
            }
            System.Console.Out.WriteLine("TaskAttempt State is : " + report.GetTaskAttemptState
                                             ());
            NUnit.Framework.Assert.AreEqual("TaskAttempt state is not correct (timedout)", finalState
                                            , report.GetTaskAttemptState());
        }
Exemple #25
0
 public virtual void VerifyHsTaskAttemptXML(Element element, TaskAttempt att, TaskType
                                            ttype)
 {
     VerifyTaskAttemptGeneric(att, ttype, WebServicesTestUtils.GetXmlString(element, "id"
                                                                            ), WebServicesTestUtils.GetXmlString(element, "state"), WebServicesTestUtils.GetXmlString
                                  (element, "type"), WebServicesTestUtils.GetXmlString(element, "rack"), WebServicesTestUtils
                              .GetXmlString(element, "nodeHttpAddress"), WebServicesTestUtils.GetXmlString(element
                                                                                                           , "diagnostics"), WebServicesTestUtils.GetXmlString(element, "assignedContainerId"
                                                                                                                                                               ), WebServicesTestUtils.GetXmlLong(element, "startTime"), WebServicesTestUtils.GetXmlLong
                                  (element, "finishTime"), WebServicesTestUtils.GetXmlLong(element, "elapsedTime")
                              , WebServicesTestUtils.GetXmlFloat(element, "progress"));
     if (ttype == TaskType.Reduce)
     {
         VerifyReduceTaskAttemptGeneric(att, WebServicesTestUtils.GetXmlLong(element, "shuffleFinishTime"
                                                                             ), WebServicesTestUtils.GetXmlLong(element, "mergeFinishTime"), WebServicesTestUtils
                                        .GetXmlLong(element, "elapsedShuffleTime"), WebServicesTestUtils.GetXmlLong(element
                                                                                                                    , "elapsedMergeTime"), WebServicesTestUtils.GetXmlLong(element, "elapsedReduceTime"
                                                                                                                                                                           ));
     }
 }
 public JobTaskAttemptCounterInfo(TaskAttempt taskattempt)
 {
     this.id = MRApps.ToString(taskattempt.GetID());
     total   = taskattempt.GetCounters();
     taskAttemptCounterGroup = new AList <TaskCounterGroupInfo>();
     if (total != null)
     {
         foreach (CounterGroup g in total)
         {
             if (g != null)
             {
                 TaskCounterGroupInfo cginfo = new TaskCounterGroupInfo(g.GetName(), g);
                 if (cginfo != null)
                 {
                     taskAttemptCounterGroup.AddItem(cginfo);
                 }
             }
         }
     }
 }
        /// <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());
        }
Exemple #28
0
        public virtual void TestKillTaskWait()
        {
            Dispatcher dispatcher = new _AsyncDispatcher_145();
            // Task is asking the reduce TA to kill itself. 'Create' a race
            // condition. Make the task succeed and then inform the task that
            // TA has succeeded. Once Task gets the TA succeeded event at
            // KILL_WAIT, then relay the actual kill signal to TA
            // When the TA comes and reports that it is done, send the
            // cachedKillEvent
            MRApp app = new _MRApp_183(dispatcher, 1, 1, false, this.GetType().FullName, true
                                       );

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(new Configuration());
            JobId jobId = app.GetJobId();

            app.WaitForState(job, JobState.Running);
            NUnit.Framework.Assert.AreEqual("Num tasks not correct", 2, job.GetTasks().Count);
            IEnumerator <Task> it = job.GetTasks().Values.GetEnumerator();
            Task mapTask          = it.Next();
            Task reduceTask       = it.Next();

            app.WaitForState(mapTask, TaskState.Running);
            app.WaitForState(reduceTask, TaskState.Running);
            TaskAttempt mapAttempt = mapTask.GetAttempts().Values.GetEnumerator().Next();

            app.WaitForState(mapAttempt, TaskAttemptState.Running);
            TaskAttempt reduceAttempt = reduceTask.GetAttempts().Values.GetEnumerator().Next(
                );

            app.WaitForState(reduceAttempt, TaskAttemptState.Running);
            // Finish map
            app.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(mapAttempt.GetID()
                                                                           , TaskAttemptEventType.TaDone));
            app.WaitForState(mapTask, TaskState.Succeeded);
            // Now kill the job
            app.GetContext().GetEventHandler().Handle(new JobEvent(jobId, JobEventType.JobKill
                                                                   ));
            app.WaitForInternalState((JobImpl)job, JobStateInternal.Killed);
        }
Exemple #29
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();
        }
        private long StoredPerAttemptValue(IDictionary <TaskAttempt, AtomicLong> data, TaskAttemptId
                                           attemptID)
        {
            TaskId taskID = attemptID.GetTaskId();
            JobId  jobID  = taskID.GetJobId();

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = context.GetJob(jobID);
            Task task = job.GetTask(taskID);

            if (task == null)
            {
                return(-1L);
            }
            TaskAttempt taskAttempt = task.GetAttempt(attemptID);

            if (taskAttempt == null)
            {
                return(-1L);
            }
            AtomicLong estimate = data[taskAttempt];

            return(estimate == null ? -1L : estimate.Get());
        }