Exemplo n.º 1
0
        /// <summary>Child checking whether it can commit.</summary>
        /// <remarks>
        /// Child checking whether it can commit.
        /// <br />
        /// Commit is a two-phased protocol. First the attempt informs the
        /// ApplicationMaster that it is
        /// <see cref="CommitPending(TaskAttemptID, TaskStatus)"/>
        /// . Then it repeatedly polls
        /// the ApplicationMaster whether it
        /// <see cref="CanCommit(TaskAttemptID)"/>
        /// This is
        /// a legacy from the centralized commit protocol handling by the JobTracker.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        public virtual bool CanCommit(TaskAttemptID taskAttemptID)
        {
            Log.Info("Commit go/no-go request from " + taskAttemptID.ToString());
            // An attempt is asking if it can commit its output. This can be decided
            // only by the task which is managing the multiple attempts. So redirect the
            // request there.
            TaskAttemptId attemptID = TypeConverter.ToYarn(taskAttemptID);

            taskHeartbeatHandler.Progressing(attemptID);
            // tell task to retry later if AM has not heard from RM within the commit
            // window to help avoid double-committing in a split-brain situation
            long now = context.GetClock().GetTime();

            if (now - rmHeartbeatHandler.GetLastHeartbeatTime() > commitWindowMs)
            {
                return(false);
            }
            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = context.GetJob(attemptID.GetTaskId
                                                                                ().GetJobId());
            Task task = job.GetTask(attemptID.GetTaskId());

            return(task.CanCommit(attemptID));
        }