Changeset 9033
- Timestamp:
- 12/12/12 11:04:23 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.Hive.Web/Hive-3.3/Status.aspx
r9027 r9033 29 29 <asp:Label ID="availableCoresLabel" runat="server" /> 30 30 <br /> 31 <strong>System-Wide Waiting Jobs:</strong> 32 <asp:Label ID="waitingJobsLabel" runat="server" /> 33 <br /> 31 34 <strong>Used Cores / Calculating Jobs:</strong> 32 35 <asp:Label ID="usedCoresLabel" runat="server" /> 33 <br />34 <strong>Waiting Jobs:</strong>35 <asp:Label ID="waitingJobsLabel" runat="server" />36 36 <br /> 37 37 <strong>Overall -
trunk/sources/HeuristicLab.Services.Hive.Web/Hive-3.3/Status.aspx.cs
r9028 r9033 55 55 var resId = dao.GetResources(x => x.Name == resourceName).Single().Id; 56 56 resourceIds = dao.GetChildResources(resId).Select(x => x.Id).Union(new List<Guid> { resId }); 57 calculatingTasksByUser = dao.GetCalculatingTasksByUserForResources(resourceIds.ToList()); 58 waitingTasksByUser = dao.GetWaitingTasksByUserForResources(resourceIds.ToList()); 57 59 }, false, false); 58 60 } else { … … 60 62 { 61 63 resourceIds = dao.GetResources(x => true).Select(y => y.Id); 64 calculatingTasksByUser = dao.GetCalculatingTasksByUser(); 65 waitingTasksByUser = dao.GetWaitingTasksByUser(); 62 66 }, false, false); 63 67 } … … 65 69 transactionManager.UseTransaction(() => 66 70 { 67 onlineSlaves = dao.GetSlaves(x => (x.SlaveState == DA.SlaveState.Calculating || x.SlaveState == DA.SlaveState.Idle) && resourceIds.Contains(x.ResourceId)); 68 currentlyJobsWaiting = dao.GetLightweightTasks(x => x.State == DA.TaskState.Waiting).Count(); 69 calculatingTasksByUser = dao.GetCalculatingTasksByUser(); 70 waitingTasksByUser = dao.GetWaitingTasksByUser(); 71 onlineSlaves = dao.GetSlaves(x => (x.SlaveState == DA.SlaveState.Calculating || x.SlaveState == DA.SlaveState.Idle) && resourceIds.Contains(x.ResourceId)); 72 currentlyJobsWaiting = dao.GetLightweightTasks(x => x.State == DA.TaskState.Waiting).Count(); 71 73 }, false, false); 72 74 … … 116 118 } 117 119 118 foreach (var kvp in waitingTasksByUser) { 120 GenerateTasksByUserTable(waitingTasksByUser, waitingTasksByUserTable); 121 GenerateTasksByUserTable(calculatingTasksByUser, calculatingTasksByUserTable); 122 } 123 124 private void GenerateTasksByUserTable(Dictionary<Guid, int> tasksByUser, Table table) { 125 foreach (var kvp in tasksByUser) { 119 126 TableRow curRow = new TableRow(); 120 127 TableCell cellUser = new TableCell(); … … 125 132 curRow.Cells.Add(cellUser); 126 133 curRow.Cells.Add(cellCnt); 127 waitingTasksByUserTable.Rows.Add(curRow);134 table.Rows.Add(curRow); 128 135 } 129 130 foreach (var kvp in calculatingTasksByUser) { 131 TableRow curRow = new TableRow(); 132 TableCell cellUser = new TableCell(); 133 cellUser.Text = ServiceLocator.Instance.UserManager.GetUserById(kvp.Key).UserName; 134 TableCell cellCnt = new TableCell(); 135 cellCnt.Text = kvp.Value.ToString(); 136 137 curRow.Cells.Add(cellUser); 138 curRow.Cells.Add(cellCnt); 139 calculatingTasksByUserTable.Rows.Add(curRow); 136 if (tasksByUser.Count() > 0) { 137 TableRow sumRow = new TableRow(); 138 TableCell sumCell = new TableCell(); 139 sumCell.BorderWidth = Unit.Pixel(3); 140 sumCell.Text = tasksByUser.Sum(x => x.Value).ToString(); 141 sumRow.Cells.Add(new TableCell()); 142 sumRow.Cells.Add(sumCell); 143 table.Rows.Add(sumRow); 140 144 } 141 } 145 } 142 146 } -
trunk/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs
r9025 r9033 843 843 } 844 844 845 public Dictionary<Guid, int> GetWaitingTasksByUserForResources(List<Guid> resourceIds) { 846 using (var db = CreateContext()) { 847 var waitingTasksByUser = from task in db.Tasks 848 where task.State == TaskState.Waiting && task.AssignedResources.Any(x => resourceIds.Contains(x.ResourceId)) 849 group task by task.Job.OwnerUserId into g 850 select new { UserId = g.Key, UsedCores = g.Count() }; 851 return waitingTasksByUser.ToDictionary(x => x.UserId, x => x.UsedCores); 852 } 853 } 854 845 855 public Dictionary<Guid, int> GetCalculatingTasksByUser() { 846 856 using (var db = CreateContext()) { 847 857 var calculatingTasksByUser = from task in db.Tasks 848 858 where task.State == TaskState.Calculating 859 group task by task.Job.OwnerUserId into g 860 select new { UserId = g.Key, UsedCores = g.Count() }; 861 return calculatingTasksByUser.ToDictionary(x => x.UserId, x => x.UsedCores); 862 } 863 } 864 865 public Dictionary<Guid, int> GetCalculatingTasksByUserForResources(List<Guid> resourceIds) { 866 using (var db = CreateContext()) { 867 var calculatingTasksByUser = from task in db.Tasks 868 where task.State == TaskState.Calculating && task.AssignedResources.Any(x => resourceIds.Contains(x.ResourceId)) 849 869 group task by task.Job.OwnerUserId into g 850 870 select new { UserId = g.Key, UsedCores = g.Count() }; -
trunk/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs
r9022 r9033 148 148 #region Statistics Methods 149 149 Dictionary<Guid, int> GetWaitingTasksByUser(); 150 Dictionary<Guid, int> GetWaitingTasksByUserForResources(List<Guid> resourceIds); 150 151 Dictionary<Guid, int> GetCalculatingTasksByUser(); 152 Dictionary<Guid, int> GetCalculatingTasksByUserForResources(List<Guid> resourceIds); 151 153 DT.Statistics GetStatistic(Guid id); 152 154 IEnumerable<DT.Statistics> GetStatistics(Expression<Func<Statistics, bool>> predicate);
Note: See TracChangeset
for help on using the changeset viewer.