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

#2839 implemented project facts-logging in HiveStatisticsGenerator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveStatisticsGenerator.cs

    r15659 r15666  
    5959          pm.UseTransaction(() => {
    6060            UpdateFactClientInfoTable(time, pm);
    61             UpdateFactProjectInfoTable(time, pm); // in progress
     61            UpdateFactProjectInfoTable(time, pm);
    6262            pm.SubmitChanges();
    6363          });
     
    118118    }
    119119
     120    // add new projects
     121    // delete expired projects
     122    // update information of existing projects
    120123    private void UpdateDimProjectTable(PersistenceManager pm) {
    121124      var projectDao = pm.ProjectDao;
     
    353356
    354357    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        );
    356379    }
    357380
Note: See TracChangeset for help on using the changeset viewer.