Changeset 11222 for branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Controllers/AdminDataController.cs
- Timestamp:
- 07/24/14 09:16:42 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Controllers/AdminDataController.cs
r11030 r11222 24 24 } 25 25 26 public JsonResult TaskStats(DateTime start, DateTime end, string userName=null) 27 { 28 using (var db = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString)) 29 { 26 public JsonResult TaskStats(DateTime start, DateTime end, string userName=null) { 27 using (var db = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString)) { 30 28 var taskStats = (from tasks in db.FactTasks 31 29 join jobs in db.DimJobs … … 35 33 (string.IsNullOrEmpty(userName) || jobs.UserName == userName) 36 34 select new { tasks.TotalWaitingTime, tasks.TotalTransferTime, tasks.TotalRuntime, tasks.NumCalculationRuns, 37 tasks.CoresRequired, tasks.MemoryRequired , tasks.TaskSize, tasks.ResultSize})35 tasks.CoresRequired, tasks.MemoryRequired}) 38 36 .ToList(); 39 37 … … 45 43 FullStats.Add(new KeyValuePair<string, double>("Cores Required", taskStats.Sum(c => c.CoresRequired))); 46 44 FullStats.Add(new KeyValuePair<string, double>("Memory Required", taskStats.Sum(m => m.MemoryRequired))); 47 FullStats.Add(new KeyValuePair<string, double>("Task Size", taskStats.Sum(ts => ts.TaskSize)));48 FullStats.Add(new KeyValuePair<string, double>("Result Size", taskStats.Sum(rs => Convert.ToDouble(rs.ResultSize))));49 45 50 46 return Json(FullStats, JsonRequestBehavior.AllowGet); 51 47 } 52 48 } 49 50 public JsonResult MoreTaskInfo(string taskId) { 51 using (var db = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString)) 52 { 53 var moreInfo = (from tasks in db.FactTasks 54 where tasks.TaskId.ToString() == taskId 55 select new 56 { 57 tasks.TotalWaitingTime, 58 tasks.TotalTransferTime, 59 tasks.TotalRuntime, 60 tasks.NumCalculationRuns, 61 tasks.CoresRequired, 62 tasks.MemoryRequired, 63 }) 64 .ToList(); 65 66 List<KeyValuePair<string, double>> AllInfo = new List<KeyValuePair<string, double>>(); 67 AllInfo.Add(new KeyValuePair<string, double>("Number Calculation Runs", moreInfo.Sum(n => n.NumCalculationRuns))); 68 AllInfo.Add(new KeyValuePair<string, double>("Cores Required", moreInfo.Sum(c => c.CoresRequired))); 69 AllInfo.Add(new KeyValuePair<string, double>("Memory Required", moreInfo.Sum(m => m.MemoryRequired))); 70 71 return Json(AllInfo, JsonRequestBehavior.AllowGet); 72 } 73 } 74 75 public JsonResult MoreSlaveInfo(string slaveId) { 76 using (var db = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString)) 77 { 78 var moreInfo = (from slaves in db.FactClientInfos 79 where slaves.ClientId.ToString() == slaveId 80 select new 81 { 82 slaves.Time, 83 slaves.TotalTimeIdle, 84 slaves.TotalTimeCalculating, 85 slaves.TotalTimeTransferring, 86 slaves.TotalTimeOffline, 87 slaves.TotalTimeUnavailable 88 }).ToList(); 89 90 List<List<KeyValuePair<string, string>>> AllInfo = new List<List<KeyValuePair<string, string>>>(); 91 List<List<KeyValuePair<string, string>>> DistinctInfo = new List<List<KeyValuePair<string, string>>>(); 92 for(var i=0; i < moreInfo.Count; i++) { 93 List<KeyValuePair<string, string>> newRow = new List<KeyValuePair<string, string>>(); 94 newRow.Add(new KeyValuePair<string, string>("Time", moreInfo.ElementAt(i).Time.ToShortDateString() + " " + moreInfo.ElementAt(i).Time.ToShortTimeString())); 95 newRow.Add(new KeyValuePair<string, string>("Time Idle", moreInfo.ElementAt(i).TotalTimeIdle.ToString())); 96 newRow.Add(new KeyValuePair<string, string>("Time Calculating", moreInfo.ElementAt(i).TotalTimeCalculating.ToString())); 97 newRow.Add(new KeyValuePair<string, string>("Time Transferring", moreInfo.ElementAt(i).TotalTimeTransferring.ToString())); 98 newRow.Add(new KeyValuePair<string, string>("Time Offline", moreInfo.ElementAt(i).TotalTimeOffline.ToString())); 99 newRow.Add(new KeyValuePair<string, string>("Time Unavailable", moreInfo.ElementAt(i).TotalTimeUnavailable.ToString())); 100 AllInfo.Add(newRow); 101 } 102 103 //Ensures that only records with changes in Traffic or Time fields are included 104 List<KeyValuePair<string, string>> lastRecord = null; 105 //Initilized to true to ensure first record is automatically included 106 bool isDistinct = true; 107 foreach (List<KeyValuePair<string, string>> row in AllInfo) { 108 //Ignores check for first row 109 if (lastRecord != null) { 110 isDistinct = false; 111 //Cycles through values of current row and lastRecord 112 for (var j=0; j < row.Count; j++) { 113 //Disregards time field from distinct checks 114 if (row.ElementAt(j).Key != "Time") { 115 //If values differ then row is distinct, break loop 116 if (row.ElementAt(j).Value != lastRecord.ElementAt(j).Value) { 117 isDistinct = true; 118 break; 119 } 120 } 121 } 122 } 123 lastRecord = row; 124 if (isDistinct) { 125 DistinctInfo.Add(row); 126 } 127 } 128 129 return Json(DistinctInfo, JsonRequestBehavior.AllowGet); 130 } 131 } 53 132 } 54 133 }
Note: See TracChangeset
for help on using the changeset viewer.