Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/29/18 17:38:50 (7 years ago)
Author:
jzenisek
Message:

#2839 implemented project facts-logging in HiveStatisticsGenerator

Location:
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectDao.cs

    r15577 r15666  
    2828  public class ProjectDao : GenericDao<Guid, Project> {
    2929    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    }
    3036
    3137    public override Project GetById(Guid id) {
     
    7076    }
    7177
     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
    7286    #region Compiled queries
    7387    private static readonly Func<DataContext, Guid, Project> GetByIdQuery =
     
    7993
    8094    #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
    81129    private const string GetUsageGrantedProjectsForUserQueryString = @"
    82130      SELECT DISTINCT p.*
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/TaskDao.cs

    r15644 r15666  
    9393
    9494    #region String queries
    95     private const string GetParentTasksQueryString = @"
    96       SELECT t.* FROM [Task] t, [Job] j, [AssignedJobResource] ajr
    97         WHERE t.IsParentTask = 1
    98         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'
    9999        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
    103102    ";
    104103    private const string GetWaitingTasksQueryString = @"
Note: See TracChangeset for help on using the changeset viewer.