Changeset 12551 for branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/GroupController.cs
- Timestamp:
- 06/30/15 13:12:07 (9 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources
-
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/GroupController.cs
r12525 r12551 38 38 var dimClientDao = pm.DimClientDao; 39 39 var factClientInfoDao = pm.FactClientInfoDao; 40 var factTaskDao = pm.FactTaskDao; 40 41 return pm.UseTransaction(() => { 42 var clientTimeData = factClientInfoDao.GetAll() 43 .Join(dimClientDao.GetAll(), x => x.ClientId, y => y.Id, (x, y) => new { 44 y.ResourceGroupId, 45 x.IdleTime, 46 x.OfflineTime, 47 x.UnavailableTime 48 }) 49 .Where(x => x.ResourceGroupId == id) 50 .GroupBy(x => x.ResourceGroupId) 51 .Select(x => new { 52 TotalIdleTime = x.Sum(y => y.IdleTime), 53 TotalOfflineTime = x.Sum(y => y.OfflineTime), 54 TotalUnavailableTime = x.Sum(y => y.UnavailableTime) 55 }) 56 .FirstOrDefault(); 57 58 var taskTimeData = factTaskDao.GetByGroupId(id) 59 .Select(x => new { 60 id, 61 x.CalculatingTime, 62 x.TransferTime 63 }) 64 .GroupBy(x => x.id) 65 .Select(x => new { 66 CalculatingTime = x.Sum(y => y.CalculatingTime), 67 TransferTime = x.Sum(y => y.TransferTime) 68 }) 69 .FirstOrDefault(); 41 70 return (from client in dimClientDao.GetActiveClients().Where(x => x.ResourceGroupId == id) 42 71 join info in factClientInfoDao.GetAll() … … 51 80 TotalMemory = clientInfo.TotalMemory, 52 81 UsedMemory = offline ? 0 : clientInfo.UsedMemory, 53 CpuUtilization = offline ? 0 : clientInfo.CpuUtilization 82 CpuUtilization = offline ? 0 : clientInfo.CpuUtilization, 83 SlaveState = clientInfo.SlaveState 54 84 }) 55 85 .GroupBy(x => new { x.ResourceGroupId, x.GroupName }) 56 86 .Select(x => new DT.GroupDetails { 57 Id = x.Key.ResourceGroupId ?? default(Guid),87 Id = id, 58 88 Name = x.Key.GroupName, 59 Clients = x.Count(), 89 TotalClients = x.Count(), 90 OnlineClients = x.Count(y => y.SlaveState != DA.SlaveState.Offline), 60 91 TotalCores = x.Sum(y => y.TotalCores), 61 92 UsedCores = x.Sum(y => y.UsedCores), 62 93 TotalMemory = x.Sum(y => y.TotalMemory), 63 94 UsedMemory = x.Sum(y => y.UsedMemory), 64 CpuUtilization = x.Average(y => y.CpuUtilization) 95 TotalCpuUtilization = x.Average(y => (double?)y.CpuUtilization) ?? 0.0, 96 ActiveCpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0, 97 TotalUnavailableTime = clientTimeData != null ? clientTimeData.TotalUnavailableTime : 0, 98 TotalCalculatingTime = taskTimeData != null ? taskTimeData.CalculatingTime : 0, 99 TotalIdleTime = clientTimeData != null ? clientTimeData.TotalIdleTime : 0, 100 TotalOfflineTime = clientTimeData != null ? clientTimeData.TotalOfflineTime : 0, 101 TotalTransferringTime = taskTimeData != null ? taskTimeData.TransferTime : 0, 102 TasksStates = factTaskDao.GetByGroupId(id) 103 .GroupBy(y => y.TaskState) 104 .Select(y => new DT.TaskStateCount { 105 State = y.Key.ToString(), 106 Count = y.Count() 107 }).ToList() 65 108 }).FirstOrDefault(); 66 109 }); … … 83 126 TotalMemory = clientInfo.TotalMemory, 84 127 UsedMemory = offline ? 0 : clientInfo.UsedMemory, 85 CpuUtilization = offline ? 0 : clientInfo.CpuUtilization 128 CpuUtilization = offline ? 0 : clientInfo.CpuUtilization, 129 SlaveState = clientInfo.SlaveState 86 130 }).GroupBy(x => x.ResourceGroupId).Select(x => new { 87 131 GroupId = x.Key, 88 Count = x.Count(), 132 TotalClients = x.Count(), 133 OnlineClients = x.Count(y => y.SlaveState != DA.SlaveState.Offline), 89 134 TotalCores = x.Sum(y => y.TotalCores), 90 135 UsedCores = x.Sum(y => y.UsedCores), 91 136 TotalMemory = x.Sum(y => y.TotalMemory), 92 137 UsedMemory = x.Sum(y => y.UsedMemory), 93 CpuUtilization = x. Average(y => y.CpuUtilization)138 CpuUtilization = x.Where(y => y.SlaveState != DA.SlaveState.Offline).Average(y => (double?)y.CpuUtilization) ?? 0.0 94 139 }); 95 140 var query = dimClientDao.GetAll() … … 108 153 Id = group.Id, 109 154 Name = group.Name, 110 Clients = info.Count, 155 TotalClients = info.TotalClients, 156 OnlineClients = info.OnlineClients, 111 157 TotalCores = info.TotalCores, 112 158 UsedCores = info.UsedCores,
Note: See TracChangeset
for help on using the changeset viewer.