コード例 #1
0
        public virtual void TestARRMResponseId()
        {
            MockNM nm1 = rm.RegisterNode("h1:1234", 5000);
            RMApp  app = rm.SubmitApp(2000);

            // Trigger the scheduling so the AM gets 'launched'
            nm1.NodeHeartbeat(true);
            RMAppAttempt attempt = app.GetCurrentAppAttempt();
            MockAM       am      = rm.SendAMLaunched(attempt.GetAppAttemptId());

            am.RegisterAppAttempt();
            AllocateRequest allocateRequest = AllocateRequest.NewInstance(0, 0F, null, null,
                                                                          null);
            AllocateResponse response = Allocate(attempt.GetAppAttemptId(), allocateRequest);

            NUnit.Framework.Assert.AreEqual(1, response.GetResponseId());
            NUnit.Framework.Assert.IsTrue(response.GetAMCommand() == null);
            allocateRequest = AllocateRequest.NewInstance(response.GetResponseId(), 0F, null,
                                                          null, null);
            response = Allocate(attempt.GetAppAttemptId(), allocateRequest);
            NUnit.Framework.Assert.AreEqual(2, response.GetResponseId());
            /* try resending */
            response = Allocate(attempt.GetAppAttemptId(), allocateRequest);
            NUnit.Framework.Assert.AreEqual(2, response.GetResponseId());
            allocateRequest = AllocateRequest.NewInstance(0, 0F, null, null, null);
            try
            {
                Allocate(attempt.GetAppAttemptId(), allocateRequest);
                NUnit.Framework.Assert.Fail();
            }
            catch (Exception e)
            {
                NUnit.Framework.Assert.IsTrue(e.InnerException is InvalidApplicationMasterRequestException
                                              );
            }
        }