Пример #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
      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;
      }
Пример #3
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();
      }
Пример #4
0
 public void FillTest12()
 {
    string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_12\\options.txt");
    var options = new Options();
    options.Fill(MessageCache.GetNextJsonMessage(ref message));
    Assert.AreEqual("assign3.stanford.edu:8080 assign4.stanford.edu:80", options.AssignmentServers);
    Assert.AreEqual("capture", options.CaptureDirectory);
    Assert.AreEqual(false, options.CaptureOnError);
    Assert.AreEqual(false, options.CapturePackets);
    Assert.AreEqual(false, options.CaptureRequests);
    Assert.AreEqual(false, options.CaptureResponses);
    Assert.AreEqual(false, options.CaptureSockets);
    Assert.AreEqual("ANY", options.Cause);
    // Assert.AreEqual(null, options.CertificateFile);
    Assert.AreEqual(15, options.Checkpoint);
    Assert.AreEqual(false, options.Child);
    Assert.AreEqual("STDCLI", options.FahClientSubType);
    Assert.AreEqual(FahClientSubType.CPU, options.FahClientSubTypeEnum);
    Assert.AreEqual(4, options.ClientThreads);
    Assert.AreEqual("normal", options.FahClientType);
    Assert.AreEqual(FahClientType.Normal, options.FahClientTypeEnum);
    Assert.AreEqual("0.0.0.0", options.CommandAddress);
    Assert.AreEqual("127.0.0.1", options.Allow);
    Assert.AreEqual("127.0.0.1", options.CommandAllowNoPass);
    Assert.AreEqual("0/0", options.Deny);
    Assert.AreEqual("0/0", options.CommandDenyNoPass);
    Assert.AreEqual(36330, options.CommandPort);
    Assert.AreEqual(true, options.ConfigRotate);
    Assert.AreEqual("configs", options.ConfigRotateDir);
    Assert.AreEqual(16, options.ConfigRotateMax);
    Assert.AreEqual(60, options.ConnectionTimeout);
    Assert.AreEqual("cores", options.CoreDir);
    Assert.AreEqual(null, options.CoreKey);
    Assert.AreEqual(null, options.CorePrep);
    Assert.AreEqual("idle", options.CorePriority);
    Assert.AreEqual(CorePriority.Idle, options.CorePriorityEnum);
    Assert.AreEqual(null, options.CoreServer);
    Assert.AreEqual(false, options.CpuAffinity);
    Assert.AreEqual("X86_PENTIUM_II", options.CpuSpecies);
    Assert.AreEqual("AMD64", options.CpuType);
    Assert.AreEqual(100, options.CpuUsage);
    Assert.AreEqual(-1, options.Cpus);
    // Assert.AreEqual(null, options.CrlFile);
    Assert.AreEqual(0, options.CudaIndex);
    Assert.AreEqual(4, options.CycleRate);
    Assert.AreEqual(-1, options.Cycles);
    Assert.AreEqual(false, options.Daemon);
    Assert.AreEqual(".", options.DataDirectory);
    Assert.AreEqual(false, options.DebugSockets);
    Assert.AreEqual(null, options.DisableProjectLookup);
    Assert.AreEqual(true, options.DisableSleepWhenActive);
    Assert.AreEqual(true, options.DumpAfterDeadline);
    Assert.AreEqual(null, options.Eval);
    Assert.AreEqual(true, options.ExceptionLocations);
    Assert.AreEqual("C:\\Program Files (x86)\\FAHClient", options.ExecDirectory);
    Assert.AreEqual(false, options.ExitWhenDone);
    Assert.AreEqual(null, options.ExtraCoreArgs);
    Assert.AreEqual(false, options.FoldAnon);
    Assert.AreEqual(null, options.ForceWs);
    Assert.AreEqual(true, options.Gpu);
    Assert.AreEqual("assign-GPU.stanford.edu:80 assign-GPU.stanford.edu:8080", options.GpuAssignmentServers);
    Assert.AreEqual(null, options.GpuDeviceId);
    Assert.AreEqual(null, options.GpuId);
    Assert.AreEqual(null, options.GpuVendorId);
    Assert.AreEqual(null, options.GpuIndex);
    Assert.AreEqual(100, options.GpuUsage);
    Assert.AreEqual("0:7396", options.HttpAddresses);
    Assert.AreEqual("", options.HttpsAddresses);
    Assert.AreEqual(100, options.GpuUsage);
    Assert.AreEqual(300, options.IdleSeconds);
    Assert.AreEqual(false, options.LogColor);
    Assert.AreEqual(true, options.LogCrlf);
    Assert.AreEqual(false, options.LogDate);
    Assert.AreEqual(21600, options.LogDatePeriodically);
    Assert.AreEqual(true, options.LogDebug);
    Assert.AreEqual(false, options.LogDomain);
    Assert.AreEqual(null, options.LogDomainLevels);
    Assert.AreEqual(true, options.LogHeader);
    Assert.AreEqual(true, options.LogLevel);
    Assert.AreEqual(true, options.LogNoInfoHeader);
    Assert.AreEqual(false, options.LogRedirect);
    Assert.AreEqual(true, options.LogRotate);
    Assert.AreEqual("logs", options.LogRotateDir);
    Assert.AreEqual(16, options.LogRotateMax);
    Assert.AreEqual(false, options.LogShortLevel);
    Assert.AreEqual(true, options.LogSimpleDomains);
    Assert.AreEqual(false, options.LogThreadId);
    Assert.AreEqual(true, options.LogTime);
    Assert.AreEqual(true, options.LogToScreen);
    Assert.AreEqual(false, options.LogTruncate);
    Assert.AreEqual(0, options.MachineId);
    Assert.AreEqual(null, options.MaxDelay);
    Assert.AreEqual(900, options.MaxConnectTime);
    Assert.AreEqual(800, options.MaxConnections);
    Assert.AreEqual("normal", options.MaxPacketSize);
    Assert.AreEqual(MaxPacketSize.Normal, options.MaxPacketSizeEnum);
    Assert.AreEqual(16, options.MaxQueue);
    Assert.AreEqual(52428800, options.MaxRequestLength);
    Assert.AreEqual(60, options.MaxShutdownWait);
    Assert.AreEqual(5, options.MaxSlotErrors);
    Assert.AreEqual(5, options.MaxUnitErrors);
    Assert.AreEqual(0, options.MaxUnits);
    Assert.AreEqual(null, options.Memory);
    Assert.AreEqual(null, options.MinDelay);
    Assert.AreEqual(300, options.MinConnectTime);
    Assert.AreEqual(99, options.NextUnitPercentage);
    Assert.AreEqual(null, options.Priority);
    Assert.AreEqual(false, options.NoAssembly);
    Assert.AreEqual(0, options.OpenClIndex);
    Assert.AreEqual("UNKNOWN", options.OsSpecies);
    Assert.AreEqual("WIN32", options.OsType);
    Assert.AreEqual("", options.Passkey);
    Assert.AreEqual(null, options.Password);
    Assert.AreEqual(true, options.PauseOnBattery);
    Assert.AreEqual(false, options.PauseOnStart);
    Assert.AreEqual(false, options.Pid);
    Assert.AreEqual("Folding@home Client.pid", options.PidFile);
    Assert.AreEqual("medium", options.Power);
    // Assert.AreEqual(null, options.PrivateKeyFile);
    Assert.AreEqual(0, options.ProjectKey);
    Assert.AreEqual(":8080", options.Proxy);
    Assert.AreEqual(false, options.ProxyEnable);
    Assert.AreEqual(String.Empty, options.ProxyPass);
    Assert.AreEqual(String.Empty, options.ProxyUser);
    Assert.AreEqual(false, options.Respawn);
    Assert.AreEqual(null, options.RunAs);
    Assert.AreEqual(null, options.Script);
    Assert.AreEqual(false, options.Service);
    Assert.AreEqual("Folding@home Client", options.ServiceDescription);
    Assert.AreEqual(true, options.ServiceRestart);
    Assert.AreEqual(5000, options.ServiceRestartDelay);
    Assert.AreEqual(3600, options.SessionTimeout);
    Assert.AreEqual(true, options.Smp);
    Assert.AreEqual(false, options.StackTraces);
    Assert.AreEqual(32, options.Team);
    Assert.AreEqual(4, options.Threads);
    Assert.AreEqual("harlam357", options.User);
    Assert.AreEqual(3, options.Verbosity);
    Assert.AreEqual("127.0.0.1", options.WebAllow);
    Assert.AreEqual("0/0", options.WebDeny);
 }
Пример #5
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);
            }
         }
      }
      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
      }
Пример #7
0
 public void FillTest7()
 {
    string message = File.ReadAllText("..\\..\\..\\TestFiles\\Client_v7_7\\options.txt");
    var options = new Options();
    options.Fill(MessageCache.GetNextJsonMessage(ref message));
    Assert.AreEqual("assign3.stanford.edu:8080 assign4.stanford.edu:80", options.AssignmentServers);
    Assert.AreEqual("capture", options.CaptureDirectory);
    Assert.AreEqual(false, options.CaptureSockets);
    Assert.AreEqual(15, options.Checkpoint);
    Assert.AreEqual(false, options.Child);
    Assert.AreEqual("STDCLI", options.FahClientSubType);
    Assert.AreEqual(FahClientSubType.CPU, options.FahClientSubTypeEnum);
    Assert.AreEqual("normal", options.FahClientType);
    Assert.AreEqual(FahClientType.Normal, options.FahClientTypeEnum);
    Assert.AreEqual("0.0.0.0", options.CommandAddress);
    Assert.AreEqual("127.0.0.1", options.Allow);
    Assert.AreEqual("127.0.0.1", options.CommandAllowNoPass);
    Assert.AreEqual("0.0.0.0/0", options.Deny);
    Assert.AreEqual("0.0.0.0/0", options.CommandDenyNoPass);
    Assert.AreEqual(36330, options.CommandPort);
    Assert.AreEqual(true, options.ConfigRotate);
    Assert.AreEqual("configs", options.ConfigRotateDir);
    Assert.AreEqual(16, options.ConfigRotateMax);
    Assert.AreEqual("cores", options.CoreDir);
    Assert.AreEqual(null, options.CoreKey);
    Assert.AreEqual(null, options.CorePrep);
    Assert.AreEqual("idle", options.CorePriority);
    Assert.AreEqual(CorePriority.Idle, options.CorePriorityEnum);
    Assert.AreEqual(null, options.CoreServer);
    Assert.AreEqual(false, options.CpuAffinity);
    Assert.AreEqual("X86_PENTIUM_II", options.CpuSpecies);
    Assert.AreEqual("X86", options.CpuType);
    Assert.AreEqual(100, options.CpuUsage);
    Assert.AreEqual(4, options.Cpus);
    Assert.AreEqual(4, options.CycleRate);
    Assert.AreEqual(-1, options.Cycles);
    Assert.AreEqual(false, options.Daemon);
    Assert.AreEqual(".", options.DataDirectory);
    Assert.AreEqual(false, options.DebugSockets);
    Assert.AreEqual(true, options.DumpAfterDeadline);
    Assert.AreEqual(null, options.Eval);
    Assert.AreEqual(true, options.ExceptionLocations);
    Assert.AreEqual("C:\\folding\\FAH-V7\\FAHClient", options.ExecDirectory);
    Assert.AreEqual(false, options.ExitWhenDone);
    Assert.AreEqual(null, options.ExtraCoreArgs);
    Assert.AreEqual(null, options.ForceWs);
    Assert.AreEqual(false, options.Gpu);
    Assert.AreEqual("assign-GPU.stanford.edu:80 assign-GPU.stanford.edu:8080", options.GpuAssignmentServers);
    Assert.AreEqual(null, options.GpuDeviceId);
    Assert.AreEqual(0, options.GpuId);
    Assert.AreEqual(null, options.GpuIndex);
    Assert.AreEqual(null, options.GpuVendorId);
    Assert.AreEqual("log.txt", options.Log);
    Assert.AreEqual(false, options.LogColor);
    Assert.AreEqual(true, options.LogCrlf);
    Assert.AreEqual(false, options.LogDate);
    Assert.AreEqual(true, options.LogDebug);
    Assert.AreEqual(false, options.LogDomain);
    Assert.AreEqual(null, options.LogDomainLevels);
    Assert.AreEqual(true, options.LogHeader);
    Assert.AreEqual(true, options.LogLevel);
    Assert.AreEqual(true, options.LogNoInfoHeader);
    Assert.AreEqual(false, options.LogRedirect);
    Assert.AreEqual(true, options.LogRotate);
    Assert.AreEqual("logs", options.LogRotateDir);
    Assert.AreEqual(16, options.LogRotateMax);
    Assert.AreEqual(false, options.LogShortLevel);
    Assert.AreEqual(true, options.LogSimpleDomains);
    Assert.AreEqual(false, options.LogThreadId);
    Assert.AreEqual(true, options.LogTime);
    Assert.AreEqual(true, options.LogToScreen);
    Assert.AreEqual(false, options.LogTruncate);
    Assert.AreEqual(0, options.MachineId);
    Assert.AreEqual(21600, options.MaxDelay);
    Assert.AreEqual("normal", options.MaxPacketSize);
    Assert.AreEqual(MaxPacketSize.Normal, options.MaxPacketSizeEnum);
    Assert.AreEqual(16, options.MaxQueue);
    Assert.AreEqual(60, options.MaxShutdownWait);
    Assert.AreEqual(5, options.MaxSlotErrors);
    Assert.AreEqual(5, options.MaxUnitErrors);
    Assert.AreEqual(0, options.MaxUnits);
    Assert.AreEqual(null, options.Memory);
    Assert.AreEqual(60, options.MinDelay);
    Assert.AreEqual(99, options.NextUnitPercentage);
    Assert.AreEqual(null, options.Priority);
    Assert.AreEqual(false, options.NoAssembly);
    Assert.AreEqual("WIN_XP", options.OsSpecies);
    Assert.AreEqual("WIN32", options.OsType);
    Assert.AreEqual("xxxxx", options.Passkey);
    Assert.AreEqual("yyyyy", options.Password);
    Assert.AreEqual(false, options.PauseOnBattery);
    Assert.AreEqual(false, options.PauseOnStart);
    Assert.AreEqual(false, options.Pid);
    Assert.AreEqual("Folding@home Client.pid", options.PidFile);
    Assert.AreEqual(0, options.ProjectKey);
    Assert.AreEqual(":8080", options.Proxy);
    Assert.AreEqual(false, options.ProxyEnable);
    Assert.AreEqual(String.Empty, options.ProxyPass);
    Assert.AreEqual(String.Empty, options.ProxyUser);
    Assert.AreEqual(false, options.Respawn);
    Assert.AreEqual(null, options.RunAs);
    Assert.AreEqual(null, options.Script);
    Assert.AreEqual(false, options.Service);
    Assert.AreEqual("Folding@home Client", options.ServiceDescription);
    Assert.AreEqual(true, options.ServiceRestart);
    Assert.AreEqual(5000, options.ServiceRestartDelay);
    Assert.AreEqual(true, options.Smp);
    Assert.AreEqual(false, options.StackTraces);
    Assert.AreEqual(32, options.Team);
    Assert.AreEqual(4, options.Threads);
    Assert.AreEqual("HayesK", options.User);
    Assert.AreEqual(3, options.Verbosity);
 }
        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
        }
Пример #9
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;
        }
Пример #10
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();
        }
Пример #11
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;
        }
Пример #12
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;
        }