- Timestamp:
- 04/18/13 16:35:14 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs
r9304 r9381 43 43 } 44 44 45 public Task GetTaskDA(Guid id) { 46 var db = HiveOperationContext.Current.DataContext; 47 return db.Tasks.SingleOrDefault(x => x.TaskId == id); 48 } 49 45 50 public IEnumerable<DT.Task> GetTasks(Expression<Func<Task, bool>> predicate) { 46 51 using (var db = CreateContext()) { … … 138 143 db.SubmitChanges(); 139 144 } 145 } 146 147 public void UpdateTaskDA(Task task) { 148 var db = HiveOperationContext.Current.DataContext; 149 db.SubmitChanges(); 140 150 } 141 151 … … 195 205 } 196 206 207 public IEnumerable<TaskInfoForScheduler> GetWaitingTasksDA(Slave slave) { 208 var db = HiveOperationContext.Current.DataContext; 209 var parentResources = GetParentResourcesDA(slave.ResourceId); 210 var resourceIds = parentResources.Select(x => x.ResourceId); 211 //Originally we checked here if there are parent tasks which should be calculated (with GetParentTasks(resourceIds, count, false);). 212 //Because there is at the moment no case where this makes sense (there don't exist parent tasks which need to be calculated), 213 //we skip this step because it's wasted runtime 214 215 var query = from ar in db.AssignedResources 216 where resourceIds.Contains(ar.ResourceId) 217 && !(ar.Task.IsParentTask && ar.Task.FinishWhenChildJobsFinished) 218 && ar.Task.State == TaskState.Waiting 219 && ar.Task.CoresNeeded <= slave.FreeCores 220 && ar.Task.MemoryNeeded <= slave.FreeMemory 221 select new TaskInfoForScheduler() { TaskId = ar.Task.TaskId, JobId = ar.Task.JobId, Priority = ar.Task.Priority }; 222 var waitingTasks = query.ToArray(); 223 return waitingTasks; 224 } 225 197 226 public DT.Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception) { 198 227 using (var db = CreateContext()) { … … 222 251 return DT.Convert.ToDto(task); 223 252 } 253 } 254 255 public Task UpdateTaskStateDA(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception) { 256 var db = HiveOperationContext.Current.DataContext; 257 258 db.StateLogs.InsertOnSubmit(new StateLog { 259 TaskId = taskId, 260 State = taskState, 261 SlaveId = slaveId, 262 UserId = userId, 263 Exception = exception, 264 DateTime = DateTime.Now 265 }); 266 267 var task = db.Tasks.SingleOrDefault(x => x.TaskId == taskId); 268 task.State = taskState; 269 270 db.SubmitChanges(); 271 272 return task; 224 273 } 225 274 #endregion … … 516 565 } 517 566 567 public Slave GetSlaveDA(Guid id) { 568 var db = HiveOperationContext.Current.DataContext; 569 return db.Resources.OfType<Slave>().SingleOrDefault(x => x.ResourceId == id); 570 } 571 518 572 public IEnumerable<DT.Slave> GetSlaves(Expression<Func<Slave, bool>> predicate) { 519 573 using (var db = CreateContext()) { … … 538 592 db.SubmitChanges(); 539 593 } 594 } 595 596 public void UpdateSlaveDA(Slave slave) { 597 var db = HiveOperationContext.Current.DataContext; 598 db.SubmitChanges(); 540 599 } 541 600 … … 664 723 return resources.Select(r => DT.Convert.ToDto(r)).ToArray(); 665 724 } 725 } 726 727 public IEnumerable<Resource> GetParentResourcesDA(Guid resourceId) { 728 var db = HiveOperationContext.Current.DataContext; 729 var resources = new List<Resource>(); 730 CollectParentResources(resources, db.Resources.Where(r => r.ResourceId == resourceId).Single()); 731 return resources; 666 732 } 667 733
Note: See TracChangeset
for help on using the changeset viewer.