/// <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 TestReadWriteApplicationHistory() { // Out of order ApplicationId appId = ApplicationId.NewInstance(0, 1); try { WriteApplicationFinishData(appId); NUnit.Framework.Assert.Fail(); } catch (IOException e) { NUnit.Framework.Assert.IsTrue(e.Message.Contains("is stored before the start information" )); } // Normal int numApps = 5; for (int i = 1; i <= numApps; ++i) { appId = ApplicationId.NewInstance(0, i); WriteApplicationStartData(appId); WriteApplicationFinishData(appId); } NUnit.Framework.Assert.AreEqual(numApps, store.GetAllApplications().Count); for (int i_1 = 1; i_1 <= numApps; ++i_1) { appId = ApplicationId.NewInstance(0, i_1); ApplicationHistoryData data = store.GetApplication(appId); NUnit.Framework.Assert.IsNotNull(data); NUnit.Framework.Assert.AreEqual(appId.ToString(), data.GetApplicationName()); NUnit.Framework.Assert.AreEqual(appId.ToString(), data.GetDiagnosticsInfo()); } // Write again appId = ApplicationId.NewInstance(0, 1); try { WriteApplicationStartData(appId); NUnit.Framework.Assert.Fail(); } catch (IOException e) { NUnit.Framework.Assert.IsTrue(e.Message.Contains("is already stored")); } try { WriteApplicationFinishData(appId); NUnit.Framework.Assert.Fail(); } catch (IOException e) { NUnit.Framework.Assert.IsTrue(e.Message.Contains("is already stored")); } }
public virtual void TestWriteApplication() { RMApp app = CreateRMApp(ApplicationId.NewInstance(0, 1)); writer.ApplicationStarted(app); ApplicationHistoryData appHD = null; for (int i = 0; i < MaxRetries; ++i) { appHD = store.GetApplication(ApplicationId.NewInstance(0, 1)); if (appHD != null) { break; } else { Sharpen.Thread.Sleep(100); } } NUnit.Framework.Assert.IsNotNull(appHD); NUnit.Framework.Assert.AreEqual("test app", appHD.GetApplicationName()); NUnit.Framework.Assert.AreEqual("test app type", appHD.GetApplicationType()); NUnit.Framework.Assert.AreEqual("test user", appHD.GetUser()); NUnit.Framework.Assert.AreEqual("test queue", appHD.GetQueue()); NUnit.Framework.Assert.AreEqual(0L, appHD.GetSubmitTime()); NUnit.Framework.Assert.AreEqual(1L, appHD.GetStartTime()); writer.ApplicationFinished(app, RMAppState.Finished); for (int i_1 = 0; i_1 < MaxRetries; ++i_1) { appHD = store.GetApplication(ApplicationId.NewInstance(0, 1)); if (appHD.GetYarnApplicationState() != null) { break; } else { Sharpen.Thread.Sleep(100); } } NUnit.Framework.Assert.AreEqual(2L, appHD.GetFinishTime()); NUnit.Framework.Assert.AreEqual("test diagnostics info", appHD.GetDiagnosticsInfo ()); NUnit.Framework.Assert.AreEqual(FinalApplicationStatus.Undefined, appHD.GetFinalApplicationStatus ()); NUnit.Framework.Assert.AreEqual(YarnApplicationState.Finished, appHD.GetYarnApplicationState ()); }
/// <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)); }