Esempio n. 1
0
            protected internal override Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job CreateJob(
                Configuration conf, JobStateInternal forcedState, string diagnostic)
            {
                JobImpl jobImpl = Org.Mockito.Mockito.Mock <JobImpl>();

                Org.Mockito.Mockito.When(jobImpl.GetInternalState()).ThenReturn(this.jobStateInternal
                                                                                );
                Org.Mockito.Mockito.When(jobImpl.GetAllCounters()).ThenReturn(new Counters());
                JobID jobID = JobID.ForName("job_1234567890000_0001");
                JobId jobId = TypeConverter.ToYarn(jobID);

                Org.Mockito.Mockito.When(jobImpl.GetID()).ThenReturn(jobId);
                ((AppContext)this.GetContext()).GetAllJobs()[jobImpl.GetID()] = jobImpl;
                return(jobImpl);
            }
Esempio n. 2
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();
        }