public PeachStatus Parse(Stream statusFileStream) { PeachStatus peachStatus = new PeachStatus(); using (StreamReader sr = new StreamReader(statusFileStream)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); StatusLineType lineType = identifyLineType(line); UInt64 startingIteration; UInt64 finalIteration; UInt64 faultingIteration; switch (lineType) { case StatusLineType.FaultDetected: ParseFaultDetectedLine(line, out faultingIteration); peachStatus.LastCompletedIteration = faultingIteration; peachStatus.LastUpdate = ParseDate(line); break; case StatusLineType.IterationX: ParseIterationXLine(line, out startingIteration); peachStatus.LastCompletedIteration = startingIteration - 1; peachStatus.LastUpdate = ParseDate(line); break; case StatusLineType.IterationXofN: ParseIterationXofNLine(line, out startingIteration, out finalIteration); peachStatus.LastCompletedIteration = startingIteration - 1; peachStatus.FinalIteration = finalIteration; peachStatus.LastUpdate = ParseDate(line); break; case StatusLineType.TestFinished: peachStatus.Finished = true; return(peachStatus); default: break; } } } return(peachStatus); }
public bool Equals(PeachStatus other) { if (this.LastCompletedIteration != other.LastCompletedIteration) { return(false); } if (this.FinalIteration != other.FinalIteration) { return(false); } if (this.Finished != other.Finished) { return(false); } if (this.LastUpdate != other.LastUpdate) { return(false); } return(true); }
private void PrintLastStatus() { using (Stream statusFileStream = _filePuller.GetStatusFileStream()) { if (statusFileStream == null) { return; } PeachStatus status = _statusFileParser.Parse(statusFileStream); if (status.LastCompletedIteration != null) { Console.WriteLine("Last iteration: {0}", status.LastCompletedIteration); } if (status.LastUpdate != null) { Console.WriteLine("Last activity: {0}", status.LastUpdate); } if (status.Finished) { Console.WriteLine("Worker no longer running"); } } }