- Timestamp:
- 07/21/15 11:48:49 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/TaskDao.cs
r12691 r12789 27 27 namespace HeuristicLab.Services.Hive.DataAccess.Daos { 28 28 public class TaskDao : GenericDao<Guid, Task> { 29 private Table<AssignedResource> AssignedResourceTable { 30 get { return DataContext.GetTable<AssignedResource>(); } 31 } 32 29 33 public TaskDao(DataContext dataContext) : base(dataContext) { } 30 34 … … 51 55 //we skip this step because it's wasted runtime 52 56 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(); 53 83 } 54 84
Note: See TracChangeset
for help on using the changeset viewer.