public virtual void TestJobStartTimeBackwardsCompatible() { string jobHistoryFile = string.Format(OldFormatBeforeAddStartTime, JobId, SubmitTime , UserName, JobNameWithDelimiterEscape, FinishTime, NumMaps, NumReduces, JobStatus , QueueName); JobIndexInfo info = FileNameIndexUtils.GetIndexInfo(jobHistoryFile); NUnit.Framework.Assert.AreEqual(info.GetJobStartTime(), info.GetSubmitTime()); }
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()); }
// Sanitize job history file for predictable parsing // Job history file names need to be backwards compatible // Only append new elements to the end of this list /// <summary>Constructs the job history file name from the JobIndexInfo.</summary> /// <param name="indexInfo">the index info.</param> /// <returns>the done job history filename.</returns> /// <exception cref="System.IO.IOException"/> public static string GetDoneFileName(JobIndexInfo indexInfo) { StringBuilder sb = new StringBuilder(); //JobId sb.Append(EscapeDelimiters(TypeConverter.FromYarn(indexInfo.GetJobId()).ToString( ))); sb.Append(Delimiter); //SubmitTime sb.Append(indexInfo.GetSubmitTime()); sb.Append(Delimiter); //UserName sb.Append(EscapeDelimiters(GetUserName(indexInfo))); sb.Append(Delimiter); //JobName sb.Append(EscapeDelimiters(TrimJobName(GetJobName(indexInfo)))); sb.Append(Delimiter); //FinishTime sb.Append(indexInfo.GetFinishTime()); sb.Append(Delimiter); //NumMaps sb.Append(indexInfo.GetNumMaps()); sb.Append(Delimiter); //NumReduces sb.Append(indexInfo.GetNumReduces()); sb.Append(Delimiter); //JobStatus sb.Append(indexInfo.GetJobStatus()); sb.Append(Delimiter); //QueueName sb.Append(EscapeDelimiters(GetQueueName(indexInfo))); sb.Append(Delimiter); //JobStartTime sb.Append(indexInfo.GetJobStartTime()); sb.Append(JobHistoryUtils.JobHistoryFileExtension); return(EncodeJobHistoryFileName(sb.ToString())); }