Exemplo n.º 1
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        private void StopContainerInternal(ContainerId containerId, NodeId nodeId)
        {
            ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData proxy = null;
            IList <ContainerId> containerIds = new AList <ContainerId>();

            containerIds.AddItem(containerId);
            try
            {
                proxy = cmProxy.GetProxy(nodeId.ToString(), containerId);
                StopContainersResponse response = proxy.GetContainerManagementProtocol().StopContainers
                                                      (StopContainersRequest.NewInstance(containerIds));
                if (response.GetFailedRequests() != null && response.GetFailedRequests().Contains
                        (containerId))
                {
                    Exception t = response.GetFailedRequests()[containerId].DeSerialize();
                    ParseAndThrowException(t);
                }
            }
            finally
            {
                if (proxy != null)
                {
                    cmProxy.MayBeCloseProxy(proxy);
                }
            }
        }
Exemplo n.º 2
0
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        public override ContainerStatus GetContainerStatus(ContainerId containerId, NodeId
                                                           nodeId)
        {
            ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData proxy = null;
            IList <ContainerId> containerIds = new AList <ContainerId>();

            containerIds.AddItem(containerId);
            try
            {
                proxy = cmProxy.GetProxy(nodeId.ToString(), containerId);
                GetContainerStatusesResponse response = proxy.GetContainerManagementProtocol().GetContainerStatuses
                                                            (GetContainerStatusesRequest.NewInstance(containerIds));
                if (response.GetFailedRequests() != null && response.GetFailedRequests().Contains
                        (containerId))
                {
                    Exception t = response.GetFailedRequests()[containerId].DeSerialize();
                    ParseAndThrowException(t);
                }
                ContainerStatus containerStatus = response.GetContainerStatuses()[0];
                return(containerStatus);
            }
            finally
            {
                if (proxy != null)
                {
                    cmProxy.MayBeCloseProxy(proxy);
                }
            }
        }
Exemplo n.º 3
0
 private bool TryCloseProxy(ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData
                            proxy)
 {
     proxy.activeCallers--;
     if (proxy.scheduledForClose && proxy.activeCallers < 0)
     {
         Log.Info("Closing proxy : " + proxy.containerManagerBindAddr);
         Sharpen.Collections.Remove(cmProxy, proxy.containerManagerBindAddr);
         try
         {
             rpc.StopProxy(proxy.GetContainerManagementProtocol(), conf);
         }
         finally
         {
             Sharpen.Runtime.NotifyAll(this);
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
 /// <exception cref="System.IO.IOException"/>
 public override IDictionary <string, ByteBuffer> StartContainer(Container container
                                                                 , ContainerLaunchContext containerLaunchContext)
 {
     // Do synchronization on StartedContainer to prevent race condition
     // between startContainer and stopContainer only when startContainer is
     // in progress for a given container.
     NMClientImpl.StartedContainer startingContainer = CreateStartedContainer(container
                                                                              );
     lock (startingContainer)
     {
         AddStartingContainer(startingContainer);
         IDictionary <string, ByteBuffer> allServiceResponse;
         ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData proxy = null;
         try
         {
             proxy = cmProxy.GetProxy(container.GetNodeId().ToString(), container.GetId());
             StartContainerRequest scRequest = StartContainerRequest.NewInstance(containerLaunchContext
                                                                                 , container.GetContainerToken());
             IList <StartContainerRequest> list = new AList <StartContainerRequest>();
             list.AddItem(scRequest);
             StartContainersRequest  allRequests = StartContainersRequest.NewInstance(list);
             StartContainersResponse response    = proxy.GetContainerManagementProtocol().StartContainers
                                                       (allRequests);
             if (response.GetFailedRequests() != null && response.GetFailedRequests().Contains
                     (container.GetId()))
             {
                 Exception t = response.GetFailedRequests()[container.GetId()].DeSerialize();
                 ParseAndThrowException(t);
             }
             allServiceResponse      = response.GetAllServicesMetaData();
             startingContainer.state = ContainerState.Running;
         }
         catch (YarnException e)
         {
             startingContainer.state = ContainerState.Complete;
             // Remove the started container if it failed to start
             RemoveStartedContainer(startingContainer);
             throw;
         }
         catch (IOException e)
         {
             startingContainer.state = ContainerState.Complete;
             RemoveStartedContainer(startingContainer);
             throw;
         }
         catch (Exception t)
         {
             startingContainer.state = ContainerState.Complete;
             RemoveStartedContainer(startingContainer);
             throw RPCUtil.GetRemoteException(t);
         }
         finally
         {
             if (proxy != null)
             {
                 cmProxy.MayBeCloseProxy(proxy);
             }
         }
         return(allServiceResponse);
     }
 }