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 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 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; //} }
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; // } //} }
internal static bool IsSameUnitAs(this UnitInfo unit1, UnitInfo unit2) { if (unit1 == null) throw new ArgumentNullException("unit1"); if (unit2 == null) { return false; } // if the Projects are known if (!unit1.ProjectIsUnknown() && !unit2.ProjectIsUnknown()) { // ReSharper disable RedundantThisQualifier // equals the Project and Download Time if (unit1.EqualsProject(unit2) && unit1.DownloadTime.Equals(unit2.DownloadTime)) { return true; } // ReSharper restore RedundantThisQualifier } return false; }
private static bool ValidateIncompleteUnitInfo(UnitInfo unitInfo) { // Finished Time will not be populated if any of these error // results are detected. Only check for valid Project and // download time - Issue 233 return unitInfo.ProjectIsUnknown() == false && (unitInfo.UnitResult.Equals(WorkUnitResult.BadWorkUnit) || unitInfo.UnitResult.Equals(WorkUnitResult.CoreOutdated) || unitInfo.UnitResult.Equals(WorkUnitResult.EarlyUnitEnd) || unitInfo.UnitResult.Equals(WorkUnitResult.Interrupted) || unitInfo.UnitResult.Equals(WorkUnitResult.UnstableMachine)) && unitInfo.DownloadTime.Equals(DateTime.MinValue) == false; }
private static bool ValidateFinishedUnitInfo(UnitInfo unitInfo) { return unitInfo.ProjectIsUnknown() == false && unitInfo.UnitResult.Equals(WorkUnitResult.FinishedUnit) && unitInfo.DownloadTime.Equals(DateTime.MinValue) == false && unitInfo.FinishedTime.Equals(DateTime.MinValue) == false; }