public void DuplicateTestMixed() { var instance1 = new SlotModel { UserId = "1" }; var unitInfo1 = new UnitInfo { ProjectID = 1 }; var logic1 = CreateUnitInfoLogic(unitInfo1); instance1.UnitInfoLogic = logic1; var instance2 = new SlotModel { UserId = "1" }; var unitInfo2 = new UnitInfo { ProjectID = 2 }; var logic2 = CreateUnitInfoLogic(unitInfo2); instance2.UnitInfoLogic = logic2; var instance3 = new SlotModel { UserId = "2" }; var unitInfo3 = new UnitInfo { ProjectID = 1 }; var logic3 = CreateUnitInfoLogic(unitInfo3); instance3.UnitInfoLogic = logic3; (new[] { instance1, instance2, instance3 }).FindDuplicates(); Assert.IsTrue(instance1.UserIdIsDuplicate); Assert.IsTrue(instance1.ProjectIsDuplicate); Assert.IsTrue(instance2.UserIdIsDuplicate); Assert.IsFalse(instance2.ProjectIsDuplicate); Assert.IsFalse(instance3.UserIdIsDuplicate); Assert.IsTrue(instance3.ProjectIsDuplicate); }
public void CurrentFrameTest4() { var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { FrameID = -1 }; unitInfo.SetUnitFrame(unitFrame); Assert.IsNull(unitInfo.CurrentFrame); }
public void GetUnitFrameTest2() { var unitInfo = new UnitInfo(); unitInfo.SetUnitFrame(new UnitFrame { FrameID = 0 }); Assert.IsNotNull(unitInfo.GetUnitFrame(0)); Assert.IsNull(unitInfo.GetUnitFrame(1)); }
public void UnitInfo_CurrentFrame_Test1() { // Arrange var unitInfo = new UnitInfo(); // Act & Assert Assert.IsNull(unitInfo.CurrentFrame); }
public void CurrentFrameTest2() { var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { FrameID = 0 }; unitInfo.SetUnitFrame(unitFrame); Assert.AreSame(unitFrame, unitInfo.CurrentFrame); }
public void UnitInfo_CurrentFrame_Test2() { // Arrange var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { FrameID = 0 }; var logLine = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame }; unitInfo.LogLines = new List<LogLine>(new[] { logLine }); // Act & Assert Assert.AreSame(unitFrame, unitInfo.CurrentFrame); }
public void AllFramesCompleted1() { var unitInfo = new UnitInfo(); unitInfo.SetUnitFrame(MakeUnitFrame("00:00:00", 100)); var unitInfoLogic = CreateUnitInfoLogic(null, unitInfo); unitInfoLogic.UtcOffsetIsZero = false; unitInfoLogic.ClientTimeOffset = 0; Assert.IsTrue(unitInfoLogic.AllFramesCompleted); }
public void DownloadTimeTest3() { var unitInfo = new UnitInfo { DownloadTime = DateTime.UtcNow }; var unitInfoLogic = CreateUnitInfoLogic(new Protein(), unitInfo); unitInfoLogic.UtcOffsetIsZero = true; unitInfoLogic.ClientTimeOffset = 0; Assert.AreEqual(unitInfo.DownloadTime, unitInfoLogic.DownloadTime); }
public void DownloadTimeTest4() { var unitInfo = new UnitInfo { DownloadTime = DateTime.UtcNow }; var unitInfoLogic = CreateUnitInfoLogic(new Protein(), unitInfo); unitInfoLogic.UtcOffsetIsZero = true; unitInfoLogic.ClientTimeOffset = -60; Assert.AreEqual(unitInfo.DownloadTime .Add(TimeSpan.FromMinutes(60)), unitInfoLogic.DownloadTime); }
public void DownloadTimeTest2() { var unitInfo = new UnitInfo { DownloadTime = DateTime.UtcNow }; var unitInfoLogic = CreateUnitInfoLogic(new Protein(), unitInfo); unitInfoLogic.UtcOffsetIsZero = false; unitInfoLogic.ClientTimeOffset = 60; Assert.AreEqual(unitInfo.DownloadTime.ToLocalTime() .Subtract(TimeSpan.FromMinutes(60)), unitInfoLogic.DownloadTime); }
public void UnitInfo_CurrentFrame_Test3() { // Arrange var unitInfo = new UnitInfo(); var logLine0 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 0 } }; var logLine1 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 1 } }; var unitFrame5 = new UnitFrame { FrameID = 5 }; var logLine5 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame5 }; unitInfo.LogLines = new List<LogLine>(new[] { logLine0, logLine1, logLine5 }); // Act & Assert Assert.AreSame(unitFrame5, unitInfo.CurrentFrame); }
public void UpdateBenchmarkDataTest() { // setup var benchmarkCollection = new ProteinBenchmarkCollection(); var database = MockRepository.GenerateMock<IUnitInfoDatabase>(); var fahClient = new FahClient(MockRepository.GenerateStub<IMessageConnection>()) { BenchmarkCollection = benchmarkCollection, UnitInfoDatabase = database }; var unitInfo1 = new UnitInfo(); unitInfo1.OwningClientName = "Owner"; unitInfo1.OwningClientPath = "Path"; unitInfo1.OwningSlotId = 0; unitInfo1.ProjectID = 2669; unitInfo1.ProjectRun = 1; unitInfo1.ProjectClone = 2; unitInfo1.ProjectGen = 3; unitInfo1.FinishedTime = new DateTime(2010, 1, 1); unitInfo1.QueueIndex = 0; var currentUnitInfo = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo1 }; var unitInfo1Clone = unitInfo1.DeepClone(); unitInfo1Clone.FramesObserved = 4; unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(0), FrameID = 0 }); unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(5), FrameID = 1 }); unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(10), FrameID = 2 }); unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(15), FrameID = 3 }); unitInfo1Clone.UnitResult = WorkUnitResult.FinishedUnit; var unitInfoLogic1 = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo1Clone }; var parsedUnits = new[] { unitInfoLogic1 }; // arrange database.Stub(x => x.Connected).Return(true); database.Expect(x => x.Insert(null)).IgnoreArguments().Repeat.Times(1); var benchmarkClient = new BenchmarkClient("Owner Slot 00", "Path"); // assert before act Assert.AreEqual(false, benchmarkCollection.Contains(benchmarkClient)); Assert.AreEqual(false, new List<int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669)); Assert.IsNull(benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData)); // act fahClient.UpdateBenchmarkData(currentUnitInfo, parsedUnits, 0); // assert after act Assert.AreEqual(true, benchmarkCollection.Contains(benchmarkClient)); Assert.AreEqual(true, new List<int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669)); Assert.AreEqual(TimeSpan.FromMinutes(5), benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData).AverageFrameTime); database.VerifyAllExpectations(); }
/// <summary> /// Aggregate Data and return UnitInfo Dictionary. /// </summary> public DataAggregatorResult AggregateData(ClientRun clientRun, UnitCollection unitCollection, Info info, Options options, SlotOptions slotOptions, UnitInfo currentUnitInfo, int slotId) { if (clientRun == null) throw new ArgumentNullException("clientRun"); if (unitCollection == null) throw new ArgumentNullException("unitCollection"); if (options == null) throw new ArgumentNullException("options"); if (slotOptions == null) throw new ArgumentNullException("slotOptions"); if (currentUnitInfo == null) throw new ArgumentNullException("currentUnitInfo"); var result = new DataAggregatorResult(); result.CurrentUnitIndex = -1; SlotRun slotRun = null; if (clientRun.SlotRuns.ContainsKey(slotId)) { slotRun = clientRun.SlotRuns[slotId]; } result.StartTime = clientRun.Data.StartTime; result.Arguments = clientRun.Data.Arguments; result.ClientVersion = clientRun.Data.ClientVersion; result.UserID = clientRun.Data.UserID; result.MachineID = clientRun.Data.MachineID; result.Status = slotRun != null ? slotRun.Data.Status : SlotStatus.Unknown; if (Logger.IsDebugEnabled) { foreach (var s in clientRun.Where(x => x.LineType == LogLineType.Error)) { Logger.DebugFormat(Constants.ClientNameFormat, ClientName, String.Format("Failed to parse log line: {0}", s)); } } GenerateUnitInfoDataFromQueue(result, slotRun, unitCollection, options, slotOptions, currentUnitInfo, slotId); result.Queue = BuildClientQueue(unitCollection, info, slotOptions, slotId); if (result.UnitInfos.ContainsKey(result.CurrentUnitIndex) && result.UnitInfos[result.CurrentUnitIndex].LogLines != null) { result.CurrentLogLines = result.UnitInfos[result.CurrentUnitIndex].LogLines; } else if (slotRun != null) { result.CurrentLogLines = slotRun.ToList(); } else { result.CurrentLogLines = clientRun.ToList(); } return result; }
public void UnitInfo_DefaultPropertyValues_Test() { var unitInfo = new UnitInfo(); Assert.AreEqual(SlotType.Unknown, unitInfo.SlotType); Assert.IsTrue(unitInfo.DownloadTime.IsUnknown()); Assert.IsTrue(unitInfo.DueTime.IsUnknown()); Assert.IsTrue(unitInfo.UnitStartTimeStamp.IsZero()); Assert.IsTrue(unitInfo.FinishedTime.IsUnknown()); Assert.IsTrue(unitInfo.CoreVersion == 0); Assert.IsTrue(unitInfo.ProteinName.Length == 0); Assert.IsTrue(unitInfo.ProteinTag.Length == 0); Assert.AreEqual(WorkUnitResult.Unknown, unitInfo.UnitResult); Assert.IsNull(unitInfo.LogLines); Assert.IsNull(unitInfo.UnitFrames); Assert.AreEqual(Constants.DefaultCoreID, unitInfo.CoreID); }
private UnitInfo[] GenerateUnitInfoDataFromLogs() { var parsedUnits = new UnitInfo[2]; _unitLogLines = new IList<LogLine>[2]; if (_logInterpreterLegacy.PreviousWorkUnitLogLines != null) { _unitLogLines[0] = _logInterpreterLegacy.PreviousWorkUnitLogLines; parsedUnits[0] = BuildUnitInfo(null, LogReader.GetFahLogDataFromLogLines(_logInterpreterLegacy.PreviousWorkUnitLogLines), null); } bool matchOverride = false; _unitLogLines[1] = _logInterpreterLegacy.CurrentWorkUnitLogLines; if (_unitLogLines[1] == null) { matchOverride = true; _unitLogLines[1] = _logInterpreterLegacy.CurrentClientRunLogLines; } parsedUnits[1] = BuildUnitInfo(null, LogReader.GetFahLogDataFromLogLines(_unitLogLines[1]), GetUnitInfoLogData(), matchOverride); return parsedUnits; }
private UnitInfo BuildUnitInfo(QueueEntry queueEntry, FahLogUnitData fahLogUnitData, UnitInfoLogData unitInfoLogData, bool matchOverride) { // queueEntry can be null Debug.Assert(fahLogUnitData != null); // unitInfoLogData can be null var unit = new UnitInfo(); unit.UnitStartTimeStamp = fahLogUnitData.UnitStartTimeStamp; unit.FramesObserved = fahLogUnitData.FramesObserved; unit.CoreVersion = fahLogUnitData.CoreVersion; unit.UnitResult = fahLogUnitData.UnitResult; if (queueEntry != null) { PopulateUnitInfoFromQueueEntry(queueEntry, unit); SearchFahLogUnitDataProjects(unit, fahLogUnitData); PopulateUnitInfoFromLogs(CurrentClientRun, fahLogUnitData, unitInfoLogData, unit); if (ProjectsMatch(unit, fahLogUnitData) || ProjectsMatch(unit, unitInfoLogData) || matchOverride) { // continue parsing the frame data ParseFrameData(fahLogUnitData.FrameDataList, unit); } else { return null; } } else { PopulateUnitInfoFromLogs(CurrentClientRun, fahLogUnitData, unitInfoLogData, unit); ParseFrameData(fahLogUnitData.FrameDataList, unit); } return unit; }
private static void SearchFahLogUnitDataProjects(UnitInfo unit, FahLogUnitData fahLogUnitData) { Debug.Assert(unit != null); Debug.Assert(fahLogUnitData != null); for (int i = 0; i < fahLogUnitData.ProjectInfoList.Count; i++) { if (ProjectsMatch(unit, fahLogUnitData.ProjectInfoList[i])) { fahLogUnitData.ProjectInfoIndex = i; } } }
private static bool ProjectsMatch(UnitInfo unit, IProjectInfo projectInfo) { Debug.Assert(unit != null); if (unit.ProjectIsUnknown() || projectInfo == null) return false; return (unit.ProjectID == projectInfo.ProjectID && unit.ProjectRun == projectInfo.ProjectRun && unit.ProjectClone == projectInfo.ProjectClone && unit.ProjectGen == projectInfo.ProjectGen); }
private static void PopulateUnitInfoFromQueueEntry(QueueEntry entry, UnitInfo unit) { Debug.Assert(entry != null); Debug.Assert(unit != null); // convert to enum var queueEntryStatus = (QueueEntryStatus)entry.EntryStatus; if ((queueEntryStatus.Equals(QueueEntryStatus.Unknown) || queueEntryStatus.Equals(QueueEntryStatus.Empty) || queueEntryStatus.Equals(QueueEntryStatus.Garbage) || queueEntryStatus.Equals(QueueEntryStatus.Abandonded)) == false) { /* Tag (Could be read here or through the unitinfo.txt file) */ unit.ProteinTag = entry.WorkUnitTag; /* DownloadTime (Could be read here or through the unitinfo.txt file) */ unit.DownloadTime = entry.BeginTimeUtc; /* DueTime (Could be read here or through the unitinfo.txt file) */ unit.DueTime = entry.DueTimeUtc; /* FinishedTime */ if (queueEntryStatus.Equals(QueueEntryStatus.Finished) || queueEntryStatus.Equals(QueueEntryStatus.ReadyForUpload)) { unit.FinishedTime = entry.EndTimeUtc; } /* Project (R/C/G) */ unit.ProjectID = entry.ProjectID; unit.ProjectRun = entry.ProjectRun; unit.ProjectClone = entry.ProjectClone; unit.ProjectGen = entry.ProjectGen; /* FoldingID and Team from Queue Entry */ unit.FoldingID = entry.FoldingID; unit.Team = (int) entry.TeamNumber; /* Core ID */ unit.CoreID = entry.CoreNumberHex.ToUpperInvariant(); } }
private static void PopulateUnitInfoFromLogs(ClientRun currentClientRun, FahLogUnitData fahLogUnitData, UnitInfoLogData unitInfoLogData, UnitInfo unit) { Debug.Assert(currentClientRun != null); Debug.Assert(fahLogUnitData != null); // unitInfoLogData can be null Debug.Assert(unit != null); /* Project (R/C/G) (Could have already been read through Queue) */ if (unit.ProjectIsUnknown()) { unit.ProjectID = fahLogUnitData.ProjectID; unit.ProjectRun = fahLogUnitData.ProjectRun; unit.ProjectClone = fahLogUnitData.ProjectClone; unit.ProjectGen = fahLogUnitData.ProjectGen; } if (fahLogUnitData.Threads > 1) { unit.SlotType = SlotType.CPU; } if (unitInfoLogData != null) { unit.ProteinName = unitInfoLogData.ProteinName; /* Tag (Could have already been read through Queue) */ if (unit.ProteinTag.Length == 0) { unit.ProteinTag = unitInfoLogData.ProteinTag; } /* DownloadTime (Could have already been read through Queue) */ if (unit.DownloadTime.IsUnknown()) { unit.DownloadTime = unitInfoLogData.DownloadTime; } /* DueTime (Could have already been read through Queue) */ if (unit.DueTime.IsUnknown()) { unit.DueTime = unitInfoLogData.DueTime; } /* FinishedTime (Not available in unitinfo log) */ /* Project (R/C/G) (Could have already been read through Queue) */ if (unit.ProjectIsUnknown()) { unit.ProjectID = unitInfoLogData.ProjectID; unit.ProjectRun = unitInfoLogData.ProjectRun; unit.ProjectClone = unitInfoLogData.ProjectClone; unit.ProjectGen = unitInfoLogData.ProjectGen; } } /* FoldingID and Team from Last Client Run (Could have already been read through Queue) */ if (unit.FoldingID.Equals(Constants.DefaultFoldingID) && !String.IsNullOrEmpty(currentClientRun.FoldingID)) { unit.FoldingID = currentClientRun.FoldingID; } if (unit.Team == Constants.DefaultTeam) { unit.Team = currentClientRun.Team; } // Possibly check the currentClientRun from the log file. // The queue will have the ID and Team that was set when the work unit was received. //if (unit.FoldingID.Equals(Default.FoldingID) || // !unit.FoldingID.Equals(currentClientRun.FoldingID)) //{ // unit.FoldingID = currentClientRun.FoldingID; //} //if (unit.Team == Default.Team || // unit.Team != currentClientRun.Team) //{ // unit.Team = currentClientRun.Team; //} }
public void UnitInfo_GetUnitFrame_Test2() { // Arrange var unitInfo = new UnitInfo(); var logLine = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 0 } }; unitInfo.LogLines = new List<LogLine>(new[] { logLine }); // Act & Assert Assert.IsNotNull(unitInfo.GetUnitFrame(0)); Assert.IsNull(unitInfo.GetUnitFrame(1)); }
private static void UpdateUnitInfoFromLogData(UnitInfo unitInfo, ClientRunData clientRunData, UnitRunData unitRunData, UnitInfoLogData unitInfoLogData) { Debug.Assert(unitInfo != null); Debug.Assert(clientRunData != null); Debug.Assert(unitRunData != null); // unitInfoLogData can be null /* Project (R/C/G) (Could have already been read through Queue) */ if (unitInfo.ProjectIsUnknown()) { unitInfo.ProjectID = unitRunData.ProjectID; unitInfo.ProjectRun = unitRunData.ProjectRun; unitInfo.ProjectClone = unitRunData.ProjectClone; unitInfo.ProjectGen = unitRunData.ProjectGen; } if (unitRunData.Threads > 1) { unitInfo.SlotType = SlotType.CPU; } if (unitInfoLogData != null) { unitInfo.ProteinName = unitInfoLogData.ProteinName; /* Tag (Could have already been read through Queue) */ if (unitInfo.ProteinTag.Length == 0) { unitInfo.ProteinTag = unitInfoLogData.ProteinTag; } /* DownloadTime (Could have already been read through Queue) */ if (unitInfo.DownloadTime.IsUnknown()) { unitInfo.DownloadTime = unitInfoLogData.DownloadTime; } /* DueTime (Could have already been read through Queue) */ if (unitInfo.DueTime.IsUnknown()) { unitInfo.DueTime = unitInfoLogData.DueTime; } /* FinishedTime (Not available in unitinfo log) */ /* Project (R/C/G) (Could have already been read through Queue) */ if (unitInfo.ProjectIsUnknown()) { unitInfo.ProjectID = unitInfoLogData.ProjectID; unitInfo.ProjectRun = unitInfoLogData.ProjectRun; unitInfo.ProjectClone = unitInfoLogData.ProjectClone; unitInfo.ProjectGen = unitInfoLogData.ProjectGen; } } /* FoldingID and Team from last ClientRun (Could have already been read through Queue) */ if (unitInfo.FoldingID == Constants.DefaultFoldingID && unitInfo.Team == Constants.DefaultTeam) { if (!String.IsNullOrEmpty(clientRunData.FoldingID)) { unitInfo.FoldingID = clientRunData.FoldingID; unitInfo.Team = clientRunData.Team; } } // The queue will have the FoldingID and Team that was set in the client when the work unit was assigned. // If the user subsequently changed their FoldingID and Team before this unit was completed the // FoldingID and Team read from the queue will NOT reflect that change. //if (unitInfo.FoldingID != clientRunData.FoldingID || unitInfo.Team != clientRunData.Team) //{ // if (!String.IsNullOrEmpty(clientRunData.FoldingID)) // { // unitInfo.FoldingID = clientRunData.FoldingID; // unitInfo.Team = clientRunData.Team; // } //} }
private static void UpdateUnitInfoFromQueueData(UnitInfo unitInfo, QueueEntry queueEntry) { Debug.Assert(unitInfo != null); Debug.Assert(queueEntry != null); // convert to enum var queueEntryStatus = (QueueEntryStatus)queueEntry.EntryStatus; if ((queueEntryStatus == QueueEntryStatus.Unknown || queueEntryStatus == QueueEntryStatus.Empty || queueEntryStatus == QueueEntryStatus.Garbage || queueEntryStatus == QueueEntryStatus.Abandonded) == false) { /* Tag (Could be read here or through the unitinfo.txt file) */ unitInfo.ProteinTag = queueEntry.WorkUnitTag; /* DownloadTime (Could be read here or through the unitinfo.txt file) */ unitInfo.DownloadTime = queueEntry.BeginTimeUtc; /* DueTime (Could be read here or through the unitinfo.txt file) */ unitInfo.DueTime = queueEntry.DueTimeUtc; /* FinishedTime */ if (queueEntryStatus == QueueEntryStatus.Finished || queueEntryStatus == QueueEntryStatus.ReadyForUpload) { unitInfo.FinishedTime = queueEntry.EndTimeUtc; } /* Project (R/C/G) */ unitInfo.ProjectID = queueEntry.ProjectID; unitInfo.ProjectRun = queueEntry.ProjectRun; unitInfo.ProjectClone = queueEntry.ProjectClone; unitInfo.ProjectGen = queueEntry.ProjectGen; /* FoldingID and Team from Queue Entry */ unitInfo.FoldingID = queueEntry.FoldingID; unitInfo.Team = (int)queueEntry.TeamNumber; /* Core ID */ unitInfo.CoreID = queueEntry.CoreNumberHex.ToUpperInvariant(); } }
private static UnitInfo BuildUnitInfo(QueueEntry queueEntry, ClientRun clientRun, UnitRun unitRun, UnitInfoLogData unitInfoLogData, bool matchOverride = false) { // queueEntry can be null Debug.Assert(clientRun != null); // unitInfoLogData can be null var unit = new UnitInfo(); UnitRunData unitRunData; if (unitRun == null) { if (matchOverride) { unitRunData = new UnitRunData(); } else { return null; } } else { unit.LogLines = unitRun.ToList(); unitRunData = unitRun.Data; } unit.UnitStartTimeStamp = unitRunData.UnitStartTimeStamp ?? TimeSpan.MinValue; unit.FramesObserved = unitRunData.FramesObserved; unit.CoreVersion = unitRunData.CoreVersion; unit.UnitResult = unitRunData.WorkUnitResult; if (queueEntry != null) { UpdateUnitInfoFromQueueData(unit, queueEntry); SearchFahLogUnitDataProjects(unit, unitRunData); UpdateUnitInfoFromLogData(unit, clientRun.Data, unitRunData, unitInfoLogData); if (!ProjectsMatch(unit, unitRunData) && !ProjectsMatch(unit, unitInfoLogData) && !matchOverride) { return null; } } else { UpdateUnitInfoFromLogData(unit, clientRun.Data, unitRunData, unitInfoLogData); } return unit; }
public void UnitInfo_GetUnitFrame_Test1() { // Arrange var unitInfo = new UnitInfo(); // Act & Assert Assert.IsNull(unitInfo.GetUnitFrame(0)); }
private UnitInfo[] GenerateUnitInfoDataFromQueue(QueueData q) { Debug.Assert(q != null); var parsedUnits = new UnitInfo[10]; _unitLogLines = new IList<LogLine>[10]; for (int queueIndex = 0; queueIndex < parsedUnits.Length; queueIndex++) { // Get the Log Lines for this queue position from the reader _unitLogLines[queueIndex] = _logInterpreterLegacy.GetLogLinesForQueueIndex(queueIndex); // Get the FAH Log Data from the Log Lines FahLogUnitData fahLogUnitData = LogReader.GetFahLogDataFromLogLines(_unitLogLines[queueIndex]); UnitInfoLogData unitInfoLogData = null; // On the Current Queue Index if (queueIndex == q.CurrentIndex) { // Get the UnitInfo Log Data unitInfoLogData = GetUnitInfoLogData(); } parsedUnits[queueIndex] = BuildUnitInfo(q.GetQueueEntry((uint)queueIndex), fahLogUnitData, unitInfoLogData); if (parsedUnits[queueIndex] == null) { if (queueIndex == q.CurrentIndex) { string message = String.Format(CultureInfo.CurrentCulture, "Could not verify log section for current queue entry {0}. Trying to parse with most recent log section.", queueIndex); _logger.Warn(Constants.ClientNameFormat, ClientName, message); _unitLogLines[queueIndex] = _logInterpreterLegacy.CurrentWorkUnitLogLines; // If got no Work Unit Log Lines based on Current Work Unit Log Lines // then take the entire Current Client Run Log Lines - likely the run // was short and never contained any Work Unit Data. if (_unitLogLines[queueIndex] == null) { _unitLogLines[queueIndex] = _logInterpreterLegacy.CurrentClientRunLogLines; } fahLogUnitData = LogReader.GetFahLogDataFromLogLines(_unitLogLines[queueIndex]); if (_currentClientRun.Status.Equals(SlotStatus.GettingWorkPacket)) { // Use either the current Work Unit log lines or current Client Run log lines // as decided upon above... don't clear it here and show the user nothing - 10/9/10 //_unitLogLines[queueIndex] = null; fahLogUnitData = new FahLogUnitData(); unitInfoLogData = new UnitInfoLogData(); } parsedUnits[queueIndex] = BuildUnitInfo(q.GetQueueEntry((uint)queueIndex), fahLogUnitData, unitInfoLogData, true); } else { // Just skip this unit and continue string message = String.Format(CultureInfo.CurrentCulture, "Could not find or verify log section for queue entry {0} (this is not a problem).", queueIndex); _logger.Debug(Constants.ClientNameFormat, ClientName, message); } } } return parsedUnits; }
private static bool ValidateUnitInfo(UnitInfo unitInfo) { // if Project and Download Time are valid if (!unitInfo.ProjectIsUnknown() && unitInfo.DownloadTime != DateTime.MinValue) { // if UnitResult is FinishedUnit if (unitInfo.UnitResult == WorkUnitResult.FinishedUnit) { // the Finished Time must be valid return unitInfo.FinishedTime != DateTime.MinValue; } // otherwise, the UnitResult must be a Terminating error result return unitInfo.UnitResult.IsTerminating(); } return false; }
private static void ParseFrameData(IEnumerable<LogLine> frameData, UnitInfo unit) { Debug.Assert(frameData != null); Debug.Assert(unit != null); foreach (var logLine in frameData) { // Check for FrameData var frame = logLine.LineData as UnitFrame; if (frame == null) { // If not found, clear the LineType and get out logLine.LineType = LogLineType.Unknown; continue; } unit.SetUnitFrame(frame); } }
private UnitInfoLogic BuildUnitInfoLogic(SlotModel slotModel, UnitInfo unitInfo) { Debug.Assert(slotModel != null); Debug.Assert(unitInfo != null); Protein protein = ProteinDictionary.GetProteinOrDownload(unitInfo.ProjectID); // update the data unitInfo.UnitRetrievalTime = LastRetrievalTime; unitInfo.OwningClientName = Settings.Name; unitInfo.OwningClientPath = Settings.DataPath(); unitInfo.OwningSlotId = slotModel.SlotId; //unitInfo.SlotType = UnitInfo.DetermineSlotType(protein.Core, unitInfo.CoreID); // build unit info logic var unitInfoLogic = ServiceLocator.Resolve<UnitInfoLogic>(); unitInfoLogic.CurrentProtein = protein; unitInfoLogic.UnitInfoData = unitInfo; return unitInfoLogic; }
public void UnitInfo_SetUnitFrameDataFromLogLines_Test1() { // Arrange var unitInfo = new UnitInfo(); var unitFrame = new UnitFrame { RawFramesComplete = 0, RawFramesTotal = 100000, FrameID = 0 }; var logLine = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame }; // Act unitInfo.LogLines = new List<LogLine>(new[] { logLine }); // Assert Assert.AreEqual(0, unitInfo.RawFramesComplete); Assert.AreEqual(100000, unitInfo.RawFramesTotal); Assert.AreEqual(1, unitInfo.UnitFrames.Count); Assert.AreSame(unitFrame, unitInfo.CurrentFrame); }