コード例 #1
0
      /// <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;
      }
コード例 #2
0
ファイル: SlotOptionsTests.cs プロジェクト: kszysiu/hfm-net
 public void FillTest10_1()
 {
     string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\slot-options1.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(15, slotOptions.Checkpoint);
      Assert.AreEqual(true, slotOptions.PauseOnStart);
      Assert.AreEqual(null, slotOptions.GpuIndex);
      Assert.AreEqual(null, slotOptions.GpuUsage);
 }
コード例 #3
0
        public void FillTest3()
        {
            string message     = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_3\\slot-options.txt");
            var    slotOptions = new SlotOptions();

            slotOptions.Fill(JsonMessageConnection.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);
        }
コード例 #4
0
ファイル: FahClient.cs プロジェクト: kszysiu/hfm-net
 public void AddSlotOptions(SlotOptions item)
 {
     _slotOptions.Add(item);
 }
コード例 #5
0
      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();
      }
コード例 #6
0
        private static void PopulateUnitInfoFromQueueEntry(Unit entry, Options options, SlotOptions slotOptions, UnitInfo unit)
        {
            Debug.Assert(entry != null);
             Debug.Assert(options != null);
             Debug.Assert(slotOptions != null);
             Debug.Assert(unit != null);

             /* DownloadTime (AssignedDateTime from HFM.Client API) */
             unit.DownloadTime = entry.AssignedDateTime.GetValueOrDefault();

             /* DueTime (TimeoutDateTime from HFM.Client API) */
             unit.DueTime = entry.TimeoutDateTime.GetValueOrDefault();

             /* FinishedTime */
             //if (queueEntryStatus.Equals(QueueEntryStatus.Finished) ||
             //    queueEntryStatus.Equals(QueueEntryStatus.ReadyForUpload))
             //{
             //   unit.FinishedTime = entry.EndTimeUtc;
             //}

             /* Project (R/C/G) */
             unit.ProjectID = entry.Project;
             unit.ProjectRun = entry.Run;
             unit.ProjectClone = entry.Clone;
             unit.ProjectGen = entry.Gen;

             /* FoldingID and Team from Queue Entry */
             unit.FoldingID = options.User ?? Constants.DefaultFoldingID;
             unit.Team = options.Team ?? Constants.DefaultTeam;
             unit.SlotType = (SlotType)Enum.Parse(typeof(SlotType), slotOptions.FahClientSubTypeEnum.ToString());

             /* Core ID */
             unit.CoreID = entry.Core.Replace("0x", String.Empty).ToUpperInvariant();
        }
コード例 #7
0
      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 == FahUnitStatus.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 == FahUnitStatus.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);
            }
         }
      }
コード例 #8
0
      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;
      }
コード例 #9
0
      private static ClientQueue BuildClientQueue(IEnumerable<Unit> unitCollection, Info info, SlotOptions slotOptions, int slotId)
      {
         ClientQueue 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 ClientQueue { ClientType = ClientType.FahClient, CurrentIndex = -1 };
            }

            var cqe = new ClientQueueEntry();
            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 = info.System.OperatingSystemEnum.ToOperatingSystemString(info.System.OperatingSystemArchitectureEnum);
            // 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 == FahUnitStatus.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;
      }
コード例 #10
0
      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.CpuType.ToCpuTypeString();
         }

         return String.Empty;
      }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the Slot class.
 /// </summary>
 public Slot()
 {
     SlotOptions = new SlotOptions();
     _errors     = new List <MessagePropertyConversionError>();
 }
コード例 #12
0
        private static UnitInfo BuildUnitInfo(Unit queueEntry, Options options, SlotOptions slotOptions, FahLogUnitData fahLogUnitData)
        {
            Debug.Assert(queueEntry != null);
             Debug.Assert(options != null);
             Debug.Assert(slotOptions != null);

             var unit = new UnitInfo();
             unit.QueueIndex = queueEntry.Id;
             if (fahLogUnitData != null)
             {
            unit.UnitStartTimeStamp = fahLogUnitData.UnitStartTimeStamp;
            unit.FramesObserved = fahLogUnitData.FramesObserved;
            unit.CoreVersion = fahLogUnitData.CoreVersion;
            unit.UnitResult = fahLogUnitData.UnitResult;

            // there is no finished time available from the client API
            // since the unit history database won't write the same
            // result twice, the first time this hits use the local UTC
            // value for the finished time... not as good as what was
            // available with v6.
            if (unit.UnitResult.Equals(WorkUnitResult.FinishedUnit))
            {
               unit.FinishedTime = DateTime.UtcNow;
            }
             }

             PopulateUnitInfoFromQueueEntry(queueEntry, options, slotOptions, unit);
             if (fahLogUnitData != null)
             {
            // parse the frame data
            ParseFrameData(fahLogUnitData.FrameDataList, unit);
             }

             return unit;
        }
コード例 #13
0
ファイル: SlotOptionsTests.cs プロジェクト: kszysiu/hfm-net
 public void FillTest5_2()
 {
     string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_5\\slot-options2.txt");
      var slotOptions = new SlotOptions();
      slotOptions.Fill(MessageCache.GetNextJsonMessage(ref message));
      Assert.AreEqual(null, slotOptions.Cpus);
      Assert.AreEqual("advanced", slotOptions.FahClientType);
      Assert.AreEqual(FahClientType.Advanced, slotOptions.FahClientTypeEnum);
      Assert.AreEqual("GPU", slotOptions.FahClientSubType);
      Assert.AreEqual(FahClientSubType.GPU, slotOptions.FahClientSubTypeEnum);
      Assert.AreEqual(1, 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(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);
 }
コード例 #14
0
ファイル: SlotOptionsTests.cs プロジェクト: kszysiu/hfm-net
 public void FillTest4_3()
 {
     string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_4\\slot-options3.txt");
      var slotOptions = new SlotOptions();
      slotOptions.Fill(MessageCache.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);
 }
コード例 #15
0
      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
      }
コード例 #16
0
        public void Client_v7_10_0()
        {
            const int slotId = 0;
             _dataAggregator.ClientName = "Client_v7_10";

             var lines = LogReader.GetLogLines(File.ReadAllLines("..\\..\\..\\TestFiles\\Client_v7_10\\log.txt").Where(x => x.Length != 0), LogFileType.FahClient);
             lines = lines.Filter(LogFilterType.SlotAndNonIndexed, slotId).ToList();

             string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\units.txt");
             var unitCollection = new UnitCollection();
             unitCollection.Fill(MessageCache.GetNextJsonMessage(ref message));

             message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\info.txt");
             var info = new Info();
             info.Fill(MessageCache.GetNextJsonMessage(ref message));

             message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\options.txt");
             var options = new Options();
             options.Fill(MessageCache.GetNextJsonMessage(ref message));

             message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_10\\slot-options1.txt");
             var slotOptions = new SlotOptions();
             slotOptions.Fill(MessageCache.GetNextJsonMessage(ref message));

             var units = _dataAggregator.AggregateData(lines, unitCollection, info, options, slotOptions, new UnitInfo(), slotId);
             Assert.AreEqual(1, units.Count);
             Assert.IsFalse(units.Any(x => x.Value == null));

             #region Check Data Aggregator
             Assert.IsNotNull(_dataAggregator.Queue);
             Assert.AreEqual(1, _dataAggregator.CurrentUnitIndex);
             Assert.IsNotNull(_dataAggregator.CurrentClientRun);
             Assert.IsNotNull(_dataAggregator.CurrentLogLines);
             Assert.AreEqual(1, _dataAggregator.UnitLogLines.Count);
             Assert.IsFalse(_dataAggregator.UnitLogLines.Any(x => x.Value == null));
             if (_dataAggregator.UnitLogLines.ContainsKey(_dataAggregator.CurrentUnitIndex))
             {
            Assert.AreEqual(_dataAggregator.CurrentLogLines, _dataAggregator.UnitLogLines[_dataAggregator.CurrentUnitIndex]);
             }
             #endregion

             var unitInfoData = units[_dataAggregator.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
        }
コード例 #17
0
        private IDictionary<int, UnitInfo> GenerateUnitInfoDataFromQueue(IEnumerable<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);

             var parsedUnits = new Dictionary<int, UnitInfo>();
             _unitLogLines = new Dictionary<int, IList<LogLine>>();

             bool foundCurrentUnitInfo = false;

             foreach (var unit in unitCollection)
             {
            if (unit.Slot != slotId)
            {
               // does not match requested slot
               continue;
            }

            var projectInfo = new ProjectInfo { ProjectID = unit.Project, ProjectRun = unit.Run,
                                                ProjectClone = unit.Clone, ProjectGen = unit.Gen };
            if (projectInfo.EqualsProject(currentUnitInfo) &&
                unit.AssignedDateTime.GetValueOrDefault().Equals(currentUnitInfo.DownloadTime))
            {
               foundCurrentUnitInfo = true;
            }

            FahLogUnitData fahLogUnitData = null;
            // Get the Log Lines for this queue position from the reader
            var logLines = _logInterpreter.GetLogLinesForQueueIndex(unit.Id, projectInfo);
            if (logLines == null)
            {
               string message = String.Format(CultureInfo.CurrentCulture,
                  "Could not find log section for slot {0}. Cannot update frame data for this slot.", slotId);
               _logger.Warn(Constants.ClientNameFormat, ClientName, message);
            }
            else
            {
               // Get the FAH Log Data from the Log Lines
               fahLogUnitData = LogReader.GetFahLogDataFromLogLines(logLines);
            }

            UnitInfo unitInfo = BuildUnitInfo(unit, options, slotOptions, fahLogUnitData);
            if (unitInfo != null)
            {
               parsedUnits.Add(unit.Id, unitInfo);
               if (logLines != null)
               {
                  _unitLogLines.Add(unit.Id, logLines);
               }
               if (unit.StateEnum.Equals(FahUnitStatus.Running))
               {
                  _currentUnitIndex = unit.Id;
               }
            }
             }

             // if no running WU found
             if (_currentUnitIndex == -1)
             {
            // look for a WU with Ready state
            var unit = unitCollection.FirstOrDefault(x => x.Slot == slotId && x.StateEnum.Equals(FahUnitStatus.Ready));
            if (unit != null)
            {
               _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 logLines = _logInterpreter.GetLogLinesForQueueIndex(currentUnitInfo.QueueIndex, currentUnitInfo);
            if (logLines != null)
            {
               // Get the FAH Log Data from the Log Lines
               FahLogUnitData fahLogUnitData = LogReader.GetFahLogDataFromLogLines(logLines);

               // 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();

               UpdateUnitInfo(currentClone, fahLogUnitData);
               parsedUnits.Add(currentClone.QueueIndex, currentClone);
               _unitLogLines.Add(currentClone.QueueIndex, logLines);
            }
             }

             return parsedUnits;
        }
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of the Slot class.
 /// </summary>
 public Slot()
 {
     SlotOptions = new SlotOptions();
 }
コード例 #19
0
        /// <summary>
        /// Aggregate Data and return UnitInfo Dictionary.
        /// </summary>
        public IDictionary<int, UnitInfo> AggregateData(ICollection<LogLine> logLines, UnitCollection unitCollection, Info info, Options options, 
            SlotOptions slotOptions, UnitInfo currentUnitInfo, int slotId)
        {
            if (logLines == null) throw new ArgumentNullException("logLines");
             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");

             _currentUnitIndex = -1;
             // only take up to the last MaxDisplayableLogLines
             _currentLogLines = logLines.Skip(Math.Max(0, logLines.Count - Constants.MaxDisplayableLogLines)).ToList();
             _logInterpreter = new LogInterpreter(logLines, LogReader.GetClientRuns(logLines, LogFileType.FahClient));
             _currentClientRun = _logInterpreter.CurrentClientRun;

             // report errors that came back from log parsing
             foreach (var s in _logInterpreter.LogLineParsingErrors)
             {
            _logger.Debug(Constants.ClientNameFormat, ClientName, s);
             }

             IDictionary<int, UnitInfo> parsedUnits = GenerateUnitInfoDataFromQueue(unitCollection, options, slotOptions, currentUnitInfo, slotId);
             _clientQueue = BuildClientQueue(unitCollection, info, slotOptions, slotId);
             _logInterpreter = null;

             return parsedUnits;
        }