Exemplo n.º 1
0
        public void SlotModel_FindDuplicateProjects_WhenSomeProjectsAreDuplicates()
        {
            // Arrange
            var slotModel1 = new SlotModel(new NullClient());

            slotModel1.WorkUnitModel = new WorkUnitModel(slotModel1, new WorkUnit {
                ProjectID = 1
            });
            var slotModel2 = new SlotModel(new NullClient());

            slotModel2.WorkUnitModel = new WorkUnitModel(slotModel2, new WorkUnit {
                ProjectID = 2
            });
            var slotModel3 = new SlotModel(new NullClient());

            slotModel3.WorkUnitModel = new WorkUnitModel(slotModel2, new WorkUnit {
                ProjectID = 1
            });
            // Act
            SlotModel.FindDuplicateProjects(new[] { slotModel1, slotModel2, slotModel3 });
            // Assert
            Assert.IsTrue(slotModel1.ProjectIsDuplicate);
            Assert.IsFalse(slotModel2.ProjectIsDuplicate);
            Assert.IsTrue(slotModel3.ProjectIsDuplicate);
        }
Exemplo n.º 2
0
        internal void RefreshSlots()
        {
            _slotsLock.EnterWriteLock();
            try
            {
                _slots.Clear();
                if (Messages.SlotCollection != null)
                {
                    // iterate through slot collection
                    foreach (var slot in Messages.SlotCollection)
                    {
                        var slotDescription = ParseSlotDescription(slot.Description);
                        // add slot model to the collection
                        var slotModel = new SlotModel(this)
                        {
                            Status        = (SlotStatus)Enum.Parse(typeof(SlotStatus), slot.Status, true),
                            SlotID        = slot.ID.GetValueOrDefault(),
                            SlotType      = slotDescription.SlotType,
                            SlotThreads   = slotDescription.CPUThreads,
                            SlotProcessor = slotDescription.GPU
                        };
                        _slots.Add(slotModel);
                    }
                }
            }
            finally
            {
                _slotsLock.ExitWriteLock();
            }

            OnSlotsChanged(EventArgs.Empty);
        }
Exemplo n.º 3
0
 private static void SetSlotStatus(SlotModel slotModel)
 {
     if (slotModel.Status == SlotStatus.Running ||
         slotModel.Status == SlotStatus.RunningNoFrameTimes)
     {
         slotModel.Status = slotModel.IsUsingBenchmarkFrameTime ? SlotStatus.RunningNoFrameTimes : SlotStatus.Running;
     }
 }
Exemplo n.º 4
0
        private WorkUnitModel BuildWorkUnitModel(SlotModel slotModel, WorkUnit workUnit)
        {
            Debug.Assert(slotModel != null);
            Debug.Assert(workUnit != null);

            Protein protein = ProteinService.GetOrRefresh(workUnit.ProjectID) ?? new Protein();

            // update the data
            workUnit.UnitRetrievalTime = LastRetrievalTime;
            var workUnitModel = new WorkUnitModel(slotModel, workUnit);

            workUnitModel.CurrentProtein = protein;
            return(workUnitModel);
        }
Exemplo n.º 5
0
        private static WorkUnitQueue BuildWorkUnitQueue(IEnumerable <Unit> unitCollection, Info info, SlotModel slotModel)
        {
            WorkUnitQueue d = null;

            foreach (var unit in unitCollection.Where(unit => unit.Slot == slotModel.SlotID))
            {
                if (d == null)
                {
                    d = new WorkUnitQueue();
                }

                var wui = new WorkUnitQueueItem(unit.ID.GetValueOrDefault());
                wui.ProjectID           = unit.Project.GetValueOrDefault();
                wui.ProjectRun          = unit.Run.GetValueOrDefault();
                wui.ProjectClone        = unit.Clone.GetValueOrDefault();
                wui.ProjectGen          = unit.Gen.GetValueOrDefault();
                wui.State               = unit.State;
                wui.WaitingOn           = unit.WaitingOn;
                wui.Attempts            = unit.Attempts.GetValueOrDefault();
                wui.NextAttempt         = unit.NextAttemptTimeSpan.GetValueOrDefault();
                wui.AssignedDateTimeUtc = unit.AssignedDateTime.GetValueOrDefault();
                wui.WorkServer          = unit.WorkServer;
                wui.CPU             = GetCPUString(info, slotModel);
                wui.OperatingSystem = info.System.OS;
                // Memory Value is in Gigabytes - turn into Megabytes and truncate
                wui.Memory     = (int)(info.System.MemoryValue.GetValueOrDefault() * 1024);
                wui.CPUThreads = info.System.CPUs.GetValueOrDefault();
                wui.SlotID     = slotModel.SlotID;

                d.Add(wui);
                if (unit.State.Equals("RUNNING", StringComparison.OrdinalIgnoreCase))
                {
                    d.CurrentQueueID = unit.ID.GetValueOrDefault();
                }
            }

            if (d != null)
            {
                if (d.CurrentQueueID == WorkUnitQueue.NoQueueID)
                {
                    d.CurrentQueueID = d.DefaultQueueID;
                }
            }

            return(d);
        }
Exemplo n.º 6
0
 public FahClientMessageAggregator(IFahClient fahClient, SlotModel slotModel)
 {
     FahClient = fahClient;
     SlotModel = slotModel;
 }
Exemplo n.º 7
0
 internal static string GetCPUString(Info info, SlotModel slotModel)
 {
     return(slotModel.SlotType == SlotType.GPU
         ? slotModel.SlotProcessor
         : info.System.CPU);
 }
Exemplo n.º 8
0
        public async Task FahClientMessageAggregator_Client_v7_11_SlotID_0()
        {
            // Arrange
            var settings = new ClientSettings {
                Name = "Client_v7_11"
            };
            var fahClient = CreateClient(settings);

            using (var textReader = new StreamReader(@"..\..\..\..\TestFiles\Client_v7_11\log.txt"))
                using (var reader = new FahClientLogTextReader(textReader))
                {
                    await fahClient.Messages.Log.ReadAsync(reader);
                }

            var extractor = new FahClientJsonMessageExtractor();
            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_11\units.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_11\info.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_11\options.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_11\slots.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_11\slot-options1.txt"))));

            var slotModel = new SlotModel(fahClient)
            {
                SlotID = 0
            };
            var aggregator = new FahClientMessageAggregator(fahClient, slotModel);

            // Act
            var result = aggregator.AggregateData();

            // Assert
            Assert.AreEqual(1, result.WorkUnits.Count);
            Assert.IsFalse(result.WorkUnits.Any(x => x.Value == null));

            #region Check Data Aggregator

            Assert.IsNotNull(result.WorkUnitQueue);
            Assert.AreEqual(1, result.CurrentUnitIndex);
            Assert.AreEqual(new DateTime(2012, 2, 18, 6, 33, 41), 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.WorkUnits.Any(x => x.Value.LogLines == null));
            if (result.WorkUnits.ContainsKey(result.CurrentUnitIndex))
            {
                Assert.AreEqual(result.CurrentLogLines, result.WorkUnits[result.CurrentUnitIndex].LogLines);
            }

            #endregion

            var unitInfoData = result.WorkUnits[result.CurrentUnitIndex];

            #region Check Unit Info Data Values
            Assert.AreEqual(DateTime.MinValue, unitInfoData.UnitRetrievalTime);
            Assert.AreEqual("harlam357", unitInfoData.FoldingID);
            Assert.AreEqual(32, unitInfoData.Team);
            Assert.AreEqual(new DateTime(2012, 2, 17, 21, 48, 22), unitInfoData.Assigned);
            Assert.AreEqual(new DateTime(2012, 2, 29, 14, 50, 46), unitInfoData.Timeout);
            Assert.AreEqual(new TimeSpan(6, 34, 38), unitInfoData.UnitStartTimeStamp);
            Assert.AreEqual(DateTime.MinValue, unitInfoData.Finished);
            Assert.AreEqual(2.27f, unitInfoData.CoreVersion);
            Assert.AreEqual(7610, unitInfoData.ProjectID);
            Assert.AreEqual(192, unitInfoData.ProjectRun);
            Assert.AreEqual(0, unitInfoData.ProjectClone);
            Assert.AreEqual(58, unitInfoData.ProjectGen);
            Assert.AreEqual(null, unitInfoData.ProteinName);
            Assert.AreEqual(null, unitInfoData.ProteinTag);
            Assert.AreEqual(WorkUnitResult.Unknown, unitInfoData.UnitResult);
            Assert.AreEqual(3, unitInfoData.FramesObserved);
            Assert.AreEqual(95, unitInfoData.CurrentFrame.ID);
            Assert.AreEqual(1900000, unitInfoData.CurrentFrame.RawFramesComplete);
            Assert.AreEqual(2000000, unitInfoData.CurrentFrame.RawFramesTotal);
            Assert.AreEqual(new TimeSpan(6, 46, 16), unitInfoData.CurrentFrame.TimeStamp);
            Assert.AreEqual(new TimeSpan(0, 4, 50), unitInfoData.CurrentFrame.Duration);
            Assert.AreEqual("A4", unitInfoData.CoreID);
            #endregion
        }
Exemplo n.º 9
0
        public async Task FahClientMessageAggregator_Client_v7_10_SlotID_0_UnitDataOnly()
        {
            // Arrange
            var settings = new ClientSettings {
                Name = "Client_v7_10"
            };
            var fahClient = CreateClient(settings);

            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))
                {
                    await fahClient.Messages.Log.ReadAsync(reader);
                }

            var extractor = new FahClientJsonMessageExtractor();
            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\units.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\info.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\options.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\slots.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\slot-options1.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\slot-options2.txt"))));

            var slotModel = new SlotModel(fahClient)
            {
                SlotID = 0
            };
            var aggregator = new FahClientMessageAggregator(fahClient, slotModel);

            // Act
            var result = aggregator.AggregateData();

            // Assert
            Assert.AreEqual(1, result.WorkUnits.Count);
            Assert.IsFalse(result.WorkUnits.Any(x => x.Value == null));

            #region Check Data Aggregator

            Assert.IsNotNull(result.WorkUnitQueue);
            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.WorkUnits.All(x => x.Value.LogLines == null));
            if (result.WorkUnits.ContainsKey(result.CurrentUnitIndex))
            {
                Assert.AreEqual(result.CurrentLogLines, LogLineEnumerable.Create(fahClient.Messages.Log.ClientRuns.Last()));
            }

            #endregion

            var unitInfoData = result.WorkUnits[result.CurrentUnitIndex];

            #region Check Unit Info Data Values
            Assert.AreEqual(DateTime.MinValue, unitInfoData.UnitRetrievalTime);
            Assert.AreEqual("harlam357", unitInfoData.FoldingID);
            Assert.AreEqual(32, unitInfoData.Team);
            Assert.AreEqual(new DateTime(2012, 1, 10, 23, 20, 27), unitInfoData.Assigned);
            Assert.AreEqual(new DateTime(2012, 1, 22, 16, 22, 51), unitInfoData.Timeout);
            Assert.AreEqual(TimeSpan.Zero, unitInfoData.UnitStartTimeStamp);
            Assert.AreEqual(DateTime.MinValue, unitInfoData.Finished);
            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(null, unitInfoData.ProteinName);
            Assert.AreEqual(null, unitInfoData.ProteinTag);
            Assert.AreEqual(WorkUnitResult.Unknown, unitInfoData.UnitResult);
            Assert.AreEqual(0, unitInfoData.FramesObserved);
            Assert.IsNull(unitInfoData.CurrentFrame);
            Assert.AreEqual("A4", unitInfoData.CoreID);
            #endregion
        }
Exemplo n.º 10
0
        private void PopulateRunLevelData(ClientMessageAggregatorResult result, Info info, SlotModel slotModel)
        {
            Debug.Assert(slotModel != null);

            if (info != null)
            {
                // TODO: Surface client arguments?
                //slotModel.Arguments = info.Client.Args;
                slotModel.ClientVersion = info.Client.Version;
                slotModel.SlotProcessor = FahClientMessageAggregator.GetCPUString(info, slotModel);
            }
            if (WorkUnitRepository.Connected)
            {
                slotModel.TotalRunCompletedUnits = (int)WorkUnitRepository.CountCompleted(slotModel.Name, result.StartTime);
                slotModel.TotalCompletedUnits    = (int)WorkUnitRepository.CountCompleted(slotModel.Name, null);
                slotModel.TotalRunFailedUnits    = (int)WorkUnitRepository.CountFailed(slotModel.Name, result.StartTime);
                slotModel.TotalFailedUnits       = (int)WorkUnitRepository.CountFailed(slotModel.Name, null);
            }
        }