Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/21/15 11:48:49 (9 years ago)
Author:
dglaser
Message:

#2388:

HeuristicLab.Services.Access.DataAccess-3.3:

  • Added a new method to the TaskDao

HeuristicLab.Services.Hive-3.3:

  • Added NewEventManager.cs
  • Updated HiveJanitor.cs
  • Updated ServiceLocator.cs
File:
1 edited

Legend:

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

    r12691 r12789  
    2727namespace HeuristicLab.Services.Hive.DataAccess.Daos {
    2828  public class TaskDao : GenericDao<Guid, Task> {
     29    private Table<AssignedResource> AssignedResourceTable {
     30      get { return DataContext.GetTable<AssignedResource>(); }
     31    }
     32
    2933    public TaskDao(DataContext dataContext) : base(dataContext) { }
    3034
     
    5155      //we skip this step because it's wasted runtime
    5256      return DataContext.ExecuteQuery<TaskPriorityInfo>(GetWaitingTasksQueryString, slave.ResourceId, Enum.GetName(typeof(TaskState), TaskState.Waiting), slave.FreeCores, slave.FreeMemory).ToList();
     57    }
     58
     59    /// <summary>
     60    /// returns all parent tasks which are waiting for their child tasks to finish
     61    /// </summary>
     62    /// <param name="resourceIds">list of resourceids which for which the task should be valid</param>
     63    /// <param name="count">maximum number of task to return</param>
     64    /// <param name="finished">if true, all parent task which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param>
     65    /// <returns></returns>
     66    public IEnumerable<Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished) {
     67      var query = from ar in AssignedResourceTable
     68                  where resourceIds.Contains(ar.ResourceId)
     69                     && ar.Task.State == TaskState.Waiting
     70                     && ar.Task.IsParentTask
     71                     && (finished ? ar.Task.FinishWhenChildJobsFinished : !ar.Task.FinishWhenChildJobsFinished)
     72                     && (from child in Table
     73                         where child.ParentTaskId == ar.Task.TaskId
     74                         select child.State == TaskState.Finished
     75                             || child.State == TaskState.Aborted
     76                             || child.State == TaskState.Failed).All(x => x)
     77                     && (from child in Table // avoid returning WaitForChildTasks task where no child-task exist (yet)
     78                         where child.ParentTaskId == ar.Task.TaskId
     79                         select child).Any()
     80                  orderby ar.Task.Priority descending
     81                  select ar.Task;
     82      return count == 0 ? query.ToArray() : query.Take(count).ToArray();
    5383    }
    5484
Note: See TracChangeset for help on using the changeset viewer.