[6743] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2011 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;
|
---|
[6457] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using System.Web;
|
---|
| 26 | using System.Web.UI;
|
---|
| 27 | using System.Web.UI.WebControls;
|
---|
| 28 | using HeuristicLab.Services.Hive.DataAccess;
|
---|
| 29 | using HeuristicLab.Services.Hive;
|
---|
[6717] | 30 | using HeuristicLab.Services.Hive.DataTransfer;
|
---|
[6457] | 31 | using System.Text;
|
---|
[6458] | 32 | using System.Web.UI.DataVisualization.Charting;
|
---|
[6717] | 33 | using DA = HeuristicLab.Services.Hive.DataAccess;
|
---|
[6457] | 34 |
|
---|
| 35 | public partial class Status : System.Web.UI.Page {
|
---|
| 36 | protected void Page_Load(object sender, EventArgs e) {
|
---|
| 37 | var dao = ServiceLocator.Instance.HiveDao;
|
---|
[6478] | 38 | var resourceName = Request.QueryString["resource"];
|
---|
| 39 | IEnumerable<Guid> resourceIds;
|
---|
| 40 | if (!string.IsNullOrEmpty(resourceName)) {
|
---|
| 41 | var resId = dao.GetResources(x => x.Name == resourceName).Single().Id;
|
---|
| 42 | resourceIds = dao.GetChildResources(resId).Select(x => x.Id).Union(new List<Guid> { resId });
|
---|
| 43 | speedupChartHours.Visible = false;
|
---|
| 44 | speedupChartMinutes.Visible = false;
|
---|
| 45 | } else {
|
---|
| 46 | resourceIds = dao.GetResources(x => true).Select(y => y.Id);
|
---|
| 47 | speedupChartHours.Visible = true;
|
---|
| 48 | speedupChartMinutes.Visible = true;
|
---|
| 49 | }
|
---|
[6717] | 50 |
|
---|
| 51 | var onlineSlaves = dao.GetSlaves(x => (x.SlaveState == DA.SlaveState.Calculating || x.SlaveState == DA.SlaveState.Idle) && resourceIds.Contains(x.ResourceId));
|
---|
[6457] | 52 |
|
---|
[6940] | 53 | int currentlyAvailableCores = onlineSlaves.Where(s => s.Cores.HasValue).Sum(s => s.Cores.Value);
|
---|
| 54 | int currentlyUsedCores = currentlyAvailableCores - onlineSlaves.Where(s => s.FreeCores.HasValue).Sum(s => s.FreeCores.Value);
|
---|
[6743] | 55 | int currentlyJobsWaiting = ServiceLocator.Instance.HiveDao.GetTasks(x => x.State == DA.TaskState.Waiting).Count();
|
---|
[6457] | 56 |
|
---|
[6458] | 57 | this.availableCoresLabel.Text = currentlyAvailableCores.ToString();
|
---|
| 58 | this.usedCoresLabel.Text = currentlyUsedCores.ToString();
|
---|
| 59 | this.waitingJobsLabel.Text = currentlyJobsWaiting.ToString();
|
---|
[6457] | 60 |
|
---|
[6478] | 61 | slavesLabel.Text = string.Join(", ", onlineSlaves.Select(x => string.Format("<a href=\"?resource={0}\">{0}</a> ({1} %)", x.Name, Math.Round(x.CpuUtilization, 2))));
|
---|
[6457] | 62 |
|
---|
[6469] | 63 | cpuUtilizationLabel.Text = (onlineSlaves.Count() > 0 ? Math.Round(onlineSlaves.Average(s => s.CpuUtilization), 2).ToString() : "0.0") + " %";
|
---|
[6458] | 64 |
|
---|
[6717] | 65 | HeuristicLab.Services.Hive.DataTransfer.Statistics[] stats;
|
---|
[6941] | 66 | if (daysDropDownList.SelectedValue == "All") {
|
---|
[6478] | 67 | stats = dao.GetStatistics(x => true).OrderBy(x => x.TimeStamp).ToArray();
|
---|
[6941] | 68 | } else {
|
---|
[6478] | 69 | stats = dao.GetStatistics(x => x.Timestamp >= DateTime.Now.Subtract(TimeSpan.FromDays(int.Parse(daysDropDownList.SelectedValue)))).OrderBy(x => x.TimeStamp).ToArray();
|
---|
[6941] | 70 | }
|
---|
| 71 |
|
---|
[6712] | 72 | if (stats.Length != 0) {
|
---|
[6941] | 73 | var firstStatisticsDate = stats.OrderBy(x => x.TimeStamp).First().TimeStamp;
|
---|
| 74 | var statisticsSince = DateTime.Now - firstStatisticsDate;
|
---|
[6712] | 75 | totalExecutionTimeLabel.Text = new TimeSpan(stats.Last().UserStatistics.Sum(x => x.ExecutionTime.Ticks)).ToString() + " (since " + Math.Round(statisticsSince.TotalDays, 2) + " days)";
|
---|
| 76 | } else {
|
---|
| 77 | totalExecutionTimeLabel.Text = "00:00:00.00";
|
---|
| 78 | }
|
---|
[6478] | 79 |
|
---|
[6458] | 80 | for (int i = 0; i < stats.Length; i++) {
|
---|
| 81 | var s = stats[i];
|
---|
[6478] | 82 | var slaveStats = s.SlaveStatistics.Where(x => resourceIds.Contains(x.SlaveId));
|
---|
[6458] | 83 |
|
---|
[6478] | 84 | var averageCpuUtilization = slaveStats.Count() > 0 ? slaveStats.Average(x => x.CpuUtilization) : 0.0;
|
---|
[6458] | 85 | cpuUtilizationChart.Series[0].Points.Add(new DataPoint(s.TimeStamp.ToOADate(), averageCpuUtilization));
|
---|
| 86 |
|
---|
[6478] | 87 | var cores = slaveStats.Sum(x => x.Cores);
|
---|
[6458] | 88 |
|
---|
[6478] | 89 | var usedCores = cores - slaveStats.Sum(x => x.FreeCores);
|
---|
[6458] | 90 | coresChart.Series[0].Points.AddXY(s.TimeStamp.ToOADate(), cores);
|
---|
| 91 | coresChart.Series[1].Points.AddXY(s.TimeStamp.ToOADate(), usedCores);
|
---|
| 92 |
|
---|
[6478] | 93 | var memory = slaveStats.Sum(x => x.Memory);
|
---|
| 94 | var usedMemory = memory - slaveStats.Sum(x => x.FreeMemory);
|
---|
| 95 | memoryChart.Series[0].Points.AddXY(s.TimeStamp.ToOADate(), memory / 1024.0);
|
---|
| 96 | memoryChart.Series[1].Points.AddXY(s.TimeStamp.ToOADate(), usedMemory / 1024.0);
|
---|
[6458] | 97 |
|
---|
| 98 | if (i > 0) {
|
---|
[6457] | 99 | var execTime = new TimeSpan(s.UserStatistics.Sum(x => x.ExecutionTime.Ticks));
|
---|
[6458] | 100 | var execTimePrev = new TimeSpan(stats[i - 1].UserStatistics.Sum(x => x.ExecutionTime.Ticks));
|
---|
| 101 | var execTimeDifference = execTimePrev - execTime;
|
---|
| 102 |
|
---|
| 103 | var timeDifference = stats[i - 1].TimeStamp - s.TimeStamp; // the difference between statistic entries is not alway exactly 1 minute
|
---|
| 104 | var speedup = execTimeDifference.TotalMinutes / timeDifference.TotalMinutes;
|
---|
| 105 | speedupChartMinutes.Series[0].Points.AddXY(s.TimeStamp.ToOADate(), speedup);
|
---|
[6478] | 106 | speedupChartMinutes.Series[1].Points.AddXY(s.TimeStamp.ToOADate(), cores);
|
---|
[6457] | 107 | }
|
---|
[6458] | 108 | if (i - 60 >= 0) {
|
---|
| 109 | var execTime = new TimeSpan(s.UserStatistics.Sum(x => x.ExecutionTime.Ticks));
|
---|
| 110 | var execTimePrev = new TimeSpan(stats[i - 60].UserStatistics.Sum(x => x.ExecutionTime.Ticks));
|
---|
| 111 | var execTimeDifference = execTimePrev - execTime;
|
---|
| 112 |
|
---|
| 113 | var timeDifference = stats[i - 60].TimeStamp - s.TimeStamp; // the difference between statistic entries is not alway exactly 1 minute
|
---|
| 114 | var speedup = execTimeDifference.TotalMinutes / timeDifference.TotalMinutes;
|
---|
| 115 | speedupChartHours.Series[0].Points.AddXY(s.TimeStamp.ToOADate(), speedup);
|
---|
[6478] | 116 | speedupChartHours.Series[1].Points.AddXY(s.TimeStamp.ToOADate(), cores);
|
---|
[6458] | 117 | }
|
---|
[6457] | 118 | }
|
---|
| 119 | }
|
---|
[6458] | 120 |
|
---|
| 121 | protected void daysDropDownList_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
| 122 |
|
---|
| 123 | }
|
---|
[6457] | 124 | } |
---|