コード例 #1
0
					 GetCMProxy(string containerMgrBindAddr, ContainerId containerId)
				{
					IPEndPoint addr = NetUtils.GetConnectAddress(this._enclosing._enclosing.server);
					string containerManagerBindAddr = addr.GetHostName() + ":" + addr.Port;
					Token token = this._enclosing.tokenSecretManager.CreateNMToken(containerId.GetApplicationAttemptId
						(), NodeId.NewInstance(addr.GetHostName(), addr.Port), "user");
					ContainerManagementProtocolProxy cmProxy = new ContainerManagementProtocolProxy(this
						._enclosing._enclosing.conf);
					ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData proxy = new 
						ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData(this, YarnRPC
						.Create(this._enclosing._enclosing.conf), containerManagerBindAddr, containerId, 
						token);
					return proxy;
				}
コード例 #2
0
 GetCMProxy(string containerMgrBindAddr, ContainerId containerId)
 {
     ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData protocolProxy
         = Org.Mockito.Mockito.Mock <ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData
                                     >();
     Org.Mockito.Mockito.When(protocolProxy.GetContainerManagementProtocol()).ThenReturn
         (containerManager);
     return(protocolProxy);
 }
コード例 #3
0
 public virtual void Kill()
 {
     lock (this)
     {
         if (this.state == ContainerLauncherImpl.ContainerState.Prep)
         {
             this.state = ContainerLauncherImpl.ContainerState.KilledBeforeLaunch;
         }
         else
         {
             if (!this.IsCompletelyDone())
             {
                 ContainerLauncherImpl.Log.Info("KILLING " + this.taskAttemptID);
                 ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData proxy = null;
                 try
                 {
                     proxy = this._enclosing.GetCMProxy(this.containerMgrAddress, this.containerID);
                     // kill the remote container if already launched
                     IList <ContainerId> ids = new AList <ContainerId>();
                     ids.AddItem(this.containerID);
                     StopContainersRequest  request  = StopContainersRequest.NewInstance(ids);
                     StopContainersResponse response = proxy.GetContainerManagementProtocol().StopContainers
                                                           (request);
                     if (response.GetFailedRequests() != null && response.GetFailedRequests().Contains
                             (this.containerID))
                     {
                         throw response.GetFailedRequests()[this.containerID].DeSerialize();
                     }
                 }
                 catch (Exception t)
                 {
                     // ignore the cleanup failure
                     string message = "cleanup failed for container " + this.containerID + " : " + StringUtils
                                      .StringifyException(t);
                     this._enclosing.context.GetEventHandler().Handle(new TaskAttemptDiagnosticsUpdateEvent
                                                                          (this.taskAttemptID, message));
                     ContainerLauncherImpl.Log.Warn(message);
                 }
                 finally
                 {
                     if (proxy != null)
                     {
                         this._enclosing.cmProxy.MayBeCloseProxy(proxy);
                     }
                 }
                 this.state = ContainerLauncherImpl.ContainerState.Done;
             }
         }
         // after killing, send killed event to task attempt
         this._enclosing.context.GetEventHandler().Handle(new TaskAttemptEvent(this.taskAttemptID
                                                                               , TaskAttemptEventType.TaContainerCleaned));
     }
 }
コード例 #4
0
 public virtual void Launch(ContainerRemoteLaunchEvent @event)
 {
     lock (this)
     {
         ContainerLauncherImpl.Log.Info("Launching " + this.taskAttemptID);
         if (this.state == ContainerLauncherImpl.ContainerState.KilledBeforeLaunch)
         {
             this.state = ContainerLauncherImpl.ContainerState.Done;
             this._enclosing.SendContainerLaunchFailedMsg(this.taskAttemptID, "Container was killed before it was launched"
                                                          );
             return;
         }
         ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData proxy = null;
         try
         {
             proxy = this._enclosing.GetCMProxy(this.containerMgrAddress, this.containerID);
             // Construct the actual Container
             ContainerLaunchContext containerLaunchContext = @event.GetContainerLaunchContext(
                 );
             // Now launch the actual container
             StartContainerRequest startRequest = StartContainerRequest.NewInstance(containerLaunchContext
                                                                                    , @event.GetContainerToken());
             IList <StartContainerRequest> list = new AList <StartContainerRequest>();
             list.AddItem(startRequest);
             StartContainersRequest  requestList = StartContainersRequest.NewInstance(list);
             StartContainersResponse response    = proxy.GetContainerManagementProtocol().StartContainers
                                                       (requestList);
             if (response.GetFailedRequests() != null && response.GetFailedRequests().Contains
                     (this.containerID))
             {
                 throw response.GetFailedRequests()[this.containerID].DeSerialize();
             }
             ByteBuffer portInfo = response.GetAllServicesMetaData()[ShuffleHandler.MapreduceShuffleServiceid
                                   ];
             int port = -1;
             if (portInfo != null)
             {
                 port = ShuffleHandler.DeserializeMetaData(portInfo);
             }
             ContainerLauncherImpl.Log.Info("Shuffle port returned by ContainerManager for " +
                                            this.taskAttemptID + " : " + port);
             if (port < 0)
             {
                 this.state = ContainerLauncherImpl.ContainerState.Failed;
                 throw new InvalidOperationException("Invalid shuffle port number " + port + " returned for "
                                                     + this.taskAttemptID);
             }
             // after launching, send launched event to task attempt to move
             // it from ASSIGNED to RUNNING state
             this._enclosing.context.GetEventHandler().Handle(new TaskAttemptContainerLaunchedEvent
                                                                  (this.taskAttemptID, port));
             this.state = ContainerLauncherImpl.ContainerState.Running;
         }
         catch (Exception t)
         {
             string message = "Container launch failed for " + this.containerID + " : " + StringUtils
                              .StringifyException(t);
             this.state = ContainerLauncherImpl.ContainerState.Failed;
             this._enclosing.SendContainerLaunchFailedMsg(this.taskAttemptID, message);
         }
         finally
         {
             if (proxy != null)
             {
                 this._enclosing.cmProxy.MayBeCloseProxy(proxy);
             }
         }
     }
 }