Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/30/18 12:56:00 (7 years ago)
Author:
jzenisek
Message:

#2839

  • adapted computation of DimClient and FactClientInfo stats
  • adapted web app according to new stats computation
Location:
branches/HiveProjectManagement/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ClientController.cs

    r14185 r15671  
    7474                  on client.Id equals info.ClientId into clientInfoJoin
    7575                from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
    76                 let offline = (client.ExpirationTime != null || clientInfo.SlaveState == SlaveState.Offline)
     76                let offline = (client.DateExpired != null || clientInfo.SlaveState == SlaveState.Offline)
     77                let parent = client.ParentResourceId.HasValue ? dimClientDao.GetById(client.ParentResourceId.Value) : null
    7778                select new DT.ClientDetails {
    7879                  Id = client.Id,
     
    8586                  State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
    8687                  LastUpdate = clientInfo.Time,
    87                   GroupId = client.ResourceGroupId,
    88                   GroupName = client.GroupName,
     88                  GroupId = client.ParentResourceId,
     89                  GroupName = parent != null ? parent.Name : null,
    8990                  UpTime = offline ? 0 : upTime,
    9091                  TotalUnavailableTime = timeData != null ? timeData.TotalUnavailableTime : 0,
     
    117118      var factClientInfoDao = pm.FactClientInfoDao;
    118119      return pm.UseTransaction(() => {
    119         var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients();
     120        var clients = expired ? dimClientDao.GetAllExpiredSlaves() : dimClientDao.GetAllOnlineSlaves();
    120121        var query = (from client in clients
    121122                     join info in factClientInfoDao.GetAll()
     
    123124                     from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
    124125                     let offline = (expired || clientInfo.SlaveState == SlaveState.Offline)
     126                     let parent = client.ParentResourceId.HasValue ? dimClientDao.GetById(client.ParentResourceId.Value) : null
    125127                     select new DT.Client {
    126128                       Id = client.Id,
     
    132134                       CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
    133135                       State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
    134                        GroupId = client.ResourceGroupId,
    135                        GroupName = client.GroupName,
     136                       GroupId = client.ParentResourceId,
     137                       GroupName = parent != null ? parent.Name : null,
    136138                       IsAllowedToCalculate = clientInfo.IsAllowedToCalculate
    137139                     });
     
    200202      var factClientInfoDao = pm.FactClientInfoDao;
    201203      return pm.UseTransaction(() => {
    202         var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients();
    203         clients = clients.Where(x => x.ResourceGroupId == id);
     204        var clients = expired ? dimClientDao.GetAllExpiredClients() : dimClientDao.GetAllOnlineClients();
     205        clients = clients.Where(x => x.ParentResourceId == id);
    204206        var query = (from client in clients
    205207                     join info in factClientInfoDao.GetAll()
     
    207209                     from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
    208210                     let offline = (expired || clientInfo.SlaveState == SlaveState.Offline)
     211                     let parent = client.ParentResourceId.HasValue ? dimClientDao.GetById(client.ParentResourceId.Value) : null
    209212                     select new DT.Client {
    210213                       Id = client.Id,
     
    216219                       CpuUtilization = offline ? 0 : clientInfo.CpuUtilization,
    217220                       State = offline ? SlaveState.Offline.ToString() : clientInfo.SlaveState.ToString(),
    218                        GroupId = client.ResourceGroupId,
    219                        GroupName = client.GroupName,
     221                       GroupId = client.ParentResourceId,
     222                       GroupName = parent != null ? parent.Name : null,
    220223                       IsAllowedToCalculate = clientInfo.IsAllowedToCalculate
    221224                     });
     
    247250          client => client.Id,
    248251          (fact, client) => new {
    249             client.ResourceGroupId,
     252            client.ParentResourceId,
    250253            fact.Time,
    251254            fact.CpuUtilization,
     
    255258            fact.UsedMemory
    256259          })
    257         .Where(x => x.ResourceGroupId == id)
     260        .Where(x => x.ParentResourceId == id)
    258261        .ToList();
    259262      var clientStatus = new DT.ClientStatus {
  • branches/HiveProjectManagement/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/GroupController.cs

    r14185 r15671  
    4242        var clientTimeData = factClientInfoDao.GetAll()
    4343          .Join(dimClientDao.GetAll(), x => x.ClientId, y => y.Id, (x, y) => new {
    44             y.ResourceGroupId,
     44            y.ParentResourceId,
    4545            x.IdleTime,
    4646            x.OfflineTime,
    4747            x.UnavailableTime
    4848          })
    49           .Where(x => x.ResourceGroupId == id)
    50           .GroupBy(x => x.ResourceGroupId)
     49          .Where(x => x.ParentResourceId == id)
     50          .GroupBy(x => x.ParentResourceId)
    5151          .Select(x => new {
    5252            TotalIdleTime = x.Sum(y => y.IdleTime),
     
    6868          })
    6969          .FirstOrDefault();
    70         return (from client in dimClientDao.GetActiveClients().Where(x => x.ResourceGroupId == id)
     70        return (from client in dimClientDao.GetAllOnlineSlaves().Where(x => x.ParentResourceId == id)
    7171                join info in factClientInfoDao.GetAll()
    7272                  on client.Id equals info.ClientId into clientInfoJoin
    7373                from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1)
    7474                let offline = (clientInfo.SlaveState == DA.SlaveState.Offline)
     75                let parent = client.ParentResourceId.HasValue ? dimClientDao.GetById(client.ParentResourceId.Value) : null
    7576                select new {
    76                   ResourceGroupId = client.ResourceGroupId,
    77                   GroupName = client.GroupName,
     77                  ResourceGroupId = client.ParentResourceId,
     78                  GroupName = parent != null ? parent.Name : null,
    7879                  TotalCores = clientInfo.NumTotalCores,
    7980                  UsedCores = offline ? 0 : clientInfo.NumUsedCores,
     
    114115      var dimClientDao = pm.DimClientDao;
    115116      var factClientInfoDao = pm.FactClientInfoDao;
    116       var data = (from client in dimClientDao.GetActiveClients()
     117      var data = (from client in dimClientDao.GetAllOnlineSlaves()
    117118                  join info in factClientInfoDao.GetAll()
    118119                    on client.Id equals info.ClientId into clientInfoJoin
     
    120121                  let offline = (clientInfo.SlaveState == DA.SlaveState.Offline)
    121122                  select new {
    122                     ResourceGroupId = client.ResourceGroupId,
     123                    ResourceGroupId = client.ParentResourceId,
    123124                    TotalCores = clientInfo.NumTotalCores,
    124125                    UsedCores = offline ? 0 : clientInfo.NumUsedCores,
     
    137138                    CpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0
    138139                  });
    139       var query = dimClientDao.GetAll()
    140         .GroupBy(x => new { x.ResourceGroupId, x.GroupName })
    141         .Select(x => new {
    142           Id = x.Key.ResourceGroupId ?? default(Guid),
    143           Name = x.Key.GroupName
    144         });
     140
     141      var query = dimClientDao.GetAllOnlineSlaveGroups().Select(x => new {
     142        Id = x.ResourceId,
     143        Name = x.Name
     144      });
    145145      return pm.UseTransaction(() => new DT.GroupPage {
    146146        TotalGroups = query.Count(),
Note: See TracChangeset for help on using the changeset viewer.