Changeset 5526 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs
- Timestamp:
- 02/21/11 17:35:42 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs
r5511 r5526 82 82 } 83 83 84 public IEnumerable<DT.Job> GetWaitingParentJobs(IEnumerable<Guid> resourceIds, int count) { 84 /// <summary> 85 /// returns all parent jobs which are waiting for their child jobs to finish 86 /// </summary> 87 /// <param name="resourceIds">list of resourceids which for which the jobs should be valid</param> 88 /// <param name="count">maximum number of jobs to return</param> 89 /// <param name="finished">if true, all parent jobs which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param> 90 /// <returns></returns> 91 public IEnumerable<DT.Job> GetParentJobs(IEnumerable<Guid> resourceIds, int count, bool finished) { 85 92 using (var db = CreateContext()) { 86 93 var query = from ar in db.AssignedResources 87 join sl in db.StateLogs on ar.JobId equals sl.JobId88 94 where resourceIds.Contains(ar.ResourceId) 89 && ar.Job.State == JobState.FinishOnChildJobsFinished 95 && ar.Job.State == JobState.Waiting 96 && ar.Job.IsParentJob 97 && (finished ? ar.Job.FinishWhenChildJobsFinished : !ar.Job.FinishWhenChildJobsFinished) 90 98 && (from child in db.Jobs 91 99 where child.ParentJobId == ar.Job.JobId … … 103 111 using (var db = CreateContext()) { 104 112 var resourceIds = GetParentResources(slave.Id).Select(r => r.Id); 105 var waitingParentJobs = Get WaitingParentJobs(resourceIds, count);113 var waitingParentJobs = GetParentJobs(resourceIds, count, false); 106 114 if (count > 0 && waitingParentJobs.Count() >= count) return waitingParentJobs.Take(count).ToArray(); 107 115 108 116 var query = from ar in db.AssignedResources 109 117 where resourceIds.Contains(ar.ResourceId) 118 && !(ar.Job.IsParentJob && ar.Job.FinishWhenChildJobsFinished) 110 119 && ar.Job.State == JobState.Waiting 111 120 && ar.Job.CoresNeeded <= slave.FreeCores … … 160 169 #endregion 161 170 171 #region StateLog Methods 172 173 public DT.StateLog GetStateLog(Guid id) { 174 using (var db = CreateContext()) { 175 return Convert.ToDto(db.StateLogs.SingleOrDefault(x => x.StateLogId == id)); 176 } 177 } 178 179 public IEnumerable<DT.StateLog> GetStateLogs(Expression<Func<StateLog, bool>> predicate) { 180 using (var db = CreateContext()) { 181 return db.StateLogs.Where(predicate).Select(x => Convert.ToDto(x)).ToArray(); 182 } 183 } 184 185 public Guid AddStateLog(DT.StateLog dto) { 186 using (var db = CreateContext()) { 187 var entity = Convert.ToEntity(dto); 188 db.StateLogs.InsertOnSubmit(entity); 189 db.SubmitChanges(); 190 return entity.StateLogId; 191 } 192 } 193 194 public void UpdateStateLog(DT.StateLog dto) { 195 using (var db = CreateContext()) { 196 var entity = db.StateLogs.FirstOrDefault(x => x.StateLogId == dto.Id); 197 if (entity == null) db.StateLogs.InsertOnSubmit(Convert.ToEntity(dto)); 198 else Convert.ToEntity(dto, entity); 199 db.SubmitChanges(); 200 } 201 } 202 203 public void DeleteStateLog(Guid id) { 204 using (var db = CreateContext()) { 205 var entity = db.StateLogs.FirstOrDefault(x => x.StateLogId == id); 206 if (entity != null) db.StateLogs.DeleteOnSubmit(entity); 207 db.SubmitChanges(); 208 } 209 } 210 #endregion 211 162 212 #region HiveExperiment Methods 163 213 public DT.HiveExperiment GetHiveExperiment(Guid id) { … … 507 557 508 558 #endregion 559 509 560 } 510 561 }
Note: See TracChangeset
for help on using the changeset viewer.