/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public override IList <ContainerReport> GetContainers(ApplicationAttemptId appAttemptId ) { Org.Mockito.Mockito.When(mockContainersResponse.GetContainerList()).ThenReturn(GetContainersReport (appAttemptId)); return(base.GetContainers(appAttemptId)); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public override IList <ContainerReport> GetContainers(ApplicationAttemptId applicationAttemptId ) { GetContainersRequest request = GetContainersRequest.NewInstance(applicationAttemptId ); GetContainersResponse response = ahsClient.GetContainers(request); return(response.GetContainerList()); }
public virtual void TestContainers() { ApplicationId appId = ApplicationId.NewInstance(0, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.NewInstance(appId, 1); ContainerId containerId = ContainerId.NewContainerId(appAttemptId, 1); ContainerId containerId1 = ContainerId.NewContainerId(appAttemptId, 2); GetContainersRequest request = GetContainersRequest.NewInstance(appAttemptId); GetContainersResponse response = clientService.GetContainers(request); IList <ContainerReport> containers = response.GetContainerList(); NUnit.Framework.Assert.IsNotNull(containers); NUnit.Framework.Assert.AreEqual(containerId, containers[0].GetContainerId()); NUnit.Framework.Assert.AreEqual(containerId1, containers[1].GetContainerId()); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public override IList <ContainerReport> GetContainers(ApplicationAttemptId applicationAttemptId ) { IList <ContainerReport> containersForAttempt = new AList <ContainerReport>(); bool appNotFoundInRM = false; try { GetContainersRequest request = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <GetContainersRequest >(); request.SetApplicationAttemptId(applicationAttemptId); GetContainersResponse response = rmClient.GetContainers(request); Sharpen.Collections.AddAll(containersForAttempt, response.GetContainerList()); } catch (YarnException e) { if (e.GetType() != typeof(ApplicationNotFoundException) || !historyServiceEnabled) { // If Application is not in RM and history service is enabled then we // need to check with history service else throw exception. throw; } appNotFoundInRM = true; } if (historyServiceEnabled) { // Check with AHS even if found in RM because to capture info of finished // containers also IList <ContainerReport> containersListFromAHS = null; try { containersListFromAHS = historyClient.GetContainers(applicationAttemptId); } catch (IOException e) { // History service access might be enabled but system metrics publisher // is disabled hence app not found exception is possible if (appNotFoundInRM) { // app not found in bothM and RM then propagate the exception. throw; } } if (null != containersListFromAHS && containersListFromAHS.Count > 0) { // remove duplicates ICollection <ContainerId> containerIdsToBeKeptFromAHS = new HashSet <ContainerId>(); IEnumerator <ContainerReport> tmpItr = containersListFromAHS.GetEnumerator(); while (tmpItr.HasNext()) { containerIdsToBeKeptFromAHS.AddItem(tmpItr.Next().GetContainerId()); } IEnumerator <ContainerReport> rmContainers = containersForAttempt.GetEnumerator(); while (rmContainers.HasNext()) { ContainerReport tmp = rmContainers.Next(); containerIdsToBeKeptFromAHS.Remove(tmp.GetContainerId()); } // Remove containers from AHS as container from RM will have latest // information if (containerIdsToBeKeptFromAHS.Count > 0 && containersListFromAHS.Count != containerIdsToBeKeptFromAHS .Count) { IEnumerator <ContainerReport> containersFromHS = containersListFromAHS.GetEnumerator (); while (containersFromHS.HasNext()) { ContainerReport containerReport = containersFromHS.Next(); if (containerIdsToBeKeptFromAHS.Contains(containerReport.GetContainerId())) { containersForAttempt.AddItem(containerReport); } } } else { if (containersListFromAHS.Count == containerIdsToBeKeptFromAHS.Count) { Sharpen.Collections.AddAll(containersForAttempt, containersListFromAHS); } } } } return(containersForAttempt); }