Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/15 15:51:32 (9 years ago)
Author:
dglaser
Message:

#2388:

HeuristicLab.Services.Access:
HeuristicLab.Services.Access.DataAccess:

  • Changed connection strings and certificates for local usage

HeuristicLab.Services.Hive.DataAccess:

  • Added compiled queries for frequently used queries
  • Integrated string queries from OptimizedHiveDao

HeuristicLab.Services.Hive:

  • Added NewHeartbeatManager.cs
  • Added NewRoundRobinTaskScheduler.cs
  • Added PerformanceLogger
  • Updated AuthoriziationManager
  • Updated NewHiveService
    • Added Regions
    • Implemented missing methods
    • Improved performance of several queries

HeuristicLab.Services.WebApp.Status:

  • Fixed a bug which caused an error when calculating the average waiting time.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/TaskDao.cs

    r12584 r12691  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Data.Linq;
    2425using System.Linq;
     
    2930
    3031    public override Task GetById(Guid id) {
    31       return Table.SingleOrDefault(x => x.TaskId == id);
     32      return GetByIdQuery(DataContext, id);
    3233    }
    3334
     
    3940      return Table.Where(x => x.JobId == id);
    4041    }
     42    public class TaskPriorityInfo {
     43      public Guid JobId { get; set; }
     44      public Guid TaskId { get; set; }
     45      public int Priority { get; set; }
     46    }
     47
     48    public IEnumerable<TaskPriorityInfo> GetWaitingTasks(Slave slave) {
     49      //Originally we checked here if there are parent tasks which should be calculated (with GetParentTasks(resourceIds, count, false);).
     50      //Because there is at the moment no case where this makes sense (there don't exist parent tasks which need to be calculated),
     51      //we skip this step because it's wasted runtime
     52      return DataContext.ExecuteQuery<TaskPriorityInfo>(GetWaitingTasksQueryString, slave.ResourceId, Enum.GetName(typeof(TaskState), TaskState.Waiting), slave.FreeCores, slave.FreeMemory).ToList();
     53    }
     54
     55    public void UpdateExecutionTime(Guid taskId, double executionTime) {
     56      DataContext.ExecuteCommand(UpdateExecutionTimeQuery, executionTime, DateTime.Now, taskId);
     57    }
     58
     59    #region Compiled queries
     60    private static readonly Func<DataContext, Guid, Task> GetByIdQuery =
     61      CompiledQuery.Compile((DataContext db, Guid taskId) =>
     62        (from task in db.GetTable<Task>()
     63         where task.TaskId == taskId
     64         select task).SingleOrDefault());
     65    #endregion
     66
     67    #region String queries
     68    private const string GetWaitingTasksQueryString = @"
     69      WITH pr AS (
     70        SELECT ResourceId, ParentResourceId
     71        FROM [Resource]
     72        WHERE ResourceId = {0}
     73        UNION ALL
     74        SELECT r.ResourceId, r.ParentResourceId
     75        FROM [Resource] r JOIN pr ON r.ResourceId = pr.ParentResourceId
     76      )
     77      SELECT DISTINCT t.TaskId, t.JobId, t.Priority
     78      FROM pr JOIN AssignedResources ar ON ar.ResourceId = pr.ResourceId
     79          JOIN Task t ON t.TaskId = ar.TaskId
     80      WHERE NOT (t.IsParentTask = 1 AND t.FinishWhenChildJobsFinished = 1)
     81          AND t.TaskState = {1}
     82          AND t.CoresNeeded <= {2}
     83          AND t.MemoryNeeded <= {3}
     84    ";
     85
     86    private const string UpdateExecutionTimeQuery = @"
     87      UPDATE [Task]
     88         SET ExecutionTimeMs = {0},
     89             LastHeartbeat = {1}
     90       WHERE TaskId = {2}
     91    ";
     92    #endregion
    4193  }
    4294}
Note: See TracChangeset for help on using the changeset viewer.