Changeset 12563 for stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi
- Timestamp:
- 07/01/15 14:59:47 (9 years ago)
- Location:
- stable
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12146,12428-12430,12435,12442-12443,12445,12457,12514,12517,12519-12521,12523,12532,12542,12546,12552-12553,12556-12557,12559,12561 -
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataController.cs
r12428 r12563 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Generic; 24 using System.Data.Linq; 3 25 using System.Linq; 4 26 using System.Web.Http; … … 25 47 FROM UserTasks ut;"; 26 48 27 28 49 private class UserTaskStatus { 29 50 public Guid UserId { get; set; } … … 41 62 CalculatingTasks = uts.CalculatingTasks, 42 63 WaitingTasks = uts.WaitingTasks 43 }) ;64 }).OrderBy(x => x.User.Name); 44 65 } 45 66 // end temporary quickfix … … 50 71 where slave.SlaveState == SlaveState.Calculating || slave.SlaveState == SlaveState.Idle 51 72 select slave).ToList(); 73 var activeSlaves = onlineSlaves.Where(s => s.IsAllowedToCalculate).ToList(); 74 var calculatingSlaves = activeSlaves.Where(s => s.SlaveState == SlaveState.Calculating).ToList(); 75 int calculatingMemory = calculatingSlaves.Any() ? (int)calculatingSlaves.Sum(s => s.Memory) : 0; 76 int freeCalculatingMemory = calculatingSlaves.Any() ? (int)calculatingSlaves.Sum(s => s.FreeMemory) : 0; 77 52 78 return new DTO.Status { 53 79 CoreStatus = new DTO.CoreStatus { 54 80 TotalCores = onlineSlaves.Sum(s => s.Cores ?? 0), 55 AvailableCores = onlineSlaves.Where(s => s.IsAllowedToCalculate).Sum(s => s.Cores ?? 0), 56 FreeCores = onlineSlaves.Sum(s => s.FreeCores ?? 0) 81 FreeCores = onlineSlaves.Sum(s => s.FreeCores ?? 0), // temporary for old chart data 82 ActiveCores = activeSlaves.Sum(s => s.Cores ?? 0), 83 CalculatingCores = calculatingSlaves.Sum(s => s.Cores ?? 0) - calculatingSlaves.Sum(s => s.FreeCores ?? 0) 57 84 }, 58 85 CpuUtilizationStatus = new DTO.CpuUtilizationStatus { … … 60 87 ? Math.Round(onlineSlaves.Average(s => s.CpuUtilization), 2) 61 88 : 0.0, 62 UsedCpuUtilization = onlineSlaves.Any(x => x.IsAllowedToCalculate) 63 ? Math.Round(onlineSlaves.Where(x => x.IsAllowedToCalculate).Average(s => s.CpuUtilization), 2) 64 : 0.0 89 ActiveCpuUtilization = activeSlaves.Any() 90 ? Math.Round(activeSlaves.Average(s => s.CpuUtilization), 2) 91 : 0.0, 92 CalculatingCpuUtilization = calculatingSlaves.Any() 93 ? Math.Round(calculatingSlaves.Average(s => s.CpuUtilization), 2) 94 : 0.0 65 95 }, 66 96 MemoryStatus = new DTO.MemoryStatus { 67 TotalMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.Memory) / 1024 : 0, 68 FreeMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.FreeMemory) / 1024 : 0 97 TotalMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.Memory) : 0, 98 FreeMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.FreeMemory) : 0, 99 ActiveMemory = activeSlaves.Any() ? (int)activeSlaves.Sum(s => s.Memory) : 0, 100 UsedMemory = calculatingMemory - freeCalculatingMemory 69 101 }, 70 102 TasksStatus = GetTaskStatus(db), 71 SlavesCpuStatus = onlineSlaves.Select(x => new DTO.SlaveCpuStatus { 72 CpuUtilization = Math.Round(x.CpuUtilization, 2), 103 SlavesStatus = onlineSlaves.Select(x => new DTO.SlaveStatus { 73 104 Slave = new DTO.Slave { 74 105 Id = x.ResourceId.ToString(), 75 106 Name = x.Name 76 } 77 }), 107 }, 108 CpuUtilization = x.CpuUtilization, 109 Cores = x.Cores ?? 0, 110 FreeCores = x.FreeCores ?? 0, 111 Memory = x.Memory ?? 0, 112 FreeMemory = x.FreeMemory ?? 0, 113 IsAllowedToCalculate = x.IsAllowedToCalculate, 114 State = x.SlaveState.ToString() 115 }).OrderBy(x => x.Slave.Name), 78 116 Timestamp = JavascriptUtils.ToTimestamp(DateTime.Now) 79 117 }; … … 82 120 83 121 public IEnumerable<DTO.Status> GetStatusHistory(DateTime start, DateTime end) { 122 TimeSpan ts = end - start; 123 int increment = 1; 124 double totalMinutes = ts.TotalMinutes; 125 while (totalMinutes > 5761) { 126 totalMinutes -= 5761; 127 increment += 5; 128 } 84 129 using (var db = new HiveDataContext()) { 130 DataLoadOptions loadOptions = new DataLoadOptions(); 131 loadOptions.LoadWith<Statistics>(o => o.SlaveStatistics); 132 db.LoadOptions = loadOptions; 133 db.DeferredLoadingEnabled = false; 85 134 var statistics = db.Statistics.Where(s => s.Timestamp >= start && s.Timestamp <= end) 86 .OrderBy( x => x.Timestamp)135 .OrderBy(s => s.Timestamp) 87 136 .ToList(); 137 var status = new DTO.Status { 138 CoreStatus = new DTO.CoreStatus(), 139 CpuUtilizationStatus = new DTO.CpuUtilizationStatus(), 140 MemoryStatus = new DTO.MemoryStatus() 141 }; 142 int freeCores = 0; 143 int freeMemory = 0; 144 int i = 1; 88 145 foreach (var statistic in statistics) { 89 yield return new DTO.Status { 90 CoreStatus = new DTO.CoreStatus { 91 TotalCores = statistic.SlaveStatistics.Sum(x => x.Cores), 92 AvailableCores = 0, 93 FreeCores = statistic.SlaveStatistics.Sum(x => x.FreeCores) 94 }, 95 CpuUtilizationStatus = new DTO.CpuUtilizationStatus { 96 TotalCpuUtilization = 0.0, 97 UsedCpuUtilization = statistic.SlaveStatistics.Any() ? statistic.SlaveStatistics.Average(x => x.CpuUtilization) : 0.0 98 }, 99 MemoryStatus = new DTO.MemoryStatus { 100 TotalMemory = statistic.SlaveStatistics.Sum(x => x.Memory) / 1024, 101 FreeMemory = statistic.SlaveStatistics.Sum(x => x.FreeMemory) / 1024 102 }, 103 Timestamp = JavascriptUtils.ToTimestamp(statistic.Timestamp) 104 }; 146 status.CoreStatus.TotalCores += statistic.SlaveStatistics.Sum(x => x.Cores); 147 freeCores += statistic.SlaveStatistics.Sum(x => x.FreeCores); 148 status.CpuUtilizationStatus.TotalCpuUtilization += statistic.SlaveStatistics.Any() 149 ? statistic.SlaveStatistics.Average(x => x.CpuUtilization) 150 : 0.0; 151 status.MemoryStatus.TotalMemory += statistic.SlaveStatistics.Sum(x => x.Memory); 152 freeMemory += statistic.SlaveStatistics.Sum(x => x.FreeMemory); 153 if (i >= increment) { 154 status.Timestamp = JavascriptUtils.ToTimestamp(statistic.Timestamp); 155 status.CoreStatus.TotalCores /= i; 156 freeCores /= i; 157 status.CpuUtilizationStatus.TotalCpuUtilization /= i; 158 status.MemoryStatus.TotalMemory /= i; 159 freeMemory /= i; 160 status.CoreStatus.ActiveCores = status.CoreStatus.TotalCores; 161 status.MemoryStatus.ActiveMemory = status.MemoryStatus.TotalMemory; 162 status.CpuUtilizationStatus.ActiveCpuUtilization = status.CpuUtilizationStatus.TotalCpuUtilization; 163 status.CpuUtilizationStatus.CalculatingCpuUtilization = status.CpuUtilizationStatus.CalculatingCpuUtilization; 164 status.CoreStatus.CalculatingCores = status.CoreStatus.TotalCores - freeCores; 165 status.MemoryStatus.UsedMemory = status.MemoryStatus.TotalMemory - freeMemory; 166 yield return status; 167 status = new DTO.Status { 168 CoreStatus = new DTO.CoreStatus(), 169 CpuUtilizationStatus = new DTO.CpuUtilizationStatus(), 170 MemoryStatus = new DTO.MemoryStatus() 171 }; 172 freeCores = 0; 173 freeMemory = 0; 174 i = 1; 175 } else { 176 i++; 177 } 105 178 } 106 179 } -
stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataTransfer/Slave.cs
r12428 r12563 1 namespace HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer { 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 namespace HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer { 2 23 public class Slave { 3 24 public string Id { get; set; } // currently unused -
stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataTransfer/Status.cs
r12428 r12563 1 using System.Collections.Generic; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System.Collections.Generic; 2 23 3 24 namespace HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer { … … 5 26 public class CoreStatus { 6 27 public int TotalCores { get; set; } 7 public int AvailableCores { get; set; } 8 public int FreeCores { get; set; } 28 public int FreeCores { get; set; } // temporary quickfix for old chart data 29 public int ActiveCores { get; set; } 30 public int CalculatingCores { get; set; } 9 31 } 10 32 11 33 public class CpuUtilizationStatus { 12 34 public double TotalCpuUtilization { get; set; } 13 public double UsedCpuUtilization { get; set; } 35 public double ActiveCpuUtilization { get; set; } 36 public double CalculatingCpuUtilization { get; set; } 14 37 } 15 38 16 39 public class MemoryStatus { 17 40 public int TotalMemory { get; set; } 18 public int FreeMemory { get; set; } 41 public int FreeMemory { get; set; } // temporary quickfix for old chart data 42 public int ActiveMemory { get; set; } 43 public int UsedMemory { get; set; } 19 44 } 20 45 … … 25 50 } 26 51 27 public class Slave CpuStatus {52 public class SlaveStatus { 28 53 public Slave Slave { get; set; } 29 54 public double CpuUtilization { get; set; } 55 public int Cores { get; set; } 56 public int FreeCores { get; set; } 57 public int Memory { get; set; } 58 public int FreeMemory { get; set; } 59 public bool IsAllowedToCalculate { get; set; } 60 public string State { get; set; } 30 61 } 31 62 … … 35 66 public MemoryStatus MemoryStatus { get; set; } 36 67 public IEnumerable<TaskStatus> TasksStatus { get; set; } 37 public IEnumerable<Slave CpuStatus> SlavesCpuStatus { get; set; }68 public IEnumerable<SlaveStatus> SlavesStatus { get; set; } 38 69 public long Timestamp { get; set; } 39 70 } -
stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataTransfer/User.cs
r12428 r12563 1 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 2 22 namespace HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer { 3 23 public class User { -
stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi/JavascriptUtils.cs
r12428 r12563 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 3 24 namespace HeuristicLab.Services.WebApp.Status.WebApi { … … 6 27 var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); 7 28 var time = input.Subtract(new TimeSpan(epoch.Ticks)); 8 return (long)(time.Ticks / 10000);29 return time.Ticks / 10000; 9 30 } 10 31 }
Note: See TracChangeset
for help on using the changeset viewer.