/// <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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        /// <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
                                                  ()));
 }
Exemple #5
0
        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="Com.Google.Protobuf.ServiceException"/>
        public virtual YarnServiceProtos.GetContainersResponseProto GetContainers(RpcController
                                                                                  controller, YarnServiceProtos.GetContainersRequestProto proto)
        {
            GetContainersRequestPBImpl request = new GetContainersRequestPBImpl(proto);

            try
            {
                GetContainersResponse response = real.GetContainers(request);
                return(((GetContainersResponsePBImpl)response).GetProto());
            }
            catch (YarnException e)
            {
                throw new ServiceException(e);
            }
            catch (IOException e)
            {
                throw new ServiceException(e);
            }
        }
        /// <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);
        }