예제 #1
0
        public virtual void TestAbsentNotificationOnNotLastRetryUnregistrationFailure()
        {
            HttpServer2 server = StartHttpServer();
            MRApp       app    = Org.Mockito.Mockito.Spy(new TestJobEndNotifier.MRAppWithCustomContainerAllocator
                                                             (this, 2, 2, false, this.GetType().FullName, true, 1, false));

            Org.Mockito.Mockito.DoNothing().When(app).Sysexit();
            JobConf conf = new JobConf();

            conf.Set(JobContext.MrJobEndNotificationUrl, TestJobEndNotifier.JobEndServlet.baseUrl
                     + "jobend?jobid=$jobId&status=$jobStatus");
            JobImpl job = (JobImpl)app.Submit(conf);

            app.WaitForState(job, JobState.Running);
            app.GetContext().GetEventHandler().Handle(new JobEvent(app.GetJobId(), JobEventType
                                                                   .JobAmReboot));
            app.WaitForInternalState(job, JobStateInternal.Reboot);
            // Now shutdown.
            // Unregistration fails: isLastAMRetry is recalculated, this is not
            app.ShutDownJob();
            // Not the last AM attempt. So user should that the job is still running.
            app.WaitForState(job, JobState.Running);
            NUnit.Framework.Assert.IsFalse(app.IsLastAMRetry());
            NUnit.Framework.Assert.AreEqual(0, TestJobEndNotifier.JobEndServlet.calledTimes);
            NUnit.Framework.Assert.IsNull(TestJobEndNotifier.JobEndServlet.requestUri);
            NUnit.Framework.Assert.IsNull(TestJobEndNotifier.JobEndServlet.foundJobState);
            server.Stop();
        }
예제 #2
0
        public virtual void TestNotificationOnLastRetryUnregistrationFailure()
        {
            HttpServer2 server = StartHttpServer();
            MRApp       app    = Org.Mockito.Mockito.Spy(new TestJobEndNotifier.MRAppWithCustomContainerAllocator
                                                             (this, 2, 2, false, this.GetType().FullName, true, 2, false));

            // Currently, we will have isLastRetry always equals to false at beginning
            // of MRAppMaster, except staging area exists or commit already started at
            // the beginning.
            // Now manually set isLastRetry to true and this should reset to false when
            // unregister failed.
            app.isLastAMRetry = true;
            Org.Mockito.Mockito.DoNothing().When(app).Sysexit();
            JobConf conf = new JobConf();

            conf.Set(JobContext.MrJobEndNotificationUrl, TestJobEndNotifier.JobEndServlet.baseUrl
                     + "jobend?jobid=$jobId&status=$jobStatus");
            JobImpl job = (JobImpl)app.Submit(conf);

            app.WaitForState(job, JobState.Running);
            app.GetContext().GetEventHandler().Handle(new JobEvent(app.GetJobId(), JobEventType
                                                                   .JobAmReboot));
            app.WaitForInternalState(job, JobStateInternal.Reboot);
            // Now shutdown. User should see FAILED state.
            // Unregistration fails: isLastAMRetry is recalculated, this is
            ///reboot will stop service internally, we don't need to shutdown twice
            app.WaitForServiceToStop(10000);
            NUnit.Framework.Assert.IsFalse(app.IsLastAMRetry());
            // Since it's not last retry, JobEndServlet didn't called
            NUnit.Framework.Assert.AreEqual(0, TestJobEndNotifier.JobEndServlet.calledTimes);
            NUnit.Framework.Assert.IsNull(TestJobEndNotifier.JobEndServlet.requestUri);
            NUnit.Framework.Assert.IsNull(TestJobEndNotifier.JobEndServlet.foundJobState);
            server.Stop();
        }
예제 #3
0
        public virtual void TestNotificationOnLastRetryNormalShutdown()
        {
            HttpServer2 server = StartHttpServer();
            // Act like it is the second attempt. Default max attempts is 2
            MRApp app = Org.Mockito.Mockito.Spy(new TestJobEndNotifier.MRAppWithCustomContainerAllocator
                                                    (this, 2, 2, true, this.GetType().FullName, true, 2, true));

            Org.Mockito.Mockito.DoNothing().When(app).Sysexit();
            JobConf conf = new JobConf();

            conf.Set(JobContext.MrJobEndNotificationUrl, TestJobEndNotifier.JobEndServlet.baseUrl
                     + "jobend?jobid=$jobId&status=$jobStatus");
            JobImpl job = (JobImpl)app.Submit(conf);

            app.WaitForInternalState(job, JobStateInternal.Succeeded);
            // Unregistration succeeds: successfullyUnregistered is set
            app.ShutDownJob();
            NUnit.Framework.Assert.IsTrue(app.IsLastAMRetry());
            NUnit.Framework.Assert.AreEqual(1, TestJobEndNotifier.JobEndServlet.calledTimes);
            NUnit.Framework.Assert.AreEqual("jobid=" + job.GetID() + "&status=SUCCEEDED", TestJobEndNotifier.JobEndServlet
                                            .requestUri.GetQuery());
            NUnit.Framework.Assert.AreEqual(JobState.Succeeded.ToString(), TestJobEndNotifier.JobEndServlet
                                            .foundJobState);
            server.Stop();
        }
예제 #4
0
        public virtual void TestJobSuccess()
        {
            MRApp   app = new MRApp(2, 2, true, this.GetType().FullName, true, false);
            JobImpl job = (JobImpl)app.Submit(new Configuration());

            app.WaitForInternalState(job, JobStateInternal.Succeeded);
            // AM is not unregistered
            NUnit.Framework.Assert.AreEqual(JobState.Running, job.GetState());
            // imitate that AM is unregistered
            app.successfullyUnregistered.Set(true);
            app.WaitForState(job, JobState.Succeeded);
        }
예제 #5
0
        public virtual void TestJobRebootOnLastRetryOnUnregistrationFailure()
        {
            // make startCount as 2 since this is last retry which equals to
            // DEFAULT_MAX_AM_RETRY
            // The last param mocks the unregistration failure
            MRApp         app  = new MRApp(1, 0, false, this.GetType().FullName, true, 2, false);
            Configuration conf = new Configuration();

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(conf);
            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);
            //send an reboot event
            app.GetContext().GetEventHandler().Handle(new JobEvent(job.GetID(), JobEventType.
                                                                   JobAmReboot));
            app.WaitForInternalState((JobImpl)job, JobStateInternal.Reboot);
            // return exteranl state as RUNNING if this is the last retry while
            // unregistration fails
            app.WaitForState(job, JobState.Running);
        }