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;
      }
Example #2
0
 private static void PopulateRunLevelData(ClientQueueEntry queueEntry, SlotModel slotModel)
 {
     if (slotModel.UserId == Constants.DefaultUserID)
      {
     slotModel.UserId = queueEntry.UserID;
      }
      if (slotModel.MachineId == Constants.DefaultMachineID)
      {
     slotModel.MachineId = queueEntry.MachineID;
      }
 }