Changeset 12525 for branches/HiveStatistics
- Timestamp:
- 06/26/15 18:02:03 (10 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 10 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/HeuristicLab.Services.WebApp.Statistics-3.3.csproj
r12516 r12525 146 146 <Compile Include="WebApi\DataTransfer\ClientPage.cs" /> 147 147 <Compile Include="WebApi\DataTransfer\ClientStatus.cs" /> 148 <Compile Include="WebApi\DataTransfer\Group.cs" /> 149 <Compile Include="WebApi\DataTransfer\GroupDetails.cs" /> 150 <Compile Include="WebApi\DataTransfer\GroupPage.cs" /> 148 151 <Compile Include="WebApi\DataTransfer\Integer.cs" /> 149 152 <Compile Include="WebApi\DataTransfer\Job.cs" /> … … 154 157 <Compile Include="WebApi\DataTransfer\TaskStateCount.cs" /> 155 158 <Compile Include="WebApi\DataTransfer\User.cs" /> 159 <Compile Include="WebApi\GroupController.cs" /> 156 160 <Compile Include="WebApi\JavascriptUtils.cs" /> 157 161 <Compile Include="WebApi\JobController.cs" /> … … 172 176 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 173 177 </Content> 178 <Content Include="WebApp\groups\details\groupDetailsCtrl.js"> 179 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 180 </Content> 181 <Content Include="WebApp\groups\groupsCtrl.js"> 182 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 183 </Content> 174 184 <Content Include="WebApp\jobs\details\jobDetailsCtrl.js"> 175 185 <CopyToOutputDirectory>Always</CopyToOutputDirectory> … … 182 192 </Content> 183 193 <Content Include="WebApp\services\clientService.js"> 194 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 195 </Content> 196 <Content Include="WebApp\services\groupService.js"> 184 197 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 185 198 </Content> … … 224 237 </None> 225 238 <None Include="WebApp\clients\details\clientTaskDetailsDialog.cshtml"> 239 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 240 </None> 241 <Content Include="WebApp\groups\groups.cshtml"> 242 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 243 </Content> 244 <None Include="WebApp\groups\details\groupDetails.cshtml"> 226 245 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 227 246 </None> -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/ClientController.cs
r12516 r12525 86 86 State = clientInfo.SlaveState.ToString(), 87 87 LastUpdate = clientInfo.Time, 88 GroupId = client.ResourceGroupId, 89 GroupName = client.GroupName, 88 90 UpTime = offline ? 0 : upTime, 89 91 TotalUnavailableTime = timeData != null ? timeData.TotalUnavailableTime : 0, … … 124 126 CpuUtilization = offline ? 0 : clientInfo.CpuUtilization, 125 127 State = clientInfo.SlaveState.ToString(), 128 GroupId = client.ResourceGroupId, 129 GroupName = client.GroupName 126 130 }); 127 131 return new DT.ClientPage { … … 186 190 } 187 191 192 public DT.ClientPage GetClientsByGroupId(Guid id, int page, int size, bool expired = false) { 193 using (var pm = PersistenceManager) { 194 var dimClientDao = pm.DimClientDao; 195 var factClientInfoDao = pm.FactClientInfoDao; 196 return pm.UseTransaction(() => { 197 var clients = expired ? dimClientDao.GetExpiredClients() : dimClientDao.GetActiveClients(); 198 clients = clients.Where(x => x.ResourceGroupId == id); 199 var query = (from client in clients 200 join info in factClientInfoDao.GetAll() 201 on client.Id equals info.ClientId into clientInfoJoin 202 from clientInfo in clientInfoJoin.OrderByDescending(x => x.Time).Take(1) 203 let offline = (expired || clientInfo.SlaveState == SlaveState.Offline) 204 select new DT.Client { 205 Id = client.Id, 206 Name = client.Name, 207 TotalCores = clientInfo.NumTotalCores, 208 UsedCores = offline ? 0 : clientInfo.NumUsedCores, 209 TotalMemory = clientInfo.TotalMemory, 210 UsedMemory = offline ? 0 : clientInfo.UsedMemory, 211 CpuUtilization = offline ? 0 : clientInfo.CpuUtilization, 212 State = clientInfo.SlaveState.ToString(), 213 GroupId = client.ResourceGroupId, 214 GroupName = client.GroupName 215 }); 216 return new DT.ClientPage { 217 TotalClients = query.Count(), 218 Clients = query.Skip((page - 1) * size) 219 .Take(size) 220 .ToList() 221 }; 222 }); 223 } 224 } 225 226 public IEnumerable<DT.ClientStatus> GetClientHistoryByGroupId(Guid id, DateTime start, DateTime end) { 227 TimeSpan ts = end - start; 228 int increment = 1; 229 double totalMinutes = ts.TotalMinutes; 230 while (totalMinutes > 5761) { 231 totalMinutes -= 5761; 232 increment += 5; 233 } 234 using (var pm = PersistenceManager) { 235 var factClientInfo = pm.FactClientInfoDao; 236 var dimClientDao = pm.DimClientDao; 237 var clientInfos = factClientInfo.GetAll() 238 .Where(x => x.Time >= start && x.Time <= end) 239 .OrderBy(x => x.Time) 240 .Join(dimClientDao.GetAll(), 241 fact => fact.ClientId, 242 client => client.Id, 243 (fact, client) => new { 244 client.ResourceGroupId, 245 fact.Time, 246 fact.CpuUtilization, 247 fact.NumTotalCores, 248 fact.NumUsedCores, 249 fact.TotalMemory, 250 fact.UsedMemory 251 }) 252 .Where(x => x.ResourceGroupId == id) 253 .ToList(); 254 var clientStatus = new DT.ClientStatus { 255 CpuUtilization = 0, 256 TotalCores = 0, 257 UsedCores = 0, 258 TotalMemory = 0, 259 UsedMemory = 0 260 }; 261 int i = 1; 262 foreach (var clientInfo in clientInfos) { 263 clientStatus.CpuUtilization += clientInfo.CpuUtilization; 264 clientStatus.TotalCores += clientInfo.NumTotalCores; 265 clientStatus.UsedCores += clientInfo.NumUsedCores; 266 clientStatus.TotalMemory += clientInfo.TotalMemory; 267 clientStatus.UsedMemory += clientInfo.UsedMemory; 268 if (i >= increment) { 269 clientStatus.Timestamp = JavascriptUtils.ToTimestamp(clientInfo.Time); 270 clientStatus.CpuUtilization /= i; 271 clientStatus.TotalCores /= i; 272 clientStatus.UsedCores /= i; 273 clientStatus.TotalMemory /= i; 274 clientStatus.UsedMemory /= i; 275 yield return clientStatus; 276 clientStatus = new DT.ClientStatus { 277 CpuUtilization = 0, 278 TotalCores = 0, 279 UsedCores = 0, 280 TotalMemory = 0, 281 UsedMemory = 0 282 }; 283 i = 1; 284 } else { 285 ++i; 286 } 287 } 288 } 289 } 188 290 } 189 291 } -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/DataTransfer/Client.cs
r12516 r12525 33 33 public string State { get; set; } 34 34 public DateTime LastUpdate { get; set; } 35 public Guid? GroupId { get; set; } 36 public string GroupName { get; set; } 35 37 } 36 38 } -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/DataTransfer/ClientDetails.cs
r12516 r12525 34 34 public string State { get; set; } 35 35 public DateTime LastUpdate { get; set; } 36 public Guid? GroupId { get; set; } 37 public string GroupName { get; set; } 36 38 public long UpTime { get; set; } 37 39 public long TotalUnavailableTime { get; set; } -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/JobController.cs
r12516 r12525 135 135 } 136 136 137 [Authorize(Roles = HiveRoles.Administrator)] 138 public IEnumerable<DT.Job> GetAllActiveJobsFromAllUsers() { 139 using (var pm = PersistenceManager) { 140 var dimJobDao = pm.DimJobDao; 141 return pm.UseTransaction(() => { 142 return dimJobDao.GetAll() 143 .Where(x => x.DateCompleted == null) 144 .OrderByDescending(x => x.DateCreated) 145 .Select(x => ConvertToDT(x)) 146 .ToList(); 147 }); 148 } 149 } 150 137 151 private DT.Job ConvertToDT(DA.DimJob job) { 138 152 return new DT.Job { -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/TaskController.cs
r12516 r12525 143 143 Exception = isAdministrator ? factTask.Exception : string.Empty 144 144 }) 145 .OrderByDescending(x => x.EndTime )145 .OrderByDescending(x => x.EndTime ?? DateTime.MaxValue) 146 146 .Skip((page - 1) * size) 147 147 .Take(size) -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/clients/clients.cshtml
r12516 r12525 14 14 <li class="active"> 15 15 <a ng-href="#/statistics/clients">Clients</a> 16 </li> 17 <li> 18 <a ng-href="#/statistics/groups">Groups</a> 16 19 </li> 17 20 </ul> … … 31 34 <th>#</th> 32 35 <th>Client Name</th> 36 <th>Group Name</th> 33 37 <th>Cores</th> 34 38 <th>Cpu Utilization</th> … … 40 44 <td>{{($index + 1)+((curClientsPage-1)*(clientsPageSize))}}</td> 41 45 <td>{{client.Name}}</td> 46 <td> 47 <a ng-show="client.GroupName" ng-href="#/statistics/groups/{{client.GroupId}}">{{client.GroupName}}</a> 48 <span ng-hide="client.GroupName">No Group</span> 49 </td> 42 50 <td>{{client.UsedCores}} / {{client.TotalCores}}</td> 43 51 <td>{{client.CpuUtilization | number: 2}} %</td> -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/clients/details/clientDetails.cshtml
r12516 r12525 14 14 <a ng-href="#/statistics/clients">Clients</a> 15 15 </li> 16 <li> 17 <a ng-href="#/statistics/groups">Groups</a> 18 </li> 16 19 </ul> 17 20 </header> … … 34 37 <tr> 35 38 <td class="text-left">Group:</td> 36 <td ng-show="client.GroupName"> {{client.GroupName}}</td>39 <td ng-show="client.GroupName"><a ng-href="#/statistics/groups/{{client.GroupId}}">{{client.GroupName}}</a></td> 37 40 <td ng-hide="client.GroupName">None</td> 38 41 </tr> … … 253 256 <div class="default-filter-header text-center"> 254 257 <form class="form-inline"> 255 <div class="form-group" >258 <div class="form-group" style="margin-left: 5px; margin-right: 5px;"> 256 259 <label for="fromDate">From: </label> 257 260 <div class="input-group"> … … 262 265 </div> 263 266 </div> 264 <div class="form-group" >265 <label for="fromDate"> To: </label>267 <div class="form-group" style="margin-left: 5px; margin-right: 5px;"> 268 <label for="fromDate">To: </label> 266 269 <div class="input-group"> 267 <input id="fromDate" type="text" class="form-control" datepicker-popup="dd.MM.yyyy" ng-model="toDate" is-open="toIsOpen" datepicker-options="dateOptions" ng-required="true" close-text="Close" />270 <input id="fromDate" type="text" class="form-control" datepicker-popup="dd.MM.yyyy" ng-model="toDate" is-open="toIsOpen" datepicker-options="dateOptions" ng-required="true" close-text="Close" /> 268 271 <span class="input-group-btn"> 269 272 <button type="button" class="btn btn-default" ng-click="openToDateSelection($event)"><i class="glyphicon glyphicon-calendar"></i></button> … … 271 274 </div> 272 275 </div> 273 <div class=" btn-group">274 < labelclass="btn btn-default" ng-click="updateCharts()">276 <div class="form-group" style="margin-left: 5px; margin-right: 5px;"> 277 <button type="button" class="btn btn-default" ng-click="updateCharts()"> 275 278 Apply 276 </ label>279 </button> 277 280 </div> 278 281 </form> -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/jobs/details/jobDetails.cshtml
r12516 r12525 13 13 <li> 14 14 <a ng-href="#/statistics/clients">Clients</a> 15 </li> 16 <li> 17 <a ng-href="#/statistics/groups">Groups</a> 15 18 </li> 16 19 </ul> … … 97 100 <div class="col-md-2"></div> 98 101 </div> 99 </div>102 </div> 100 103 101 104 </div> -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/jobs/details/jobDetailsCtrl.js
r12516 r12525 14 14 if (isDefined($scope.job.DateCompleted)) { 15 15 $scope.job.DateCompleted = CSharpDateToString($scope.job.DateCompleted); 16 } else { 17 $scope.job.DateCompleted = 'Not completed yet'; 16 18 } 17 19 $scope.job.CalculatingWaitingRatio = ($scope.job.TotalCalculatingTime / $scope.job.TotalWaitingTime); -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/jobs/jobs.cshtml
r12516 r12525 13 13 <li> 14 14 <a ng-href="#/statistics/clients">Clients</a> 15 </li> 16 <li> 17 <a ng-href="#/statistics/groups">Groups</a> 15 18 </li> 16 19 </ul> … … 54 57 </div> 55 58 </div> 56 59 @if (Request.IsAuthenticated && User.IsInRole(HiveRoles.Administrator)) { 60 <div class="row"> 61 <div class="col-lg-12"> 62 <div class="panel panel-default"> 63 <div class="panel-heading"> 64 <h3 class="panel-title">Current Active Jobs</h3> 65 </div> 66 <div class="panel-body"> 67 <table class="table table-hover table-condensed"> 68 <thead> 69 <tr> 70 <th>#</th> 71 <th>Job Name</th> 72 <th>User Name</th> 73 <th>Date Created</th> 74 <th>Progress</th> 75 <th></th> 76 </tr> 77 </thead> 78 <tr ng-repeat="job in allUsersJobs"> 79 <td>{{$index + 1}}</td> 80 <td>{{job.Name}}</td> 81 <td> 82 <a ng-href="#/statistics/users/{{job.UserId}}" ng-show="job.UserName">{{job.UserName}}</a> 83 </td> 84 <td>{{job.DateCreated}}</td> 85 <td> 86 <progressbar class="progress active" max="job.TotalTasks" value="job.CompletedTasks" type="success"><i style="color:black; white-space:nowrap;">{{job.CompletedTasks}} / {{job.TotalTasks}}</i></progressbar> 87 </td> 88 <td> 89 <a ng-href="#/statistics/jobs/{{job.Id}}">Details</a> 90 </td> 91 </tr> 92 <tr ng-hide="allUsersJobs.length"> 93 <td colspan="6" class="text-center">No active jobs found!</td> 94 </tr> 95 </table> 96 </div> 97 </div> 98 </div> 99 </div> 100 } 57 101 <div class="row"> 58 102 <div class="col-lg-12"> -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/jobs/jobsCtrl.js
r12516 r12525 3 3 module.controller('app.statistics.jobsCtrl', 4 4 ['$scope', '$interval', 'app.statistics.jobService', function ($scope, $interval, jobService) { 5 var first = true; 6 $scope.isAdministrator = false; 5 7 $scope.interval = defaultPageUpdateInterval; 6 8 $scope.completedJobCurPage = 1; … … 30 32 }; 31 33 34 var getAllActiveJobsFromAllUsers = function () { 35 jobService.getAllActiveJobsFromAllUsers({}, function (jobs) { 36 $scope.isAdministrator = true; 37 $scope.allUsersJobs = jobs; 38 var length = $scope.allUsersJobs.length; 39 for (var i = 0; i < length; ++i) { 40 $scope.allUsersJobs[i].DateCreated = CSharpDateToString($scope.allUsersJobs[i].DateCreated); 41 } 42 }); 43 }; 44 32 45 $scope.changeCompletedJobPage = function () { 33 46 update(); … … 36 49 var update = function () { 37 50 getAllJobs(); 51 if (first || $scope.isAdministrator) { 52 getAllActiveJobsFromAllUsers(); 53 } 38 54 getCompletedJobs(); 39 55 }; 56 40 57 41 58 $scope.updateInterval = $interval(update, $scope.interval); … … 45 62 }); 46 63 update(); // init page 64 first = false; 47 65 }] 48 66 ); -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/services/clientService.js
r12516 r12525 7 7 getClientDetails: { method: 'GET', params: { action: 'GetClientDetails' } }, 8 8 getClients: { method: 'GET', params: { action: 'GetClients' } }, 9 getClientHistory: { method: 'GET', params: { action: 'GetClientHistory' }, isArray: true } 9 getClientsByGroupId: { method: 'GET', params: { action: 'GetClientsByGroupId' } }, 10 getClientHistory: { method: 'GET', params: { action: 'GetClientHistory' }, isArray: true }, 11 getClientHistoryByGroupId: { method: 'GET', params: { action: 'GetClientHistoryByGroupId' }, isArray: true } 10 12 }); 11 13 }] -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/services/jobService.js
r12516 r12525 10 10 getJobsByUserId: { method: 'GET', params: { action: 'GetJobsByUserId' } }, 11 11 getAllJobsByUserId: { method: 'GET', params: { action: 'GetAllJobsByUserId'}, isArray: true }, 12 getJobTasksStatesByJobId: { method: 'GET', params: { action: 'GetJobTasksStatesByJobId' }, isArray: true } 12 getJobTasksStatesByJobId: { method: 'GET', params: { action: 'GetJobTasksStatesByJobId' }, isArray: true }, 13 getAllActiveJobsFromAllUsers: { method: 'GET', params: { action: 'GetAllActiveJobsFromAllUsers' }, isArray: true } 13 14 }); 14 15 }] -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/users/details/userDetails.cshtml
r12516 r12525 12 12 <li> 13 13 <a ng-href="#/statistics/clients">Clients</a> 14 </li> 15 <li> 16 <a ng-href="#/statistics/groups">Groups</a> 14 17 </li> 15 18 </ul> -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/users/users.cshtml
r12516 r12525 12 12 <li> 13 13 <a ng-href="#/statistics/clients">Clients</a> 14 </li> 15 <li> 16 <a ng-href="#/statistics/groups">Groups</a> 14 17 </li> 15 18 </ul> -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/statistics.js
r12516 r12525 10 10 'WebApp/services/userService.js', 11 11 'WebApp/services/clientService.js', 12 'WebApp/services/groupService.js', 12 13 'WebApp/jobs/jobsCtrl.js', 13 14 'WebApp/jobs/details/jobDetailsCtrl.js', … … 17 18 'WebApp/clients/details/clientTaskDetailsDialogCtrl.js', 18 19 'WebApp/users/usersCtrl.js', 19 'WebApp/users/details/userDetailsCtrl.js' 20 'WebApp/users/details/userDetailsCtrl.js', 21 'WebApp/groups/groupsCtrl.js', 22 'WebApp/groups/details/groupDetailsCtrl.js' 20 23 ]; 21 24 plugin.view = 'WebApp/jobs/jobs.cshtml'; … … 27 30 new Route('clients/:id', 'WebApp/clients/details/clientDetails.cshtml', 'app.statistics.clientDetailsCtrl'), 28 31 new Route('users', 'WebApp/users/users.cshtml', 'app.statistics.usersCtrl'), 29 new Route('users/:id', 'WebApp/users/details/userDetails.cshtml', 'app.statistics.userDetailsCtrl') 32 new Route('users/:id', 'WebApp/users/details/userDetails.cshtml', 'app.statistics.userDetailsCtrl'), 33 new Route('groups', 'WebApp/groups/groups.cshtml', 'app.statistics.groupsCtrl'), 34 new Route('groups/:id', 'WebApp/groups/details/groupDetails.cshtml', 'app.statistics.groupDetailsCtrl') 30 35 ]; 31 36 var menu = app.getMenu(); … … 33 38 section.addEntry({ 34 39 name: 'Statistics', 35 route: '#/statistics /jobs',40 route: '#/statistics', 36 41 icon: 'glyphicon glyphicon-stats', 37 42 entries: [] -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataController.cs
r12515 r12525 27 27 using HeuristicLab.Services.Hive; 28 28 using HeuristicLab.Services.Hive.DataAccess; 29 using HeuristicLab.Services.Hive.DataAccess.Interfaces; 30 using DA = HeuristicLab.Services.Hive.DataAccess; 31 using DT = HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer; 29 using DAL = HeuristicLab.Services.Hive.DataAccess; 30 using DTO = HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer; 32 31 33 32 namespace HeuristicLab.Services.WebApp.Status.WebApi { 34 33 public class DataController : ApiController { 35 private IPersistenceManager PersistenceManager {36 get { return ServiceLocator.Instance.PersistenceManager; }37 }38 34 39 35 // start temporary quickfix … … 57 53 } 58 54 59 public IEnumerable<DT .TaskStatus> GetTaskStatus(HiveDataContext db) {55 public IEnumerable<DTO.TaskStatus> GetTaskStatus(HiveDataContext db) { 60 56 var query = db.ExecuteQuery<UserTaskStatus>(SQL_USER_TASK_STATUS).ToList(); 61 return query.Select(uts => new DT .TaskStatus {62 User = new DT .User {57 return query.Select(uts => new DTO.TaskStatus { 58 User = new DTO.User { 63 59 Id = uts.UserId.ToString(), 64 60 Name = ServiceLocator.Instance.UserManager.GetUserById(uts.UserId).UserName … … 70 66 // end temporary quickfix 71 67 72 public DT.Status GetStatus() { 73 DT.TimeStatus timeStatus = null; 74 using (var pm = PersistenceManager) { 75 76 // TODO: 77 // new DT.TimeStatus { 78 // AvgCalculatingTime = 0, 79 // AvgWaitingTime = 0, 80 // MaxCalculatingTime = 0, 81 // MinCalculatingTime = 0, 82 // TotalCpuTime = 0, 83 // BeginDate = DateTime.Now 84 //} 85 } 86 68 public DTO.Status GetStatus() { 87 69 using (var db = new HiveDataContext()) { 88 var onlineSlaves = (from slave in db.Resources.OfType<DA .Slave>()70 var onlineSlaves = (from slave in db.Resources.OfType<DAL.Slave>() 89 71 where slave.SlaveState == SlaveState.Calculating || slave.SlaveState == SlaveState.Idle 90 72 select slave).ToList(); 91 73 var activeSlaves = onlineSlaves.Where(s => s.IsAllowedToCalculate).ToList(); 92 74 var calculatingSlaves = activeSlaves.Where(s => s.SlaveState == SlaveState.Calculating).ToList(); 93 int calculatingMemory = calculatingSlaves.Any() ? (int)calculatingSlaves.Sum(s => s.Memory) / 1024: 0;94 int freeCalculatingMemory = calculatingSlaves.Any() ? (int)calculatingSlaves.Sum(s => s.FreeMemory) / 1024: 0;75 int calculatingMemory = calculatingSlaves.Any() ? (int)calculatingSlaves.Sum(s => s.Memory) : 0; 76 int freeCalculatingMemory = calculatingSlaves.Any() ? (int)calculatingSlaves.Sum(s => s.FreeMemory) : 0; 95 77 96 return new DT .Status {97 CoreStatus = new DT .CoreStatus {78 return new DTO.Status { 79 CoreStatus = new DTO.CoreStatus { 98 80 TotalCores = onlineSlaves.Sum(s => s.Cores ?? 0), 99 81 FreeCores = onlineSlaves.Sum(s => s.FreeCores ?? 0), // temporary for old chart data … … 101 83 CalculatingCores = calculatingSlaves.Sum(s => s.Cores ?? 0) - calculatingSlaves.Sum(s => s.FreeCores ?? 0) 102 84 }, 103 CpuUtilizationStatus = new DT .CpuUtilizationStatus {85 CpuUtilizationStatus = new DTO.CpuUtilizationStatus { 104 86 TotalCpuUtilization = onlineSlaves.Any() 105 87 ? Math.Round(onlineSlaves.Average(s => s.CpuUtilization), 2) … … 112 94 : 0.0 113 95 }, 114 MemoryStatus = new DT .MemoryStatus {115 TotalMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.Memory) / 1024: 0,116 FreeMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.FreeMemory) / 1024: 0,117 ActiveMemory = activeSlaves.Any() ? (int)activeSlaves.Sum(s => s.Memory) / 1024: 0,96 MemoryStatus = new DTO.MemoryStatus { 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, 118 100 UsedMemory = calculatingMemory - freeCalculatingMemory 119 101 }, 120 TimeStatus = timeStatus,121 102 TasksStatus = GetTaskStatus(db), 122 SlavesStatus = onlineSlaves.Select(x => new DT .SlaveStatus {123 Slave = new DT .Slave {103 SlavesStatus = onlineSlaves.Select(x => new DTO.SlaveStatus { 104 Slave = new DTO.Slave { 124 105 Id = x.ResourceId.ToString(), 125 106 Name = x.Name … … 128 109 Cores = x.Cores ?? 0, 129 110 FreeCores = x.FreeCores ?? 0, 130 Memory = (x.Memory ?? 0) / 1024,131 FreeMemory = (x.FreeMemory ?? 0) / 1024,111 Memory = x.Memory ?? 0, 112 FreeMemory = x.FreeMemory ?? 0, 132 113 IsAllowedToCalculate = x.IsAllowedToCalculate, 133 114 State = x.SlaveState.ToString() … … 138 119 } 139 120 140 public IEnumerable<DT .Status> GetStatusHistory(DateTime start, DateTime end) {121 public IEnumerable<DTO.Status> GetStatusHistory(DateTime start, DateTime end) { 141 122 TimeSpan ts = end - start; 142 123 int increment = 1; … … 154 135 .OrderBy(s => s.Timestamp) 155 136 .ToList(); 156 var status = new DT .Status {157 CoreStatus = new DT .CoreStatus(),158 CpuUtilizationStatus = new DT .CpuUtilizationStatus(),159 MemoryStatus = new DT .MemoryStatus()137 var status = new DTO.Status { 138 CoreStatus = new DTO.CoreStatus(), 139 CpuUtilizationStatus = new DTO.CpuUtilizationStatus(), 140 MemoryStatus = new DTO.MemoryStatus() 160 141 }; 161 142 int freeCores = 0; … … 168 149 ? statistic.SlaveStatistics.Average(x => x.CpuUtilization) 169 150 : 0.0; 170 status.MemoryStatus.TotalMemory += statistic.SlaveStatistics.Sum(x => x.Memory) / 1024;171 freeMemory += statistic.SlaveStatistics.Sum(x => x.FreeMemory) / 1024;151 status.MemoryStatus.TotalMemory += statistic.SlaveStatistics.Sum(x => x.Memory); 152 freeMemory += statistic.SlaveStatistics.Sum(x => x.FreeMemory); 172 153 if (i >= increment) { 173 154 status.Timestamp = JavascriptUtils.ToTimestamp(statistic.Timestamp); … … 184 165 status.MemoryStatus.UsedMemory = status.MemoryStatus.TotalMemory - freeMemory; 185 166 yield return status; 186 status = new DT .Status {187 CoreStatus = new DT .CoreStatus(),188 CpuUtilizationStatus = new DT .CpuUtilizationStatus(),189 MemoryStatus = new DT .MemoryStatus()167 status = new DTO.Status { 168 CoreStatus = new DTO.CoreStatus(), 169 CpuUtilizationStatus = new DTO.CpuUtilizationStatus(), 170 MemoryStatus = new DTO.MemoryStatus() 190 171 }; 191 172 freeCores = 0; -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp/3.3/Controllers/DataTransfer/Plugin.cs
r12435 r12525 28 28 public DateTime? LastReload { get; set; } 29 29 public int Reloads { get; set; } 30 public string Exception { get; set; } 30 31 } 31 32 } -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp/3.3/Controllers/PluginController.cs
r12515 r12525 38 38 Name = plugin.Name, 39 39 AssemblyName = plugin.AssemblyName, 40 LastReload = plugin.LastReload 40 LastReload = plugin.LastReload, 41 Exception = plugin.Exception 41 42 }); 42 43 } -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp/3.3/HeuristicLab.Services.WebApp-3.3.csproj
r12515 r12525 177 177 </Content> 178 178 <Content Include="WebApp\plugins\login\loginCtrl.js"> 179 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 180 </Content> 181 <Content Include="WebApp\plugins\plugins\pluginsExceptionCtrl.js"> 179 182 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 180 183 </Content> -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp/3.3/Plugin.cs
r12515 r12525 34 34 public string Directory { get; set; } 35 35 public string AssemblyName { get; set; } 36 public string Exception { get; set; } 36 37 public DateTime? LastReload { get; set; } 37 38 … … 66 67 public void ReloadControllers() { 67 68 AssemblyName = null; 69 Exception = null; 68 70 Controllers.Clear(); 69 71 LastReload = DateTime.Now; … … 76 78 return; 77 79 var assemblyPath = assemblies.First(); 80 AssemblyName = Path.GetFileName(assemblyPath); 78 81 var assembly = Assembly.Load(File.ReadAllBytes(assemblyPath)); 79 82 var assemblyTypes = assembly.GetTypes(); … … 83 86 Controllers.Add(controllerName, new HttpControllerDescriptor(configuration, controllerName, apiController)); 84 87 } 85 AssemblyName = Path.GetFileName(assemblyPath);86 88 } 87 catch (Exception ) {88 AssemblyName = "Error loading assembly";89 catch (Exception e) { 90 Exception = e.ToString(); 89 91 Controllers.Clear(); 90 92 } -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp/3.3/WebApp/plugins/plugins/plugins.cshtml
r12428 r12525 1 1 <div class="default-view-container"> 2 <script type="text/ng-template" id="pluginsExceptionDialog"> 3 <div class="modal-header"> 4 <button type="button" ng-click="close()" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> 5 <h4 class="modal-title">Plugin {{pluginName}}</h4> 6 </div> 7 <div class="modal-body"> 8 {{exception}} 9 </div> 10 </script> 2 11 <div class="row"> 3 12 <div class="col-lg-12"> … … 14 23 <th>Assembly</th> 15 24 <th>Last reload</th> 25 <th>Status</th> 16 26 <th></th> 17 27 </tr> … … 22 32 <td>{{plugin.AssemblyName}}</td> 23 33 <td>{{plugin.LastReload}}</td> 34 <td> 35 <span ng-hide="plugin.Exception" class="glyphicon glyphicon glyphicon-ok" style="color: green"></span> 36 <span ng-show="plugin.Exception" class="glyphicon glyphicon glyphicon-remove" style="color: darkred" 37 ng-click="open(plugin.Name, plugin.Exception)"></span> 38 </td> 24 39 <td> 25 40 <a ng-href="" data-ng-click="reloadPlugin(plugin.Name)">Reload</a> -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp/3.3/WebApp/plugins/plugins/plugins.js
r12428 r12525 5 5 plugin.files = [ 6 6 'pluginsService.js', 7 'pluginsCtrl.js' 7 'pluginsCtrl.js', 8 'pluginsExceptionCtrl.js' 8 9 ]; 9 10 plugin.view = 'plugins.cshtml'; -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp/3.3/WebApp/plugins/plugins/pluginsCtrl.js
r12428 r12525 2 2 var module = appPluginsPlugin.getAngularModule(); 3 3 module.controller('app.plugins.ctrl', 4 ['$scope', ' app.plugins.service', function ($scope, pluginService) {4 ['$scope', '$modal', 'app.plugins.service', function ($scope, $modal, pluginService) { 5 5 var getPlugins = function () { 6 6 pluginService.getPlugins({}, function (plugins) { … … 22 22 23 23 $scope.reloadPlugin = function (name) { 24 pluginService.reloadPlugin({ name: name }, function () {24 pluginService.reloadPlugin({ name: name }, function () { 25 25 getPlugins(); 26 }); 27 }; 28 29 $scope.open = function (pluginName, exception) { 30 $scope.pluginName = pluginName; 31 $scope.exception = exception; 32 $modal.open({ 33 animation: true, 34 templateUrl: 'pluginsExceptionDialog', 35 controller: 'app.plugins.pluginsExceptionCtrl', 36 resolve: { 37 pluginName: function () { 38 return $scope.pluginName; 39 }, 40 exception: function () { 41 return $scope.exception; 42 } 43 } 26 44 }); 27 45 };
Note: See TracChangeset
for help on using the changeset viewer.