Changeset 12247 for branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Services.Hive.Web/Hive-3.3/Status.aspx.cs
- Timestamp:
- 03/24/15 11:17:08 (9 years ago)
- Location:
- branches/HeuristicLab.DatasetRefactor/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DatasetRefactor/sources
- Property svn:mergeinfo changed
-
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Services.Hive.Web/Hive-3.3/Status.aspx.cs
r12031 r12247 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Web;26 using System.Web.UI;27 25 using System.Web.UI.WebControls; 28 using HeuristicLab.Services.Hive.DataAccess;29 26 using HeuristicLab.Services.Hive; 30 using HeuristicLab.Services.Hive.DataTransfer;31 using System.Text;32 27 using System.Web.UI.DataVisualization.Charting; 33 28 using DA = HeuristicLab.Services.Hive.DataAccess; … … 37 32 protected void Page_Load(object sender, EventArgs e) { 38 33 var dao = ServiceLocator.Instance.HiveDao; 34 var optDao = ServiceLocator.Instance.OptimizedHiveDao; 39 35 var transactionManager = ServiceLocator.Instance.TransactionManager; 40 36 var resourceName = Request.QueryString["resource"]; 41 IEnumerable<Guid> resourceIds = new List<Guid>();42 IEnumerable<DT.Slave> onlineSlaves = new List<DT.Slave>();37 List<Guid> resourceIds = new List<Guid>(); 38 List<DT.Slave> onlineSlaves = new List<DT.Slave>(); 43 39 int currentlyJobsWaiting = 0; 44 Dictionary<Guid, int> calculatingTasksByUser = new Dictionary<Guid, int>();40 Dictionary<Guid, int> calculatingTasksByUser = new Dictionary<Guid, int>(); 45 41 Dictionary<Guid, int> waitingTasksByUser = new Dictionary<Guid, int>(); 46 42 List<DT.Resource> groups = new List<DT.Resource>(); 47 43 48 44 transactionManager.UseTransaction(() => { 49 50 }, false, false); 45 groups = dao.GetResources(x => x.ResourceType == "GROUP").ToList(); 46 }, false, false); 51 47 52 48 if (!string.IsNullOrEmpty(resourceName)) { 53 transactionManager.UseTransaction(() => 54 { 55 var resId = dao.GetResources(x => x.Name == resourceName).Single().Id; 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()); 59 }, false, false); 49 transactionManager.UseTransaction(() => { 50 var resId = dao.GetResources(x => x.Name == resourceName).Single().Id; 51 resourceIds = dao.GetChildResources(resId).Select(x => x.Id).Union(new List<Guid> { resId }).ToList(); 52 calculatingTasksByUser = dao.GetCalculatingTasksByUserForResources(resourceIds); 53 waitingTasksByUser = dao.GetWaitingTasksByUserForResources(resourceIds); 54 }, false, false); 60 55 } else { 61 transactionManager.UseTransaction(() => 62 { 63 resourceIds = dao.GetResources(x => true).Select(y => y.Id); 64 calculatingTasksByUser = dao.GetCalculatingTasksByUser(); 65 waitingTasksByUser = dao.GetWaitingTasksByUser(); 66 }, false, false); 67 } 56 transactionManager.UseTransaction(() => { 57 resourceIds = optDao.GetAllResourceIds().ToList(); 58 calculatingTasksByUser = optDao.GetCalculatingTasksByUser(); 59 waitingTasksByUser = optDao.GetWaitingTasksByUser(); 60 }, false, false); 61 } 68 62 69 transactionManager.UseTransaction(() => 70 { 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(); 63 transactionManager.UseTransaction(() => { 64 if (string.IsNullOrEmpty(resourceName)) { 65 onlineSlaves = dao.GetSlaves(x => x.SlaveState == DA.SlaveState.Calculating || x.SlaveState == DA.SlaveState.Idle).ToList(); 66 } else { 67 onlineSlaves = dao.GetSlaves(x => (x.SlaveState == DA.SlaveState.Calculating || x.SlaveState == DA.SlaveState.Idle) && resourceIds.Contains(x.ResourceId)).ToList(); 68 } 69 currentlyJobsWaiting = optDao.GetNumberOfWaitingTasks(); 73 70 }, false, false); 74 71 … … 76 73 int currentlyAvailableCores = onlineSlaves.Where(s => s.Cores.HasValue && s.IsAllowedToCalculate).Sum(s => s.Cores.Value); 77 74 int currentlyUsedCores = overallCurrentlyAvailableCores - onlineSlaves.Where(s => s.FreeCores.HasValue).Sum(s => s.FreeCores.Value); 78 75 79 76 this.overallAvailableCoresLabel.Text = overallCurrentlyAvailableCores.ToString(); 80 77 this.availableCoresLabel.Text = currentlyAvailableCores.ToString(); … … 86 83 groupsLabel.Text += string.Join(", ", groups.Select(x => string.Format("<a href=\"?resource={0}\">{0}</a>", x.Name))); 87 84 88 overallCpuUtilizationLabel.Text = (onlineSlaves. Count() > 0? Math.Round(onlineSlaves.Average(s => s.CpuUtilization), 2).ToString() : "0.0") + " %";89 cpuUtilizationLabel.Text = (onlineSlaves. Count() > 0 && onlineSlaves.Where(x => x.IsAllowedToCalculate).Count() > 0? Math.Round(onlineSlaves.Where(x => x.IsAllowedToCalculate).Average(s => s.CpuUtilization), 2).ToString() : "0.0") + " %";85 overallCpuUtilizationLabel.Text = (onlineSlaves.Any() ? Math.Round(onlineSlaves.Average(s => s.CpuUtilization), 2).ToString() : "0.0") + " %"; 86 cpuUtilizationLabel.Text = (onlineSlaves.Any() && onlineSlaves.Any(x => x.IsAllowedToCalculate) ? Math.Round(onlineSlaves.Where(x => x.IsAllowedToCalculate).Average(s => s.CpuUtilization), 2).ToString() : "0.0") + " %"; 90 87 91 DT.Statistics[] stats = new DT.Statistics[0]; 92 transactionManager.UseTransaction(() => 93 { 94 if (daysDropDownList.SelectedValue == "All") { 95 stats = dao.GetStatistics(x => true).OrderBy(x => x.TimeStamp).ToArray(); 96 } else { 97 stats = dao.GetStatistics(x => x.Timestamp >= DateTime.Now.Subtract(TimeSpan.FromDays(int.Parse(daysDropDownList.SelectedValue)))).OrderBy(x => x.TimeStamp).ToArray(); 98 } 88 DT.Statistics[] stats = new DT.Statistics[0]; 89 transactionManager.UseTransaction(() => { 90 if (daysDropDownList.SelectedValue == "All") { 91 stats = dao.GetStatistics(x => true).OrderBy(x => x.TimeStamp).ToArray(); 92 } else { 93 stats = dao.GetStatistics(x => x.Timestamp >= DateTime.Now.Subtract(TimeSpan.FromDays(int.Parse(daysDropDownList.SelectedValue)))).OrderBy(x => x.TimeStamp).ToArray(); 94 } 99 95 }, false, false); 100 96 101 97 for (int i = 0; i < stats.Length; i++) { 102 98 var s = stats[i]; 103 var slaveStats = s.SlaveStatistics.Where(x => resourceIds.Contains(x.SlaveId)) ;99 var slaveStats = s.SlaveStatistics.Where(x => resourceIds.Contains(x.SlaveId)).ToArray(); 104 100 105 var averageCpuUtilization = slaveStats. Count() > 0? slaveStats.Average(x => x.CpuUtilization) : 0.0;101 var averageCpuUtilization = slaveStats.Any() ? slaveStats.Average(x => x.CpuUtilization) : 0.0; 106 102 cpuUtilizationChart.Series[0].Points.Add(new DataPoint(s.TimeStamp.ToOADate(), averageCpuUtilization)); 107 103 … … 118 114 } 119 115 120 GenerateTasksByUserTable(waitingTasksByUser, waitingTasksByUserTable); 121 GenerateTasksByUserTable(calculatingTasksByUser, calculatingTasksByUserTable); 116 GenerateTasksByUserTable(waitingTasksByUser, waitingTasksByUserTable); 117 GenerateTasksByUserTable(calculatingTasksByUser, calculatingTasksByUserTable); 122 118 } 123 119 … … 134 130 table.Rows.Add(curRow); 135 131 } 136 if (tasksByUser. Count() > 0) {137 TableRow sumRow = new TableRow(); 132 if (tasksByUser.Any()) { 133 TableRow sumRow = new TableRow(); 138 134 TableCell sumCell = new TableCell(); 139 135 sumCell.BorderWidth = Unit.Pixel(3); … … 143 139 table.Rows.Add(sumRow); 144 140 } 145 } 141 } 146 142 }
Note: See TracChangeset
for help on using the changeset viewer.