public Result Process() { var result = new Result(); if (SlotCollection != null && _slotOptions.Count == SlotCollection.Count) { foreach (var options in _slotOptions) { SlotOptions options1 = options; if (options1.MachineId.HasValue) { int machineId = options1.MachineId.Value; var slot = SlotCollection.First(x => x.Id == machineId); slot.SlotOptions = options; } } _slotOptions.Clear(); result.SlotsUpdated = true; } if (LogRetrieved) { if (result.SlotsUpdated) { result.ExecuteRetrieval = true; } if (UnitCollection != null && !_unitCollectionEqualityComparer.Equals(_previousUnitCollection, UnitCollection)) { _previousUnitCollection = UnitCollection; result.ExecuteRetrieval = true; } } return(result); }
void UpdateDisplay() { if (_myslot.IsOpen) { BG.ToggleWindowOn(); SlotInfo.ToggleWindowOn(); SlotOptions.ToggleWindowOff(); //Update the slot visuals. _sprIcon.spriteName = _myslot.IconName; //_lblSlotName.text = "Tap to Select"; } else { BG.ToggleWindowOff(); SlotOptions.ToggleWindowOn(); SlotInfo.ToggleWindowOff(); _lblSlotName.text = "Add Slot"; } if (_CostLabel) { float cost = (float)_myslot.Cost / 100.0f; string format = string.Format("{0:C}", cost); _CostLabel.text = format; } }
public void ShowOptions(FaceBuilder.FaceSlot slot) { SlotOptions options = _slotOptionsCache.ContainsKey(slot.name) ? _slotOptionsCache[slot.name] : new SlotOptions(); slotOptionsPanel.DisplayOptions(slot, options); gameObject.SetActive(false); }
private UnitInfo BuildUnitInfo(Unit queueEntry, Options options, SlotOptions slotOptions, UnitRun unitRun) { Debug.Assert(queueEntry != null); Debug.Assert(options != null); Debug.Assert(slotOptions != null); var unit = new UnitInfo(); UpdateUnitInfoFromFahClientData(unit, queueEntry, options, slotOptions); if (unitRun != null) { UpdateUnitInfoFromLogData(unit, unitRun); } return(unit); }
private bool UpdateSlotOptionsCollectionFromMessage(FahClientMessage message) { SlotOptionsCollection.Add(SlotOptions.Load(message.MessageText)); if (SlotCollection != null && SlotCollection.Count == SlotOptionsCollection.Count) { foreach (var slotOptions in SlotOptionsCollection) { if (Int32.TryParse(slotOptions[Options.MachineID], out var machineID)) { var slot = SlotCollection.First(x => x.ID == machineID); slot.SlotOptions = slotOptions; } } return(true); } return(false); }
private void Connect() { Connection?.Dispose(); Connection = Model.CreateConnection(); Connection.Open(); if (!String.IsNullOrWhiteSpace(Model.Password)) { Connection.CreateCommand("auth " + Model.Password).Execute(); } Model.ConnectEnabled = !Connection.Connected; if (Connection.Connected) { Connection.CreateCommand("slot-info").Execute(); var reader = Connection.CreateReader(); if (reader.Read()) { var slotCollection = SlotCollection.Load(reader.Message.MessageText); foreach (var slot in slotCollection) { Connection.CreateCommand(String.Format(CultureInfo.InvariantCulture, FahClientMessages.DefaultSlotOptions, slot.ID)).Execute(); if (reader.Read()) { var slotOptions = SlotOptions.Load(reader.Message.MessageText); if (slotOptions[Options.MachineID] != null) { slot.SlotOptions = slotOptions; } } } Model.RefreshSlots(slotCollection); } else { MessageBox.ShowError(Dialog, "Connected to the FAHClient but did not read any slot information. Are you missing a password?", Core.Application.NameAndVersion); Connection.Close(); Model.ConnectEnabled = !Connection.Connected; } } }
private static string GetCpuString(Info info, SlotOptions slotOptions) { if (slotOptions.GpuIndex.HasValue) { switch (slotOptions.GpuIndex) { case 0: return(info.System.GpuId0Type); case 1: return(info.System.GpuId1Type); case 2: return(info.System.GpuId2Type); case 3: return(info.System.GpuId3Type); case 4: return(info.System.GpuId4Type); case 5: return(info.System.GpuId5Type); case 6: return(info.System.GpuId6Type); case 7: return(info.System.GpuId7Type); } } else { return(info.System.Cpu); } return(String.Empty); }
public void FillTest7_1() { string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_7\\slot-options1.txt"); var slotOptions = new SlotOptions(); slotOptions.Fill(JsonMessageConnection.GetNextJsonMessage(ref message)); Assert.AreEqual(null, slotOptions.Cpus); Assert.AreEqual("beta", slotOptions.FahClientType); Assert.AreEqual(FahClientType.Beta, slotOptions.FahClientTypeEnum); Assert.AreEqual("SMP", slotOptions.FahClientSubType); Assert.AreEqual(FahClientSubType.CPU, slotOptions.FahClientSubTypeEnum); Assert.AreEqual(0, slotOptions.MachineId); Assert.AreEqual("big", slotOptions.MaxPacketSize); Assert.AreEqual(MaxPacketSize.Big, slotOptions.MaxPacketSizeEnum); Assert.AreEqual("idle", slotOptions.CorePriority); Assert.AreEqual(CorePriority.Idle, slotOptions.CorePriorityEnum); Assert.AreEqual(100, slotOptions.NextUnitPercentage); Assert.AreEqual(0, slotOptions.MaxUnits); Assert.AreEqual(15, slotOptions.Checkpoint); Assert.AreEqual(false, slotOptions.PauseOnStart); Assert.AreEqual(null, slotOptions.GpuIndex); Assert.AreEqual(null, slotOptions.GpuUsage); }
public void FillTest4_3() { string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_4\\slot-options3.txt"); var slotOptions = new SlotOptions(); slotOptions.Fill(JsonMessageConnection.GetNextJsonMessage(ref message)); Assert.AreEqual(null, slotOptions.Cpus); Assert.AreEqual("beta", slotOptions.FahClientType); Assert.AreEqual(FahClientType.Beta, slotOptions.FahClientTypeEnum); Assert.AreEqual("GPU", slotOptions.FahClientSubType); Assert.AreEqual(FahClientSubType.GPU, slotOptions.FahClientSubTypeEnum); Assert.AreEqual(2, slotOptions.MachineId); Assert.AreEqual("normal", slotOptions.MaxPacketSize); Assert.AreEqual(MaxPacketSize.Normal, slotOptions.MaxPacketSizeEnum); Assert.AreEqual("low", slotOptions.CorePriority); Assert.AreEqual(CorePriority.Low, slotOptions.CorePriorityEnum); Assert.AreEqual(99, slotOptions.NextUnitPercentage); Assert.AreEqual(0, slotOptions.MaxUnits); Assert.AreEqual(15, slotOptions.Checkpoint); Assert.AreEqual(false, slotOptions.PauseOnStart); Assert.AreEqual(null, slotOptions.GpuIndex); Assert.AreEqual(null, slotOptions.GpuUsage); }
public void FahClientSettingsModel_RefreshSlots_FromClientObjectModel() { // Arrange var model = new FahClientSettingsModel(); var slotCollection = new SlotCollection(); var slotOptions = new SlotOptions { { Options.ClientType, "foo" }, { Options.MaxPacketSize, "bar" } }; slotCollection.Add(new Slot { ID = 0, Description = "cpu:15", SlotOptions = slotOptions }); // Act model.RefreshSlots(slotCollection); // Assert Assert.AreEqual(1, model.Slots.Count); var slotModel = model.Slots.First(); Assert.AreEqual("00", slotModel.ID); Assert.AreEqual("CPU", slotModel.SlotType); Assert.AreEqual("foo", slotModel.ClientType); Assert.AreEqual("bar", slotModel.MaxPacketSize); }
public void FillTest3() { string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_3\\slot-options.txt"); var slotOptions = new SlotOptions(); slotOptions.Fill(MessageCache.GetNextJsonMessage(ref message)); Assert.AreEqual(null, slotOptions.Cpus); Assert.AreEqual("normal", slotOptions.FahClientType); Assert.AreEqual(FahClientType.Normal, slotOptions.FahClientTypeEnum); Assert.AreEqual("SMP", slotOptions.FahClientSubType); Assert.AreEqual(FahClientSubType.CPU, slotOptions.FahClientSubTypeEnum); Assert.AreEqual(0, slotOptions.MachineId); Assert.AreEqual("normal", slotOptions.MaxPacketSize); Assert.AreEqual(MaxPacketSize.Normal, slotOptions.MaxPacketSizeEnum); Assert.AreEqual("idle", slotOptions.CorePriority); Assert.AreEqual(CorePriority.Idle, slotOptions.CorePriorityEnum); Assert.AreEqual(99, slotOptions.NextUnitPercentage); Assert.AreEqual(0, slotOptions.MaxUnits); Assert.AreEqual(30, slotOptions.Checkpoint); Assert.AreEqual(false, slotOptions.PauseOnStart); Assert.AreEqual(null, slotOptions.GpuIndex); Assert.AreEqual(null, slotOptions.GpuUsage); }
public void Client_v7_10_0() { const int slotId = 0; _dataAggregator.ClientName = "Client_v7_10"; var fahLog = FahLog.Read(File.ReadLines("..\\..\\..\\TestFiles\\Client_v7_10\\log.txt"), FahLogType.FahClient); string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\units.txt"); var unitCollection = new UnitCollection(); unitCollection.Fill(JsonMessageConnection.GetNextJsonMessage(ref message)); message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\info.txt"); var info = new Info(); info.Fill(JsonMessageConnection.GetNextJsonMessage(ref message)); message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\options.txt"); var options = new Options(); options.Fill(JsonMessageConnection.GetNextJsonMessage(ref message)); message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\slot-options1.txt"); var slotOptions = new SlotOptions(); slotOptions.Fill(JsonMessageConnection.GetNextJsonMessage(ref message)); var result = _dataAggregator.AggregateData(fahLog.ClientRuns.First(), unitCollection, info, options, slotOptions, new UnitInfo(), slotId); Assert.AreEqual(1, result.UnitInfos.Count); Assert.IsFalse(result.UnitInfos.Any(x => x.Value == null)); #region Check Data Aggregator Assert.IsNotNull(result.Queue); Assert.AreEqual(1, result.CurrentUnitIndex); Assert.AreEqual(new DateTime(2012, 1, 11, 3, 24, 22), result.StartTime); Assert.AreEqual(null, result.Arguments); Assert.AreEqual(null, result.ClientVersion); Assert.AreEqual(null, result.UserID); Assert.AreEqual(0, result.MachineID); Assert.AreEqual(SlotStatus.Unknown, result.Status); Assert.IsNotNull(result.CurrentLogLines); Assert.IsFalse(result.UnitInfos.Any(x => x.Value.LogLines == null)); if (result.UnitInfos.ContainsKey(result.CurrentUnitIndex)) { Assert.AreEqual(result.CurrentLogLines, result.UnitInfos[result.CurrentUnitIndex].LogLines); } #endregion var unitInfoData = result.UnitInfos[result.CurrentUnitIndex]; #region Check Unit Info Data Values Assert.AreEqual(null, unitInfoData.OwningSlotName); Assert.AreEqual(null, unitInfoData.OwningClientName); Assert.AreEqual(null, unitInfoData.OwningClientPath); Assert.AreEqual(-1, unitInfoData.OwningSlotId); Assert.AreEqual(DateTime.MinValue, unitInfoData.UnitRetrievalTime); Assert.AreEqual("harlam357", unitInfoData.FoldingID); Assert.AreEqual(32, unitInfoData.Team); Assert.AreEqual(SlotType.CPU, unitInfoData.SlotType); Assert.AreEqual(new DateTime(2012, 1, 10, 23, 20, 27), unitInfoData.DownloadTime); Assert.AreEqual(new DateTime(2012, 1, 22, 16, 22, 51), unitInfoData.DueTime); Assert.AreEqual(new TimeSpan(3, 25, 32), unitInfoData.UnitStartTimeStamp); Assert.AreEqual(DateTime.MinValue, unitInfoData.FinishedTime); Assert.AreEqual(2.27f, unitInfoData.CoreVersion); Assert.AreEqual(7610, unitInfoData.ProjectID); Assert.AreEqual(630, unitInfoData.ProjectRun); Assert.AreEqual(0, unitInfoData.ProjectClone); Assert.AreEqual(59, unitInfoData.ProjectGen); Assert.AreEqual(String.Empty, unitInfoData.ProteinName); Assert.AreEqual(String.Empty, unitInfoData.ProteinTag); Assert.AreEqual(WorkUnitResult.Unknown, unitInfoData.UnitResult); Assert.AreEqual(660000, unitInfoData.RawFramesComplete); Assert.AreEqual(2000000, unitInfoData.RawFramesTotal); Assert.AreEqual(10, unitInfoData.FramesObserved); Assert.AreEqual(33, unitInfoData.CurrentFrame.FrameID); Assert.AreEqual(new TimeSpan(4, 46, 8), unitInfoData.CurrentFrame.TimeOfFrame); Assert.AreEqual(new TimeSpan(0, 8, 31), unitInfoData.CurrentFrame.FrameDuration); Assert.AreEqual("A4", unitInfoData.CoreID); #endregion }
/// <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(nameof(clientRun)); } if (unitCollection == null) { throw new ArgumentNullException(nameof(unitCollection)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (slotOptions == null) { throw new ArgumentNullException(nameof(slotOptions)); } if (currentUnitInfo == null) { throw new ArgumentNullException(nameof(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; if (Logger.IsDebugEnabled) { foreach (var s in LogLineEnumerable.Create(clientRun).Where(x => x.Data is LogLineDataParserError)) { Logger.DebugFormat(Constants.ClientNameFormat, ClientName, String.Format("Failed to parse log line: {0}", s)); } } GenerateUnitInfoDataFromQueue(result, slotRun, unitCollection, options, slotOptions, currentUnitInfo, slotId); result.Queue = BuildQueueDictionary(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 = LogLineEnumerable.Create(slotRun).ToList(); } else { result.CurrentLogLines = LogLineEnumerable.Create(clientRun).ToList(); } return(result); }
private static void UpdateUnitInfoFromFahClientData(UnitInfo unitInfo, Unit queueEntry, Options options, SlotOptions slotOptions) { Debug.Assert(unitInfo != null); Debug.Assert(queueEntry != null); Debug.Assert(options != null); Debug.Assert(slotOptions != null); unitInfo.QueueIndex = queueEntry.Id; /* DownloadTime (AssignedDateTime from HFM.Client API) */ unitInfo.DownloadTime = queueEntry.AssignedDateTime.GetValueOrDefault(); /* DueTime (TimeoutDateTime from HFM.Client API) */ unitInfo.DueTime = queueEntry.TimeoutDateTime.GetValueOrDefault(); /* FinishedTime */ //if (queueEntryStatus.Equals(QueueEntryStatus.Finished) || // queueEntryStatus.Equals(QueueEntryStatus.ReadyForUpload)) //{ // unit.FinishedTime = entry.EndTimeUtc; //} /* Project (R/C/G) */ unitInfo.ProjectID = queueEntry.Project; unitInfo.ProjectRun = queueEntry.Run; unitInfo.ProjectClone = queueEntry.Clone; unitInfo.ProjectGen = queueEntry.Gen; /* FoldingID and Team from Queue Entry */ unitInfo.FoldingID = options.User ?? Constants.DefaultFoldingID; unitInfo.Team = options.Team ?? Constants.DefaultTeam; unitInfo.SlotType = slotOptions.ToSlotType(); /* Core ID */ unitInfo.CoreID = queueEntry.Core.Replace("0x", String.Empty).ToUpperInvariant(); }
public static SlotType ToSlotType(this SlotOptions value) { return((SlotType)Enum.Parse(typeof(SlotType), value.GpuIndex.HasValue ? "GPU" : "CPU")); }
private void GenerateUnitInfoDataFromQueue(DataAggregatorResult result, SlotRun slotRun, ICollection <Unit> unitCollection, Options options, SlotOptions slotOptions, UnitInfo currentUnitInfo, int slotId) { Debug.Assert(unitCollection != null); Debug.Assert(options != null); Debug.Assert(slotOptions != null); Debug.Assert(currentUnitInfo != null); result.UnitInfos = new Dictionary <int, UnitInfo>(); bool foundCurrentUnitInfo = false; foreach (var unit in unitCollection.Where(x => x.Slot == slotId)) { var projectInfo = unit.ToProjectInfo(); if (projectInfo.EqualsProject(currentUnitInfo) && unit.AssignedDateTime.GetValueOrDefault().Equals(currentUnitInfo.DownloadTime)) { foundCurrentUnitInfo = true; } // Get the Log Lines for this queue position from the reader var unitRun = GetUnitRun(slotRun, unit.Id, projectInfo); if (unitRun == null) { string message = String.Format(CultureInfo.CurrentCulture, "Could not find log section for Slot {0} {1}. Cannot update log data for this unit.", slotId, projectInfo); Logger.WarnFormat(Constants.ClientNameFormat, ClientName, message); } UnitInfo unitInfo = BuildUnitInfo(unit, options, slotOptions, unitRun); if (unitInfo != null) { result.UnitInfos.Add(unit.Id, unitInfo); if (unit.StateEnum == UnitState.Running) { result.CurrentUnitIndex = unit.Id; } } } // if no running WU found if (result.CurrentUnitIndex == -1) { // look for a WU with Ready state var unit = unitCollection.FirstOrDefault(x => x.Slot == slotId && x.StateEnum == UnitState.Ready); if (unit != null) { result.CurrentUnitIndex = unit.Id; } } // if the current unit has already left the UnitCollection then find the log section and update here if (!foundCurrentUnitInfo) { // Get the Log Lines for this queue position from the reader var unitRun = GetUnitRun(slotRun, currentUnitInfo.QueueIndex, currentUnitInfo); if (unitRun != null) { // create a clone of the current UnitInfo object so we're not working with an // instance that is referenced by a SlotModel that is bound to the grid - Issue 277 UnitInfo currentClone = currentUnitInfo.DeepClone(); UpdateUnitInfoFromLogData(currentClone, unitRun); result.UnitInfos.Add(currentClone.QueueIndex, currentClone); } } }
public void Client_v7_10_0_UnitDataOnly() { const int slotId = 0; _dataAggregator.ClientName = "Client_v7_10"; var fahLog = new FahClientLog(); string filteredLogText = String.Join(Environment.NewLine, File.ReadLines("..\\..\\..\\TestFiles\\Client_v7_10\\log.txt").Where(x => x.Length != 0).Take(82)); using (var textReader = new StringReader(filteredLogText)) using (var reader = new FahClientLogTextReader(textReader)) { fahLog.Read(reader); } string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\units.txt"); var unitCollection = new UnitCollection(); unitCollection.Fill(JsonMessageConnection.GetNextJsonMessage(ref message)); message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\info.txt"); var info = new Info(); info.Fill(JsonMessageConnection.GetNextJsonMessage(ref message)); message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\options.txt"); var options = new Options(); options.Fill(JsonMessageConnection.GetNextJsonMessage(ref message)); message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\slot-options1.txt"); var slotOptions = new SlotOptions(); slotOptions.Fill(JsonMessageConnection.GetNextJsonMessage(ref message)); var result = _dataAggregator.AggregateData(fahLog.ClientRuns.Last(), unitCollection, info, options, slotOptions, new UnitInfo(), slotId); Assert.AreEqual(1, result.UnitInfos.Count); Assert.IsFalse(result.UnitInfos.Any(x => x.Value == null)); #region Check Data Aggregator Assert.IsNotNull(result.Queue); Assert.AreEqual(1, result.CurrentUnitIndex); Assert.AreEqual(new DateTime(2012, 1, 11, 3, 24, 22), result.StartTime); Assert.AreEqual(null, result.Arguments); Assert.AreEqual(null, result.ClientVersion); Assert.AreEqual(null, result.UserID); Assert.AreEqual(0, result.MachineID); Assert.AreEqual(SlotStatus.Unknown, result.Status); Assert.IsNotNull(result.CurrentLogLines); Assert.IsTrue(result.UnitInfos.All(x => x.Value.LogLines == null)); if (result.UnitInfos.ContainsKey(result.CurrentUnitIndex)) { Assert.AreEqual(result.CurrentLogLines, LogLineEnumerable.Create(fahLog.ClientRuns.Last())); } #endregion var unitInfoData = result.UnitInfos[result.CurrentUnitIndex]; #region Check Unit Info Data Values Assert.AreEqual(null, unitInfoData.OwningSlotName); Assert.AreEqual(null, unitInfoData.OwningClientName); Assert.AreEqual(null, unitInfoData.OwningClientPath); Assert.AreEqual(-1, unitInfoData.OwningSlotId); Assert.AreEqual(DateTime.MinValue, unitInfoData.UnitRetrievalTime); Assert.AreEqual("harlam357", unitInfoData.FoldingID); Assert.AreEqual(32, unitInfoData.Team); Assert.AreEqual(SlotType.CPU, unitInfoData.SlotType); Assert.AreEqual(new DateTime(2012, 1, 10, 23, 20, 27), unitInfoData.DownloadTime); Assert.AreEqual(new DateTime(2012, 1, 22, 16, 22, 51), unitInfoData.DueTime); Assert.AreEqual(TimeSpan.Zero, unitInfoData.UnitStartTimeStamp); Assert.AreEqual(DateTime.MinValue, unitInfoData.FinishedTime); Assert.AreEqual(0, unitInfoData.CoreVersion); Assert.AreEqual(7610, unitInfoData.ProjectID); Assert.AreEqual(630, unitInfoData.ProjectRun); Assert.AreEqual(0, unitInfoData.ProjectClone); Assert.AreEqual(59, unitInfoData.ProjectGen); Assert.AreEqual(String.Empty, unitInfoData.ProteinName); Assert.AreEqual(String.Empty, unitInfoData.ProteinTag); Assert.AreEqual(WorkUnitResult.Unknown, unitInfoData.UnitResult); Assert.AreEqual(0, unitInfoData.FramesObserved); Assert.IsNull(unitInfoData.CurrentFrame); Assert.AreEqual("A4", unitInfoData.CoreID); #endregion }
private static QueueDictionary BuildQueueDictionary(IEnumerable <Unit> unitCollection, Info info, SlotOptions slotOptions, int slotId) { QueueDictionary cq = null; foreach (var unit in unitCollection.Where(unit => unit.Slot == slotId)) { // don't create a queue until we find a unit that matches this slot id if (cq == null) { cq = new QueueDictionary { CurrentIndex = -1 }; } var cqe = new QueueUnitItem(); cqe.EntryStatusLiteral = unit.StateEnum.ToString(); cqe.WaitingOn = unit.WaitingOn; cqe.Attempts = unit.Attempts; cqe.NextAttempt = unit.NextAttemptTimeSpan.GetValueOrDefault(); cqe.NumberOfSmpCores = info.System.CpuCount; cqe.BeginTimeUtc = unit.AssignedDateTime.GetValueOrDefault(); cqe.BeginTimeLocal = unit.AssignedDateTime.GetValueOrDefault().ToLocalTime(); cqe.ProjectID = unit.Project; cqe.ProjectRun = unit.Run; cqe.ProjectClone = unit.Clone; cqe.ProjectGen = unit.Gen; cqe.MachineID = slotId; cqe.ServerIP = unit.WorkServer; cqe.CpuString = GetCpuString(info, slotOptions); cqe.OsString = ToOperatingSystemString(info.System); // Memory Value is in Gigabytes - turn into Megabytes and truncate cqe.Memory = (int)(info.System.MemoryValue.GetValueOrDefault() * 1024); cq.Add(unit.Id, cqe); if (unit.StateEnum == UnitState.Running) { cq.CurrentIndex = unit.Id; } } if (cq != null) { // if no running index and at least something in the queue if (cq.CurrentIndex == -1 && cq.Count != 0) { // take the minimum queue id cq.CurrentIndex = cq.Keys.First(); } } return(cq); }
/// <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 = BuildQueueDictionary(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); }