예제 #1
0
            /*
             * Uber-AM lifecycle/ordering ("normal" case):
             *
             * - [somebody] sends TA_ASSIGNED
             *   - handled by ContainerAssignedTransition (TaskAttemptImpl.java)
             *     - creates "remoteTask" for us == real Task
             *     - sends CONTAINER_REMOTE_LAUNCH
             *     - TA: UNASSIGNED -> ASSIGNED
             * - CONTAINER_REMOTE_LAUNCH handled by LocalContainerLauncher (us)
             *   - sucks "remoteTask" out of TaskAttemptImpl via getRemoteTask()
             *   - sends TA_CONTAINER_LAUNCHED
             *     [[ elsewhere...
             *       - TA_CONTAINER_LAUNCHED handled by LaunchedContainerTransition
             *         - registers "remoteTask" with TaskAttemptListener (== umbilical)
             *         - NUKES "remoteTask"
             *         - sends T_ATTEMPT_LAUNCHED (Task: SCHEDULED -> RUNNING)
             *         - TA: ASSIGNED -> RUNNING
             *     ]]
             *   - runs Task (runSubMap() or runSubReduce())
             *     - TA can safely send TA_UPDATE since in RUNNING state
             */
            // doneWithMaps and finishedSubMaps are accessed from only
            // one thread. Therefore, no need to make them volatile.
            public virtual void Run()
            {
                ContainerLauncherEvent @event = null;
                // Collect locations of map outputs to give to reduces
                IDictionary <TaskAttemptID, MapOutputFile> localMapFiles = new Dictionary <TaskAttemptID
                                                                                           , MapOutputFile>();

                // _must_ either run subtasks sequentially or accept expense of new JVMs
                // (i.e., fork()), else will get weird failures when maps try to create/
                // write same dirname or filename:  no chdir() in Java
                while (!Sharpen.Thread.CurrentThread().IsInterrupted())
                {
                    try
                    {
                        @event = this._enclosing.eventQueue.Take();
                    }
                    catch (Exception e)
                    {
                        // mostly via T_KILL? JOB_KILL?
                        LocalContainerLauncher.Log.Error("Returning, interrupted : " + e);
                        break;
                    }
                    LocalContainerLauncher.Log.Info("Processing the event " + @event.ToString());
                    if (@event.GetType() == ContainerLauncher.EventType.ContainerRemoteLaunch)
                    {
                        ContainerRemoteLaunchEvent launchEv = (ContainerRemoteLaunchEvent)@event;
                        // execute the task on a separate thread
                        Future <object> future = this._enclosing.taskRunner.Submit(new _Runnable_228(this,
                                                                                                     launchEv, localMapFiles));
                        // remember the current attempt
                        this.futures[@event.GetTaskAttemptID()] = future;
                    }
                    else
                    {
                        if (@event.GetType() == ContainerLauncher.EventType.ContainerRemoteCleanup)
                        {
                            // cancel (and interrupt) the current running task associated with the
                            // event
                            TaskAttemptId   taId   = @event.GetTaskAttemptID();
                            Future <object> future = Sharpen.Collections.Remove(this.futures, taId);
                            if (future != null)
                            {
                                LocalContainerLauncher.Log.Info("canceling the task attempt " + taId);
                                future.Cancel(true);
                            }
                            // send "cleaned" event to task attempt to move us from
                            // SUCCESS_CONTAINER_CLEANUP to SUCCEEDED state (or
                            // {FAIL|KILL}_CONTAINER_CLEANUP to {FAIL|KILL}_TASK_CLEANUP)
                            this._enclosing.context.GetEventHandler().Handle(new TaskAttemptEvent(taId, TaskAttemptEventType
                                                                                                  .TaContainerCleaned));
                        }
                        else
                        {
                            LocalContainerLauncher.Log.Warn("Ignoring unexpected event " + @event.ToString());
                        }
                    }
                }
            }
예제 #2
0
            //We are running locally so set the shuffle port to -1
            public virtual void Handle(ContainerLauncherEvent @event)
            {
                switch (@event.GetType())
                {
                case ContainerLauncher.EventType.ContainerRemoteLaunch:
                {
                    this._enclosing.ContainerLaunched(@event.GetTaskAttemptID(), this.shufflePort);
                    this._enclosing.AttemptLaunched(@event.GetTaskAttemptID());
                    break;
                }

                case ContainerLauncher.EventType.ContainerRemoteCleanup:
                {
                    this._enclosing.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(@event
                                                                                               .GetTaskAttemptID(), TaskAttemptEventType.TaContainerCleaned));
                    break;
                }
                }
            }
예제 #3
0
                public override void Handle(ContainerLauncherEvent @event)
                {
                    switch (@event.GetType())
                    {
                    case ContainerLauncher.EventType.ContainerRemoteLaunch:
                    {
                        base.Handle(@event);
                        // Unused event and container.
                        break;
                    }

                    case ContainerLauncher.EventType.ContainerRemoteCleanup:
                    {
                        this._enclosing.GetContext().GetEventHandler().Handle(new TaskAttemptEvent(@event
                                                                                                   .GetTaskAttemptID(), TaskAttemptEventType.TaContainerCleaned));
                        break;
                    }
                    }
                }