public virtual void TestReadWriteApplicationAttemptHistory()
        {
            // Out of order
            ApplicationId        appId        = ApplicationId.NewInstance(0, 1);
            ApplicationAttemptId appAttemptId = ApplicationAttemptId.NewInstance(appId, 1);

            try
            {
                WriteApplicationAttemptFinishData(appAttemptId);
                NUnit.Framework.Assert.Fail();
            }
            catch (IOException e)
            {
                NUnit.Framework.Assert.IsTrue(e.Message.Contains("is stored before the start information"
                                                                 ));
            }
            // Normal
            int numAppAttempts = 5;

            WriteApplicationStartData(appId);
            for (int i = 1; i <= numAppAttempts; ++i)
            {
                appAttemptId = ApplicationAttemptId.NewInstance(appId, i);
                WriteApplicationAttemptStartData(appAttemptId);
                WriteApplicationAttemptFinishData(appAttemptId);
            }
            NUnit.Framework.Assert.AreEqual(numAppAttempts, store.GetApplicationAttempts(appId
                                                                                         ).Count);
            for (int i_1 = 1; i_1 <= numAppAttempts; ++i_1)
            {
                appAttemptId = ApplicationAttemptId.NewInstance(appId, i_1);
                ApplicationAttemptHistoryData data = store.GetApplicationAttempt(appAttemptId);
                NUnit.Framework.Assert.IsNotNull(data);
                NUnit.Framework.Assert.AreEqual(appAttemptId.ToString(), data.GetHost());
                NUnit.Framework.Assert.AreEqual(appAttemptId.ToString(), data.GetDiagnosticsInfo(
                                                    ));
            }
            WriteApplicationFinishData(appId);
            // Write again
            appAttemptId = ApplicationAttemptId.NewInstance(appId, 1);
            try
            {
                WriteApplicationAttemptStartData(appAttemptId);
                NUnit.Framework.Assert.Fail();
            }
            catch (IOException e)
            {
                NUnit.Framework.Assert.IsTrue(e.Message.Contains("is already stored"));
            }
            try
            {
                WriteApplicationAttemptFinishData(appAttemptId);
                NUnit.Framework.Assert.Fail();
            }
            catch (IOException e)
            {
                NUnit.Framework.Assert.IsTrue(e.Message.Contains("is already stored"));
            }
        }
 private ApplicationAttemptReport ConvertToApplicationAttemptReport(ApplicationAttemptHistoryData
                                                                    appAttemptHistory)
 {
     return(ApplicationAttemptReport.NewInstance(appAttemptHistory.GetApplicationAttemptId
                                                     (), appAttemptHistory.GetHost(), appAttemptHistory.GetRPCPort(), appAttemptHistory
                                                 .GetTrackingURL(), null, appAttemptHistory.GetDiagnosticsInfo(), appAttemptHistory
                                                 .GetYarnApplicationAttemptState(), appAttemptHistory.GetMasterContainerId()));
 }
Exemplo n.º 3
0
 /// <exception cref="System.IO.IOException"/>
 private void TestReadHistoryData(int num, bool missingContainer, bool missingApplicationAttempt
                                  )
 {
     // read application history data
     NUnit.Framework.Assert.AreEqual(num, store.GetAllApplications().Count);
     for (int i = 1; i <= num; ++i)
     {
         ApplicationId          appId   = ApplicationId.NewInstance(0, i);
         ApplicationHistoryData appData = store.GetApplication(appId);
         NUnit.Framework.Assert.IsNotNull(appData);
         NUnit.Framework.Assert.AreEqual(appId.ToString(), appData.GetApplicationName());
         NUnit.Framework.Assert.AreEqual(appId.ToString(), appData.GetDiagnosticsInfo());
         // read application attempt history data
         NUnit.Framework.Assert.AreEqual(num, store.GetApplicationAttempts(appId).Count);
         for (int j = 1; j <= num; ++j)
         {
             ApplicationAttemptId          appAttemptId = ApplicationAttemptId.NewInstance(appId, j);
             ApplicationAttemptHistoryData attemptData  = store.GetApplicationAttempt(appAttemptId
                                                                                      );
             NUnit.Framework.Assert.IsNotNull(attemptData);
             NUnit.Framework.Assert.AreEqual(appAttemptId.ToString(), attemptData.GetHost());
             if (missingApplicationAttempt && j == num)
             {
                 NUnit.Framework.Assert.IsNull(attemptData.GetDiagnosticsInfo());
                 continue;
             }
             else
             {
                 NUnit.Framework.Assert.AreEqual(appAttemptId.ToString(), attemptData.GetDiagnosticsInfo
                                                     ());
             }
             // read container history data
             NUnit.Framework.Assert.AreEqual(num, store.GetContainers(appAttemptId).Count);
             for (int k = 1; k <= num; ++k)
             {
                 ContainerId          containerId   = ContainerId.NewContainerId(appAttemptId, k);
                 ContainerHistoryData containerData = store.GetContainer(containerId);
                 NUnit.Framework.Assert.IsNotNull(containerData);
                 NUnit.Framework.Assert.AreEqual(Priority.NewInstance(containerId.GetId()), containerData
                                                 .GetPriority());
                 if (missingContainer && k == num)
                 {
                     NUnit.Framework.Assert.IsNull(containerData.GetDiagnosticsInfo());
                 }
                 else
                 {
                     NUnit.Framework.Assert.AreEqual(containerId.ToString(), containerData.GetDiagnosticsInfo
                                                         ());
                 }
             }
             ContainerHistoryData masterContainer = store.GetAMContainer(appAttemptId);
             NUnit.Framework.Assert.IsNotNull(masterContainer);
             NUnit.Framework.Assert.AreEqual(ContainerId.NewContainerId(appAttemptId, 1), masterContainer
                                             .GetContainerId());
         }
     }
 }
        public virtual void TestWriteApplicationAttempt()
        {
            RMAppAttempt appAttempt = CreateRMAppAttempt(ApplicationAttemptId.NewInstance(ApplicationId
                                                                                          .NewInstance(0, 1), 1));

            writer.ApplicationAttemptStarted(appAttempt);
            ApplicationAttemptHistoryData appAttemptHD = null;

            for (int i = 0; i < MaxRetries; ++i)
            {
                appAttemptHD = store.GetApplicationAttempt(ApplicationAttemptId.NewInstance(ApplicationId
                                                                                            .NewInstance(0, 1), 1));
                if (appAttemptHD != null)
                {
                    break;
                }
                else
                {
                    Sharpen.Thread.Sleep(100);
                }
            }
            NUnit.Framework.Assert.IsNotNull(appAttemptHD);
            NUnit.Framework.Assert.AreEqual("test host", appAttemptHD.GetHost());
            NUnit.Framework.Assert.AreEqual(-100, appAttemptHD.GetRPCPort());
            NUnit.Framework.Assert.AreEqual(ContainerId.NewContainerId(ApplicationAttemptId.NewInstance
                                                                           (ApplicationId.NewInstance(0, 1), 1), 1), appAttemptHD.GetMasterContainerId());
            writer.ApplicationAttemptFinished(appAttempt, RMAppAttemptState.Finished);
            for (int i_1 = 0; i_1 < MaxRetries; ++i_1)
            {
                appAttemptHD = store.GetApplicationAttempt(ApplicationAttemptId.NewInstance(ApplicationId
                                                                                            .NewInstance(0, 1), 1));
                if (appAttemptHD.GetYarnApplicationAttemptState() != null)
                {
                    break;
                }
                else
                {
                    Sharpen.Thread.Sleep(100);
                }
            }
            NUnit.Framework.Assert.AreEqual("test diagnostics info", appAttemptHD.GetDiagnosticsInfo
                                                ());
            NUnit.Framework.Assert.AreEqual("test url", appAttemptHD.GetTrackingURL());
            NUnit.Framework.Assert.AreEqual(FinalApplicationStatus.Undefined, appAttemptHD.GetFinalApplicationStatus
                                                ());
            NUnit.Framework.Assert.AreEqual(YarnApplicationAttemptState.Finished, appAttemptHD
                                            .GetYarnApplicationAttemptState());
        }
        /// <exception cref="System.IO.IOException"/>
        private ApplicationReport ConvertToApplicationReport(ApplicationHistoryData appHistory
                                                             )
        {
            ApplicationAttemptId currentApplicationAttemptId = null;
            string trackingUrl = Unavailable;
            string host        = Unavailable;
            int    rpcPort     = -1;
            ApplicationAttemptHistoryData lastAttempt = GetLastAttempt(appHistory.GetApplicationId
                                                                           ());

            if (lastAttempt != null)
            {
                currentApplicationAttemptId = lastAttempt.GetApplicationAttemptId();
                trackingUrl = lastAttempt.GetTrackingURL();
                host        = lastAttempt.GetHost();
                rpcPort     = lastAttempt.GetRPCPort();
            }
            return(ApplicationReport.NewInstance(appHistory.GetApplicationId(), currentApplicationAttemptId
                                                 , appHistory.GetUser(), appHistory.GetQueue(), appHistory.GetApplicationName(),
                                                 host, rpcPort, null, appHistory.GetYarnApplicationState(), appHistory.GetDiagnosticsInfo
                                                     (), trackingUrl, appHistory.GetStartTime(), appHistory.GetFinishTime(), appHistory
                                                 .GetFinalApplicationStatus(), null, string.Empty, 100, appHistory.GetApplicationType
                                                     (), null));
        }