Exemplo n.º 1
0
        public virtual void TestQueueNamePercentEncoding()
        {
            JobIndexInfo info     = new JobIndexInfo();
            JobID        oldJobId = JobID.ForName(JobId);
            JobId        jobId    = TypeConverter.ToYarn(oldJobId);

            info.SetJobId(jobId);
            info.SetSubmitTime(long.Parse(SubmitTime));
            info.SetUser(UserName);
            info.SetJobName(JobName);
            info.SetFinishTime(long.Parse(FinishTime));
            info.SetNumMaps(System.Convert.ToInt32(NumMaps));
            info.SetNumReduces(System.Convert.ToInt32(NumReduces));
            info.SetJobStatus(JobStatus);
            info.SetQueueName(QueueNameWithDelimiter);
            info.SetJobStartTime(long.Parse(JobStartTime));
            string jobHistoryFile = FileNameIndexUtils.GetDoneFileName(info);

            NUnit.Framework.Assert.IsTrue("Queue name not encoded correctly into job history file"
                                          , jobHistoryFile.Contains(QueueNameWithDelimiterEscape));
        }
Exemplo n.º 2
0
        public virtual void TestEncodingDecodingEquivalence()
        {
            JobIndexInfo info     = new JobIndexInfo();
            JobID        oldJobId = JobID.ForName(JobId);
            JobId        jobId    = TypeConverter.ToYarn(oldJobId);

            info.SetJobId(jobId);
            info.SetSubmitTime(long.Parse(SubmitTime));
            info.SetUser(UserName);
            info.SetJobName(JobName);
            info.SetFinishTime(long.Parse(FinishTime));
            info.SetNumMaps(System.Convert.ToInt32(NumMaps));
            info.SetNumReduces(System.Convert.ToInt32(NumReduces));
            info.SetJobStatus(JobStatus);
            info.SetQueueName(QueueName);
            info.SetJobStartTime(long.Parse(JobStartTime));
            string       jobHistoryFile = FileNameIndexUtils.GetDoneFileName(info);
            JobIndexInfo parsedInfo     = FileNameIndexUtils.GetIndexInfo(jobHistoryFile);

            NUnit.Framework.Assert.AreEqual("Job id different after encoding and decoding", info
                                            .GetJobId(), parsedInfo.GetJobId());
            NUnit.Framework.Assert.AreEqual("Submit time different after encoding and decoding"
                                            , info.GetSubmitTime(), parsedInfo.GetSubmitTime());
            NUnit.Framework.Assert.AreEqual("User different after encoding and decoding", info
                                            .GetUser(), parsedInfo.GetUser());
            NUnit.Framework.Assert.AreEqual("Job name different after encoding and decoding",
                                            info.GetJobName(), parsedInfo.GetJobName());
            NUnit.Framework.Assert.AreEqual("Finish time different after encoding and decoding"
                                            , info.GetFinishTime(), parsedInfo.GetFinishTime());
            NUnit.Framework.Assert.AreEqual("Num maps different after encoding and decoding",
                                            info.GetNumMaps(), parsedInfo.GetNumMaps());
            NUnit.Framework.Assert.AreEqual("Num reduces different after encoding and decoding"
                                            , info.GetNumReduces(), parsedInfo.GetNumReduces());
            NUnit.Framework.Assert.AreEqual("Job status different after encoding and decoding"
                                            , info.GetJobStatus(), parsedInfo.GetJobStatus());
            NUnit.Framework.Assert.AreEqual("Queue name different after encoding and decoding"
                                            , info.GetQueueName(), parsedInfo.GetQueueName());
            NUnit.Framework.Assert.AreEqual("Job start time different after encoding and decoding"
                                            , info.GetJobStartTime(), parsedInfo.GetJobStartTime());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parses the provided job history file name to construct a
        /// JobIndexInfo object which is returned.
        /// </summary>
        /// <param name="jhFileName">the job history filename.</param>
        /// <returns>a JobIndexInfo object built from the filename.</returns>
        /// <exception cref="System.IO.IOException"/>
        public static JobIndexInfo GetIndexInfo(string jhFileName)
        {
            string fileName = Sharpen.Runtime.Substring(jhFileName, 0, jhFileName.IndexOf(JobHistoryUtils
                                                                                          .JobHistoryFileExtension));
            JobIndexInfo indexInfo = new JobIndexInfo();

            string[] jobDetails = fileName.Split(Delimiter);
            JobID    oldJobId   = JobID.ForName(DecodeJobHistoryFileName(jobDetails[JobIdIndex]));
            JobId    jobId      = TypeConverter.ToYarn(oldJobId);

            indexInfo.SetJobId(jobId);
            // Do not fail if there are some minor parse errors
            try
            {
                try
                {
                    indexInfo.SetSubmitTime(long.Parse(DecodeJobHistoryFileName(jobDetails[SubmitTimeIndex
                                                                                ])));
                }
                catch (FormatException e)
                {
                    Log.Warn("Unable to parse submit time from job history file " + jhFileName + " : "
                             + e);
                }
                indexInfo.SetUser(DecodeJobHistoryFileName(jobDetails[UserIndex]));
                indexInfo.SetJobName(DecodeJobHistoryFileName(jobDetails[JobNameIndex]));
                try
                {
                    indexInfo.SetFinishTime(long.Parse(DecodeJobHistoryFileName(jobDetails[FinishTimeIndex
                                                                                ])));
                }
                catch (FormatException e)
                {
                    Log.Warn("Unable to parse finish time from job history file " + jhFileName + " : "
                             + e);
                }
                try
                {
                    indexInfo.SetNumMaps(System.Convert.ToInt32(DecodeJobHistoryFileName(jobDetails[NumMapsIndex
                                                                                         ])));
                }
                catch (FormatException e)
                {
                    Log.Warn("Unable to parse num maps from job history file " + jhFileName + " : " +
                             e);
                }
                try
                {
                    indexInfo.SetNumReduces(System.Convert.ToInt32(DecodeJobHistoryFileName(jobDetails
                                                                                            [NumReducesIndex])));
                }
                catch (FormatException e)
                {
                    Log.Warn("Unable to parse num reduces from job history file " + jhFileName + " : "
                             + e);
                }
                indexInfo.SetJobStatus(DecodeJobHistoryFileName(jobDetails[JobStatusIndex]));
                indexInfo.SetQueueName(DecodeJobHistoryFileName(jobDetails[QueueNameIndex]));
                try
                {
                    if (jobDetails.Length <= JobStartTimeIndex)
                    {
                        indexInfo.SetJobStartTime(indexInfo.GetSubmitTime());
                    }
                    else
                    {
                        indexInfo.SetJobStartTime(long.Parse(DecodeJobHistoryFileName(jobDetails[JobStartTimeIndex
                                                                                      ])));
                    }
                }
                catch (FormatException e)
                {
                    Log.Warn("Unable to parse start time from job history file " + jhFileName + " : "
                             + e);
                }
            }
            catch (IndexOutOfRangeException)
            {
                Log.Warn("Parsing job history file with partial data encoded into name: " + jhFileName
                         );
            }
            return(indexInfo);
        }