Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/31/13 11:20:32 (11 years ago)
Author:
pfleck
Message:

#2063:
Query last client for task facts and calculate task fact data.
(TotalRuntime/Wait/TransferRime pending)

File:
1 edited

Legend:

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

    r9557 r9560  
    232232        from lWithLf in tLfJoin.DefaultIfEmpty()
    233233        where !t.IsParentTask
    234         select new { Task = t, LastFact = tLfJoin.FirstOrDefault() };
     234        select new { Task = t, TaskDataSize = t.JobData.DataSize, LastFact = tLfJoin.FirstOrDefault() };
    235235
    236236      var tasksWithNewStateLogs =
    237237        from sl in db.StateLogs
    238238        join twlf in tasksWithLastFact on sl.TaskId equals twlf.Task.TaskId
    239         where twlf.LastFact == null || (sl.DateTime > twlf.LastFact.EndTime && sl.DateTime < newTime.Time)
     239        where (twlf.LastFact == null || sl.DateTime > twlf.LastFact.EndTime) && sl.DateTime < newTime.Time
    240240        group sl by twlf.Task into factGroup
    241         select new { Task = factGroup.Key, StateLogs = factGroup.OrderBy(x => x.DateTime) };
     241        select new {
     242          Task = factGroup.Key,
     243          StateLogs = factGroup.OrderBy(x => x.DateTime),
     244          LastSlave = factGroup.OrderByDescending(x => x.DateTime).First(x => x.SlaveId != null).SlaveId
     245        };
    242246
    243247      var tasksWithLastFactsAndStateLogs =
    244248        from twsl in tasksWithNewStateLogs
    245249        join twlf in tasksWithLastFact on twsl.Task equals twlf.Task
    246         select new { twlf.Task, twlf.LastFact, twsl.StateLogs };
     250        select new { twlf.Task, twlf.TaskDataSize, twlf.LastFact, twsl.StateLogs, twsl.LastSlave };
     251
     252      var clients =
     253        from cl in db.DimClients
     254        //where cl.ExpirationTime == null
     255        select cl;
     256
     257      var tasksWithLastFactsAndStateLogsAndLastResource =
     258        from twlfasl in tasksWithLastFactsAndStateLogs
     259        join cl in clients on twlfasl.LastSlave equals cl.ResourceId into clJoinGrp
     260        from cl in clJoinGrp.DefaultIfEmpty()
     261        select new { twlfasl.Task, twlfasl.TaskDataSize, twlfasl.LastFact, twlfasl.StateLogs, LastClient = cl };
    247262
    248263      var newTaskFacts =
    249         from t in tasksWithLastFactsAndStateLogs.ToList()
     264        from t in tasksWithLastFactsAndStateLogsAndLastResource.ToList()
    250265        select new FactTask {
    251266          TaskId = t.Task.TaskId,
    252267          JobId = t.Task.JobId,
    253           DimTimeStart = t.LastFact.DimTimeStart,
     268          DimTimeStart = t.LastFact != null ? t.LastFact.DimTimeStart : newTime,
    254269          DimTimeEnd = newTime,
    255           // ...
     270          LastClientId = t.LastClient != null ? t.LastClient.Id : (t.LastFact != null ? t.LastFact.LastClientId : Guid.Empty),
     271          Priority = t.Task.Priority,
     272          CoresRequired = t.Task.CoresNeeded,
     273          MemoryRequired = t.Task.MemoryNeeded,
     274          TaskSize = t.LastFact != null ? t.LastFact.TaskSize : t.TaskDataSize,
     275          ResultSize = t.Task.State == TaskState.Finished ? t.TaskDataSize : default(long?),
     276          NumCalculationRuns = (t.LastFact != null ? t.LastFact.NumCalculationRuns : 0) + t.StateLogs.Count(x => x.State == TaskState.Calculating),
     277          NumFails = (t.LastFact != null ? t.LastFact.NumFails : 0) + t.StateLogs.Count(x => x.State == TaskState.Failed || !string.IsNullOrEmpty(x.Exception)),
     278          TotalWaitingTime = 0, //ToDo
     279          TotalRuntime = 0, //ToDo
     280          TotalTransferTime = 0 //ToDo
    256281        };
    257282
Note: See TracChangeset for help on using the changeset viewer.