Ejemplo n.º 1
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        public override JobStatus GetJobStatus(JobID jobID)
        {
            JobStatus status = clientCache.GetClient(jobID).GetJobStatus(jobID);

            return(status);
        }
Ejemplo n.º 2
0
 private bool IsJobInTerminalState(JobStatus status)
 {
     return(status.GetState() == JobStatus.State.Killed || status.GetState() == JobStatus.State
            .Failed || status.GetState() == JobStatus.State.Succeeded);
 }
Ejemplo n.º 3
0
        public virtual void TestReconnectOnAMRestart()
        {
            //test not applicable when AM not reachable
            //as instantiateAMProxy is not called at all
            if (!isAMReachableFromClient)
            {
                return;
            }
            MRClientProtocol historyServerProxy = Org.Mockito.Mockito.Mock <MRClientProtocol>(
                );
            // RM returns AM1 url, null, null and AM2 url on invocations.
            // Nulls simulate the time when AM2 is in the process of restarting.
            ResourceMgrDelegate rmDelegate = Org.Mockito.Mockito.Mock <ResourceMgrDelegate>();

            try
            {
                Org.Mockito.Mockito.When(rmDelegate.GetApplicationReport(jobId.GetAppId())).ThenReturn
                    (GetRunningApplicationReport("am1", 78)).ThenReturn(GetRunningApplicationReport(
                                                                            null, 0)).ThenReturn(GetRunningApplicationReport(null, 0)).ThenReturn(GetRunningApplicationReport
                                                                                                                                                      ("am2", 90));
            }
            catch (YarnException e)
            {
                throw new IOException(e);
            }
            Org.Apache.Hadoop.Mapreduce.V2.Api.Protocolrecords.GetJobReportResponse jobReportResponse1
                = Org.Mockito.Mockito.Mock <Org.Apache.Hadoop.Mapreduce.V2.Api.Protocolrecords.GetJobReportResponse
                                            >();
            Org.Mockito.Mockito.When(jobReportResponse1.GetJobReport()).ThenReturn(MRBuilderUtils
                                                                                   .NewJobReport(jobId, "jobName-firstGen", "user", JobState.Running, 0, 0, 0, 0, 0
                                                                                                 , 0, 0, "anything", null, false, string.Empty));
            // First AM returns a report with jobName firstGen and simulates AM shutdown
            // on second invocation.
            MRClientProtocol firstGenAMProxy = Org.Mockito.Mockito.Mock <MRClientProtocol>();

            Org.Mockito.Mockito.When(firstGenAMProxy.GetJobReport(Matchers.Any <Org.Apache.Hadoop.Mapreduce.V2.Api.Protocolrecords.GetJobReportRequest
                                                                                >())).ThenReturn(jobReportResponse1).ThenThrow(new RuntimeException("AM is down!"
                                                                                                                                                    ));
            Org.Apache.Hadoop.Mapreduce.V2.Api.Protocolrecords.GetJobReportResponse jobReportResponse2
                = Org.Mockito.Mockito.Mock <Org.Apache.Hadoop.Mapreduce.V2.Api.Protocolrecords.GetJobReportResponse
                                            >();
            Org.Mockito.Mockito.When(jobReportResponse2.GetJobReport()).ThenReturn(MRBuilderUtils
                                                                                   .NewJobReport(jobId, "jobName-secondGen", "user", JobState.Running, 0, 0, 0, 0,
                                                                                                 0, 0, 0, "anything", null, false, string.Empty));
            // Second AM generation returns a report with jobName secondGen
            MRClientProtocol secondGenAMProxy = Org.Mockito.Mockito.Mock <MRClientProtocol>();

            Org.Mockito.Mockito.When(secondGenAMProxy.GetJobReport(Matchers.Any <Org.Apache.Hadoop.Mapreduce.V2.Api.Protocolrecords.GetJobReportRequest
                                                                                 >())).ThenReturn(jobReportResponse2);
            ClientServiceDelegate clientServiceDelegate = Org.Mockito.Mockito.Spy(GetClientServiceDelegate
                                                                                      (historyServerProxy, rmDelegate));

            // First time, connection should be to AM1, then to AM2. Further requests
            // should use the same proxy to AM2 and so instantiateProxy shouldn't be
            // called.
            Org.Mockito.Mockito.DoReturn(firstGenAMProxy).DoReturn(secondGenAMProxy).When(clientServiceDelegate
                                                                                          ).InstantiateAMProxy(Matchers.Any <IPEndPoint>());
            JobStatus jobStatus = clientServiceDelegate.GetJobStatus(oldJobId);

            NUnit.Framework.Assert.IsNotNull(jobStatus);
            NUnit.Framework.Assert.AreEqual("jobName-firstGen", jobStatus.GetJobName());
            jobStatus = clientServiceDelegate.GetJobStatus(oldJobId);
            NUnit.Framework.Assert.IsNotNull(jobStatus);
            NUnit.Framework.Assert.AreEqual("jobName-secondGen", jobStatus.GetJobName());
            jobStatus = clientServiceDelegate.GetJobStatus(oldJobId);
            NUnit.Framework.Assert.IsNotNull(jobStatus);
            NUnit.Framework.Assert.AreEqual("jobName-secondGen", jobStatus.GetJobName());
            Org.Mockito.Mockito.Verify(clientServiceDelegate, Org.Mockito.Mockito.Times(2)).InstantiateAMProxy
                (Matchers.Any <IPEndPoint>());
        }