Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12925


Ignore:
Timestamp:
09/01/15 13:47:15 (9 years ago)
Author:
ascheibe
Message:

#2388 fixed update of task facts

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.cs

    r12878 r12925  
    3030      throw new NotImplementedException();
    3131    }
    32 
    33     partial void OnCreated() {
    34       LogFactory.GetLogger(this.GetType().Namespace).Log("HiveDataContext created");
    35     }
    3632  }
    3733}
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HiveStatisticsGenerator.cs

    r12878 r12925  
    5757
    5858          pm.UseTransaction(() => {
    59             UpdateTaskFactsTable(time, pm);
     59            UpdateTaskFactsTable(pm);
    6060            try {
    6161              pm.SubmitChanges();
     
    261261    }
    262262
    263     private void UpdateTaskFactsTable(DimTime newTime, PersistenceManager pm) {
     263    private void UpdateTaskFactsTable(PersistenceManager pm) {
    264264      var factTaskDao = pm.FactTaskDao;
    265265      var taskDao = pm.TaskDao;
     
    273273
    274274      var newTasks =
    275         from task in taskDao.GetAllChildTasks()
    276         let stateLogs = task.StateLogs.OrderByDescending(x => x.DateTime)
    277         let lastSlaveId = stateLogs.First(x => x.SlaveId != null).SlaveId
    278         where (!factTaskIds.Contains(task.TaskId)
    279                || notFinishedFactTasks.Select(x => x.TaskId).Contains(task.TaskId))
    280         join lastFactTask in notFinishedFactTasks on task.TaskId equals lastFactTask.TaskId into lastFactPerTask
    281         from lastFact in lastFactPerTask.DefaultIfEmpty()
    282         join client in dimClientDao.GetActiveClients() on lastSlaveId equals client.ResourceId into clientsPerSlaveId
    283         from client in clientsPerSlaveId.DefaultIfEmpty()
    284         select new {
    285           TaskId = task.TaskId,
    286           JobId = task.JobId,
    287           Priority = task.Priority,
    288           CoresRequired = task.CoresNeeded,
    289           MemoryRequired = task.MemoryNeeded,
    290           State = task.State,
    291           StateLogs = stateLogs.OrderBy(x => x.DateTime),
    292           LastClientId = client != null
    293                          ? client.Id : lastFact != null
    294                          ? lastFact.LastClientId : (Guid?)null
    295         };
     275        (from task in taskDao.GetAllChildTasks()
     276         let stateLogs = task.StateLogs.OrderByDescending(x => x.DateTime)
     277         let lastSlaveId = stateLogs.First(x => x.SlaveId != null).SlaveId
     278         where (!factTaskIds.Contains(task.TaskId)
     279                || notFinishedFactTasks.Select(x => x.TaskId).Contains(task.TaskId))
     280         join lastFactTask in notFinishedFactTasks on task.TaskId equals lastFactTask.TaskId into lastFactPerTask
     281         from lastFact in lastFactPerTask.DefaultIfEmpty()
     282         join client in dimClientDao.GetActiveClients() on lastSlaveId equals client.ResourceId into clientsPerSlaveId
     283         from client in clientsPerSlaveId.DefaultIfEmpty()
     284         select new {
     285           TaskId = task.TaskId,
     286           JobId = task.JobId,
     287           Priority = task.Priority,
     288           CoresRequired = task.CoresNeeded,
     289           MemoryRequired = task.MemoryNeeded,
     290           State = task.State,
     291           StateLogs = stateLogs.OrderBy(x => x.DateTime),
     292           LastClientId = client != null
     293                          ? client.Id : lastFact != null
     294                          ? lastFact.LastClientId : (Guid?)null,
     295           NotFinishedTask = notFinishedFactTasks.Any(y => y.TaskId == task.TaskId)
     296         }).ToList();
     297
     298      //insert facts for new tasks
    296299      factTaskDao.Save(
    297         from x in newTasks.ToList()
     300        from x in newTasks
     301        where !x.NotFinishedTask
    298302        let taskData = CalculateFactTaskData(x.StateLogs)
    299303        select new FactTask {
     
    315319          InitialWaitingTime = taskData.InitialWaitingTime
    316320        });
    317       factTaskDao.Delete(notFinishedFactTasks.Select(x => x.TaskId));
     321
     322      //update data of already existing facts
     323      foreach (var notFinishedTask in factTaskDao.GetNotFinishedTasks()) {
     324        var ntc = newTasks.Where(x => x.TaskId == notFinishedTask.TaskId);
     325        if (ntc.Any()) {
     326          var x = ntc.Single();
     327          var taskData = CalculateFactTaskData(x.StateLogs);
     328
     329          notFinishedTask.StartTime = taskData.StartTime;
     330          notFinishedTask.EndTime = taskData.EndTime;
     331          notFinishedTask.LastClientId = x.LastClientId;
     332          notFinishedTask.Priority = x.Priority;
     333          notFinishedTask.CoresRequired = x.CoresRequired;
     334          notFinishedTask.MemoryRequired = x.MemoryRequired;
     335          notFinishedTask.NumCalculationRuns = taskData.CalculationRuns;
     336          notFinishedTask.NumRetries = taskData.Retries;
     337          notFinishedTask.WaitingTime = taskData.WaitingTime;
     338          notFinishedTask.CalculatingTime = taskData.CalculatingTime;
     339          notFinishedTask.TransferTime = taskData.TransferTime;
     340          notFinishedTask.TaskState = x.State;
     341          notFinishedTask.Exception = taskData.Exception;
     342          notFinishedTask.InitialWaitingTime = taskData.InitialWaitingTime;
     343        }
     344      }
    318345    }
    319346
Note: See TracChangeset for help on using the changeset viewer.