public virtual void Setup()
 {
     serviceResponse.Clear();
     serviceResponse[ShuffleHandler.MapreduceShuffleServiceid] = ShuffleHandler.SerializeMetaData
                                                                     (80);
 }
Ejemplo n.º 2
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);
             }
         }
     }
 }