public override async Task <GetContainersResponse> GetContainers(GetContainersRequest request, ServerCallContext context) { var containers = await this.dockerClient.Containers.ListContainersAsync(new Docker.DotNet.Models.ContainersListParameters() { All = request.ShowStopped ? true : false }); var results = containers .Where(it => string.IsNullOrWhiteSpace(request.Name) || (string.Join(", ", it.Names).ToLowerInvariant().Contains(request.Name.ToLowerInvariant())) ) .Select(it => new GetContainersResponse.Types.ContainerInfo() { Name = string.Join(", ", it.Names), Status = it.Status, State = it.State, Image = it.Image, Id = it.ID }).ToArray(); var response = new GetContainersResponse(); response.Results.Add(results); return(response); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual GetContainersResponse GetContainers(GetContainersRequest request) { GetContainersResponse response = GetContainersResponse.NewInstance(new AList <ContainerReport >(history.GetContainers(request.GetApplicationAttemptId()).Values)); return(response); }
public virtual ContainersInfo GetContainers(HttpServletRequest req, HttpServletResponse res, string appId, string appAttemptId) { UserGroupInformation callerUGI = GetUser(req); ApplicationId aid = ParseApplicationId(appId); ApplicationAttemptId aaid = ParseApplicationAttemptId(appAttemptId); ValidateIds(aid, aaid, null); ICollection <ContainerReport> containerReports = null; try { if (callerUGI == null) { GetContainersRequest request = GetContainersRequest.NewInstance(aaid); containerReports = appBaseProt.GetContainers(request).GetContainerList(); } else { containerReports = callerUGI.DoAs(new _PrivilegedExceptionAction_332(this, aaid)); } } catch (Exception e) { RewrapAndThrowException(e); } ContainersInfo containersInfo = new ContainersInfo(); foreach (ContainerReport containerReport in containerReports) { ContainerInfo containerInfo = new ContainerInfo(containerReport); containersInfo.Add(containerInfo); } return(containersInfo); }
/// <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()); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public override GetContainersResponse GetContainers(GetContainersRequest request) { this._enclosing.ResetStartFailoverFlag(true); // make sure failover has been triggered NUnit.Framework.Assert.IsTrue(this._enclosing.WaittingForFailOver()); // return fake ContainerReports return(GetContainersResponse.NewInstance(this._enclosing.CreateFakeContainerReports ())); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual GetContainersResponse GetContainers(GetContainersRequest request) { YarnServiceProtos.GetContainersRequestProto requestProto = ((GetContainersRequestPBImpl )request).GetProto(); try { return(new GetContainersResponsePBImpl(proxy.GetContainers(null, requestProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
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); }
protected override void Render(HtmlBlock.Block html) { string attemptid = $(YarnWebParams.ApplicationAttemptId); if (attemptid.IsEmpty()) { Puts("Bad request: requires application attempt ID"); return; } try { appAttemptId = ConverterUtils.ToApplicationAttemptId(attemptid); } catch (ArgumentException) { Puts("Invalid application attempt ID: " + attemptid); return; } UserGroupInformation callerUGI = GetCallerUGI(); ApplicationAttemptReport appAttemptReport; try { GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.NewInstance (appAttemptId); if (callerUGI == null) { appAttemptReport = appBaseProt.GetApplicationAttemptReport(request).GetApplicationAttemptReport (); } else { appAttemptReport = callerUGI.DoAs(new _PrivilegedExceptionAction_85(this, request )); } } catch (Exception e) { string message = "Failed to read the application attempt " + appAttemptId + "."; Log.Error(message, e); html.P().(message).(); return; } if (appAttemptReport == null) { Puts("Application Attempt not found: " + attemptid); return; } bool exceptionWhenGetContainerReports = false; ICollection <ContainerReport> containers = null; try { GetContainersRequest request = GetContainersRequest.NewInstance(appAttemptId); if (callerUGI == null) { containers = appBaseProt.GetContainers(request).GetContainerList(); } else { containers = callerUGI.DoAs(new _PrivilegedExceptionAction_115(this, request)); } } catch (RuntimeException) { // have this block to suppress the findbugs warning exceptionWhenGetContainerReports = true; } catch (Exception) { exceptionWhenGetContainerReports = true; } AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport); SetTitle(StringHelper.Join("Application Attempt ", attemptid)); string node = "N/A"; if (appAttempt.GetHost() != null && appAttempt.GetRpcPort() >= 0 && appAttempt.GetRpcPort () < 65536) { node = appAttempt.GetHost() + ":" + appAttempt.GetRpcPort(); } GenerateOverview(appAttemptReport, containers, appAttempt, node); if (exceptionWhenGetContainerReports) { html.P().("Sorry, Failed to get containers for application attempt" + attemptid + ".").(); return; } CreateAttemptHeadRoomTable(html); html.(typeof(InfoBlock)); CreateTablesForAttemptMetrics(html); // Container Table Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = html .Table("#containers").Thead().Tr().Th(".id", "Container ID").Th(".node", "Node") .Th(".exitstatus", "Container Exit Status").Th(".logs", "Logs").().().Tbody(); StringBuilder containersTableData = new StringBuilder("[\n"); foreach (ContainerReport containerReport in containers) { ContainerInfo container = new ContainerInfo(containerReport); containersTableData.Append("[\"<a href='").Append(Url("container", container.GetContainerId ())).Append("'>").Append(container.GetContainerId()).Append("</a>\",\"<a ").Append (container.GetNodeHttpAddress() == null ? "#" : "href='" + container.GetNodeHttpAddress ()).Append("'>").Append(container.GetNodeHttpAddress() == null ? "N/A" : StringEscapeUtils .EscapeJavaScript(StringEscapeUtils.EscapeHtml(container.GetNodeHttpAddress()))) .Append("</a>\",\"").Append(container.GetContainerExitStatus()).Append("\",\"<a href='" ).Append(container.GetLogUrl() == null ? "#" : container.GetLogUrl()).Append("'>" ).Append(container.GetLogUrl() == null ? "N/A" : "Logs").Append("</a>\"],\n"); } if (containersTableData[containersTableData.Length - 2] == ',') { containersTableData.Delete(containersTableData.Length - 2, containersTableData.Length - 1); } containersTableData.Append("]"); html.Script().$type("text/javascript").("var containersTableData=" + containersTableData ).(); tbody.().(); }
public _PrivilegedExceptionAction_115(AppAttemptBlock _enclosing, GetContainersRequest request) { this._enclosing = _enclosing; this.request = request; }
/// <exception cref="System.Exception"/> public ICollection <ContainerReport> Run() { GetContainersRequest request = GetContainersRequest.NewInstance(aaid); return(this._enclosing.appBaseProt.GetContainers(request).GetContainerList()); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual GetContainersResponse GetContainers(GetContainersRequest request) { return(null); }