Changeset 15666 for branches/HiveProjectManagement
- Timestamp:
- 01/29/18 17:38:50 (7 years ago)
- Location:
- branches/HiveProjectManagement
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectDao.cs
r15577 r15666 28 28 public class ProjectDao : GenericDao<Guid, Project> { 29 29 public ProjectDao(DataContext dataContext) : base(dataContext) { } 30 31 public class ProjectStats { 32 public Guid ProjectId { get; set; } 33 public int Cores { get; set; } 34 public int Memory { get; set; } 35 } 30 36 31 37 public override Project GetById(Guid id) { … … 70 76 } 71 77 78 public IEnumerable<ProjectStats> GetUsageStatsPerProject() { 79 return DataContext.ExecuteQuery<ProjectStats>(GetUsageStatsPerProjectQueryString).ToList(); 80 } 81 82 public IEnumerable<ProjectStats> GetAvailabilityStatsPerProject() { 83 return DataContext.ExecuteQuery<ProjectStats>(GetAvailabilityStatsPerProjectQueryString).ToList(); 84 } 85 72 86 #region Compiled queries 73 87 private static readonly Func<DataContext, Guid, Project> GetByIdQuery = … … 79 93 80 94 #region String queries 95 private const string GetUsageStatsPerProjectQueryString = @" 96 SELECT j.ProjectId, SUM(t.CoresNeeded) AS Cores, SUM(t.MemoryNeeded) AS Memory 97 FROM [Task] t, [Job] j 98 WHERE t.TaskState = 'Calculating' 99 AND t.JobId = j.JobId 100 GROUP BY j.ProjectId 101 "; 102 103 private const string GetAvailabilityStatsPerProjectQueryString = @" 104 WITH rtree AS 105 ( 106 SELECT ResourceId, ParentResourceId 107 FROM [Resource] 108 UNION ALL 109 SELECT rt.ResourceId, r.ParentResourceId 110 FROM [Resource] r 111 JOIN rtree rt ON rt.ParentResourceId = r.ResourceId 112 ) 113 SELECT apr.ProjectId, SUM(res.Cores) AS Cores, SUM(res.Memory) AS Memory 114 FROM rtree, [AssignedProjectResource] apr, [Resource] res 115 WHERE rtree.ResourceId = res.ResourceId 116 AND res.ResourceType = 'Slave' 117 AND (res.SlaveState = 'Idle' OR SlaveState = 'Calculating') 118 AND rtree.ParentResourceId = apr.ResourceId 119 GROUP BY apr.ProjectId 120 UNION 121 SELECT apr.ProjectId, SUM(res.Cores) AS Cores, SUM(res.Memory) AS Memory 122 FROM [AssignedProjectResource] apr, [Resource] res 123 WHERE apr.ResourceId = res.ResourceId 124 AND res.ResourceType = 'Slave' 125 AND (res.SlaveState = 'Idle' OR SlaveState = 'Calculating') 126 GROUP BY apr.ProjectId 127 "; 128 81 129 private const string GetUsageGrantedProjectsForUserQueryString = @" 82 130 SELECT DISTINCT p.* -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/TaskDao.cs
r15644 r15666 93 93 94 94 #region String queries 95 private const string Get ParentTasksQueryString= @"96 SELECT t.* FROM [Task] t, [Job] j , [AssignedJobResource] ajr97 WHERE t.IsParentTask = 198 AND t.TaskState = ' Waiting'95 private const string GetCalculatingChildTasksByProjectId = @" 96 SELECT t.* FROM [Task] t, [Job] j 97 WHERE t.IsParentTask = 0 98 AND t.TaskState = 'Calculating' 99 99 AND t.JobId = j.JobId 100 AND j.JobId = ajr.JobId 101 AND t.FinishWhenChildJobsFinished = 1 102 ... TODO (not necessary) 100 AND j.ProjectId = {0} 101 ORDER BY j.ProjectId 103 102 "; 104 103 private const string GetWaitingTasksQueryString = @" -
branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveStatisticsGenerator.cs
r15659 r15666 59 59 pm.UseTransaction(() => { 60 60 UpdateFactClientInfoTable(time, pm); 61 UpdateFactProjectInfoTable(time, pm); // in progress61 UpdateFactProjectInfoTable(time, pm); 62 62 pm.SubmitChanges(); 63 63 }); … … 118 118 } 119 119 120 // add new projects 121 // delete expired projects 122 // update information of existing projects 120 123 private void UpdateDimProjectTable(PersistenceManager pm) { 121 124 var projectDao = pm.ProjectDao; … … 353 356 354 357 private void UpdateFactProjectInfoTable(DimTime newTime, PersistenceManager pm) { 355 // TODO 358 var factProjectInfoDao = pm.FactProjectInfoDao; 359 var dimProjectDao = pm.DimProjectDao; 360 var projectDao = pm.ProjectDao; 361 362 var projectAvailabilityStats = projectDao.GetAvailabilityStatsPerProject(); 363 var projectUsageStats = projectDao.GetUsageStatsPerProject(); 364 var dimProjects = dimProjectDao.GetAllOnlineProjects().ToList(); 365 366 factProjectInfoDao.Save( 367 from dimp in dimProjects 368 let aStats = projectAvailabilityStats.Where(x => x.ProjectId == dimp.ProjectId).SingleOrDefault() 369 let uStats = projectUsageStats.Where(x => x.ProjectId == dimp.ProjectId).SingleOrDefault() 370 select new FactProjectInfo { 371 ProjectId = dimp.ProjectId, 372 DimTime = newTime, 373 NumTotalCores = aStats != null ? aStats.Cores : 0, 374 TotalMemory = aStats != null ? aStats.Memory : 0, 375 NumUsedCores = uStats != null ? uStats.Cores : 0, 376 UsedMemory = uStats != null ? uStats.Memory : 0 377 } 378 ); 356 379 } 357 380
Note: See TracChangeset
for help on using the changeset viewer.