- Timestamp:
- 02/21/11 17:35:42 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Convert.cs
r5511 r5526 40 40 LastHeartbeat = source.LastHeartbeat, 41 41 State = source.State, 42 StateLog = source.StateLogs.Select(x => Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList() 42 StateLog = source.StateLogs.Select(x => Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList(), 43 IsParentJob = source.IsParentJob, 44 FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished 43 45 }; 44 46 } … … 59 61 target.State = source.State; 60 62 if (target.StateLogs == null) target.StateLogs = new EntitySet<StateLog>(); 61 target.StateLogs.AddRange(source.StateLog.Select(x => Convert.ToEntity(x)).OrderBy(x => x.DateTime)); 63 foreach (DT.StateLog sl in source.StateLog.Where(x => x.Id == Guid.Empty)) { 64 target.StateLogs.Add(Convert.ToEntity(sl)); 65 } 66 67 //target.StateLogs.AddRange(source.StateLog.Select(x => Convert.ToEntity(x)).OrderBy(x => x.DateTime)); 68 target.IsParentJob = source.IsParentJob; 69 target.FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished; 62 70 // RequiredPlugins are added by Dao 63 71 } -
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 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml
r5511 r5526 60 60 <Type Name="Job"> 61 61 <Column Name="JobId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> 62 <Column Name="JobState" Member="State" Type="global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState" DbType="VarChar(30)" CanBeNull="false" /> 63 <Column Name="ExecutionTime" Type="System.String" DbType="VarChar(30)" CanBeNull="true" /> 64 <Column Name="LastHeartbeat" Type="System.DateTime" DbType="DateTime" CanBeNull="true" /> 62 65 <Column Name="ParentJobId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" /> 63 <Column Name="ExecutionTime" Type="System.String" DbType="VarChar(30)" CanBeNull="true" />64 66 <Column Name="Priority" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> 65 67 <Column Name="CoresNeeded" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> 66 68 <Column Name="MemoryNeeded" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> 67 <Column Name=" LastHeartbeat" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />68 <Column Name=" JobState" Member="State" Type="global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState" DbType="VarChar(30)" CanBeNull="false" />69 <Column Name="IsParentJob" Type="System.Boolean" DbType="Bit" CanBeNull="false" /> 70 <Column Name="FinishWhenChildJobsFinished" Type="System.Boolean" DbType="Bit" CanBeNull="false" /> 69 71 <Association Name="Job_AssignedResource" Member="AssignedResources" ThisKey="JobId" OtherKey="JobId" Type="AssignedResource" /> 70 72 <Association Name="Job_RequiredPlugin" Member="RequiredPlugins" ThisKey="JobId" OtherKey="JobId" Type="RequiredPlugin" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml.layout
r5511 r5526 27 27 </nestedChildShapes> 28 28 </classShape> 29 <classShape Id="695bfc39-59f3-4e60-8644-f847964bf62c" absoluteBounds="6.5, 1, 2, 2. 3478011067708335">29 <classShape Id="695bfc39-59f3-4e60-8644-f847964bf62c" absoluteBounds="6.5, 1, 2, 2.7324039713541666"> 30 30 <DataClassMoniker Name="/HiveDataContext/Job" /> 31 31 <nestedChildShapes> 32 <elementListCompartment Id="a6a30e11-03d1-4869-82e6-b733f4ef9974" absoluteBounds="6.5150000000000006, 1.46, 1.9700000000000002, 1.7878011067708333" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />32 <elementListCompartment Id="a6a30e11-03d1-4869-82e6-b733f4ef9974" absoluteBounds="6.5150000000000006, 1.46, 1.9700000000000002, 2.1724039713541665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 33 33 </nestedChildShapes> 34 34 </classShape> … … 76 76 </nodes> 77 77 </associationConnector> 78 <associationConnector edgePoints="[(8.5 : 3. 34780110677083); (8.875 : 3.875)]" fixedFrom="NotFixed" fixedTo="NotFixed">78 <associationConnector edgePoints="[(8.5 : 3.73240397135417); (8.875 : 3.875)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 79 79 <AssociationMoniker Name="/HiveDataContext/Job/Job_AssignedResource" /> 80 80 <nodes> … … 83 83 </nodes> 84 84 </associationConnector> 85 <associationConnector edgePoints="[(7.4687475 : 3. 34780110677083); (7.4687475 : 5.5)]" fixedFrom="Algorithm" fixedTo="Algorithm">85 <associationConnector edgePoints="[(7.4687475 : 3.73240397135417); (7.4687475 : 5.5)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 86 86 <AssociationMoniker Name="/HiveDataContext/Job/Job_RequiredPlugin" /> 87 87 <nodes> … … 104 104 </nodes> 105 105 </associationConnector> 106 <associationConnector edgePoints="[(6.5 : 2.98640055338542); (6.125 : 2.98640055338542)]" fixedFrom="Algorithm" fixedTo="Algorithm">106 <associationConnector edgePoints="[(6.5 : 3.17870198567708); (6.125 : 3.17870198567708)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 107 107 <AssociationMoniker Name="/HiveDataContext/Job/Job_HiveExperiment" /> 108 108 <nodes> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.designer.cs
r5511 r5526 1393 1393 private System.Guid _JobId; 1394 1394 1395 private global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState _State; 1396 1397 private string _ExecutionTime; 1398 1399 private System.Nullable<System.DateTime> _LastHeartbeat; 1400 1395 1401 private System.Nullable<System.Guid> _ParentJobId; 1396 1402 1397 private string _ExecutionTime;1398 1399 1403 private int _Priority; 1400 1404 … … 1403 1407 private int _MemoryNeeded; 1404 1408 1405 private System.Nullable<System.DateTime> _LastHeartbeat;1406 1407 private global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState _State;1409 private bool _IsParentJob; 1410 1411 private bool _FinishWhenChildJobsFinished; 1408 1412 1409 1413 private EntitySet<AssignedResource> _AssignedResources; … … 1425 1429 partial void OnJobIdChanging(System.Guid value); 1426 1430 partial void OnJobIdChanged(); 1431 partial void OnStateChanging(global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState value); 1432 partial void OnStateChanged(); 1433 partial void OnExecutionTimeChanging(string value); 1434 partial void OnExecutionTimeChanged(); 1435 partial void OnLastHeartbeatChanging(System.Nullable<System.DateTime> value); 1436 partial void OnLastHeartbeatChanged(); 1427 1437 partial void OnParentJobIdChanging(System.Nullable<System.Guid> value); 1428 1438 partial void OnParentJobIdChanged(); 1429 partial void OnExecutionTimeChanging(string value);1430 partial void OnExecutionTimeChanged();1431 1439 partial void OnPriorityChanging(int value); 1432 1440 partial void OnPriorityChanged(); … … 1435 1443 partial void OnMemoryNeededChanging(int value); 1436 1444 partial void OnMemoryNeededChanged(); 1437 partial void On LastHeartbeatChanging(System.Nullable<System.DateTime>value);1438 partial void On LastHeartbeatChanged();1439 partial void On StateChanging(global::HeuristicLab.Services.Hive.Common.DataTransfer.JobStatevalue);1440 partial void On StateChanged();1445 partial void OnIsParentJobChanging(bool value); 1446 partial void OnIsParentJobChanged(); 1447 partial void OnFinishWhenChildJobsFinishedChanging(bool value); 1448 partial void OnFinishWhenChildJobsFinishedChanged(); 1441 1449 #endregion 1442 1450 … … 1472 1480 } 1473 1481 1482 [global::System.Data.Linq.Mapping.ColumnAttribute(Name="JobState", Storage="_State", DbType="VarChar(30)", CanBeNull=false)] 1483 public global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState State 1484 { 1485 get 1486 { 1487 return this._State; 1488 } 1489 set 1490 { 1491 if ((this._State != value)) 1492 { 1493 this.OnStateChanging(value); 1494 this.SendPropertyChanging(); 1495 this._State = value; 1496 this.SendPropertyChanged("State"); 1497 this.OnStateChanged(); 1498 } 1499 } 1500 } 1501 1502 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ExecutionTime", DbType="VarChar(30)")] 1503 public string ExecutionTime 1504 { 1505 get 1506 { 1507 return this._ExecutionTime; 1508 } 1509 set 1510 { 1511 if ((this._ExecutionTime != value)) 1512 { 1513 this.OnExecutionTimeChanging(value); 1514 this.SendPropertyChanging(); 1515 this._ExecutionTime = value; 1516 this.SendPropertyChanged("ExecutionTime"); 1517 this.OnExecutionTimeChanged(); 1518 } 1519 } 1520 } 1521 1522 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LastHeartbeat", DbType="DateTime")] 1523 public System.Nullable<System.DateTime> LastHeartbeat 1524 { 1525 get 1526 { 1527 return this._LastHeartbeat; 1528 } 1529 set 1530 { 1531 if ((this._LastHeartbeat != value)) 1532 { 1533 this.OnLastHeartbeatChanging(value); 1534 this.SendPropertyChanging(); 1535 this._LastHeartbeat = value; 1536 this.SendPropertyChanged("LastHeartbeat"); 1537 this.OnLastHeartbeatChanged(); 1538 } 1539 } 1540 } 1541 1474 1542 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ParentJobId", DbType="UniqueIdentifier")] 1475 1543 public System.Nullable<System.Guid> ParentJobId … … 1496 1564 } 1497 1565 1498 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ExecutionTime", DbType="VarChar(30)")]1499 public string ExecutionTime1500 {1501 get1502 {1503 return this._ExecutionTime;1504 }1505 set1506 {1507 if ((this._ExecutionTime != value))1508 {1509 this.OnExecutionTimeChanging(value);1510 this.SendPropertyChanging();1511 this._ExecutionTime = value;1512 this.SendPropertyChanged("ExecutionTime");1513 this.OnExecutionTimeChanged();1514 }1515 }1516 }1517 1518 1566 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Priority", DbType="Int NOT NULL")] 1519 1567 public int Priority … … 1576 1624 } 1577 1625 1578 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ LastHeartbeat", DbType="DateTime")]1579 public System.Nullable<System.DateTime> LastHeartbeat1580 { 1581 get 1582 { 1583 return this._ LastHeartbeat;1584 } 1585 set 1586 { 1587 if ((this._ LastHeartbeat!= value))1588 { 1589 this.On LastHeartbeatChanging(value);1590 this.SendPropertyChanging(); 1591 this._ LastHeartbeat= value;1592 this.SendPropertyChanged(" LastHeartbeat");1593 this.On LastHeartbeatChanged();1594 } 1595 } 1596 } 1597 1598 [global::System.Data.Linq.Mapping.ColumnAttribute( Name="JobState", Storage="_State", DbType="VarChar(30)", CanBeNull=false)]1599 public global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState State1600 { 1601 get 1602 { 1603 return this._ State;1604 } 1605 set 1606 { 1607 if ((this._ State!= value))1608 { 1609 this.On StateChanging(value);1610 this.SendPropertyChanging(); 1611 this._ State= value;1612 this.SendPropertyChanged(" State");1613 this.On StateChanged();1626 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IsParentJob", DbType="Bit")] 1627 public bool IsParentJob 1628 { 1629 get 1630 { 1631 return this._IsParentJob; 1632 } 1633 set 1634 { 1635 if ((this._IsParentJob != value)) 1636 { 1637 this.OnIsParentJobChanging(value); 1638 this.SendPropertyChanging(); 1639 this._IsParentJob = value; 1640 this.SendPropertyChanged("IsParentJob"); 1641 this.OnIsParentJobChanged(); 1642 } 1643 } 1644 } 1645 1646 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FinishWhenChildJobsFinished", DbType="Bit")] 1647 public bool FinishWhenChildJobsFinished 1648 { 1649 get 1650 { 1651 return this._FinishWhenChildJobsFinished; 1652 } 1653 set 1654 { 1655 if ((this._FinishWhenChildJobsFinished != value)) 1656 { 1657 this.OnFinishWhenChildJobsFinishedChanging(value); 1658 this.SendPropertyChanging(); 1659 this._FinishWhenChildJobsFinished = value; 1660 this.SendPropertyChanged("FinishWhenChildJobsFinished"); 1661 this.OnFinishWhenChildJobsFinishedChanged(); 1614 1662 } 1615 1663 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Interfaces/IHiveDao.cs
r5511 r5526 15 15 void DeleteJob(Guid id); 16 16 IEnumerable<DT.Job> GetWaitingJobs(DT.Slave slave, int count); 17 IEnumerable<DT.Job> GetParentJobs(IEnumerable<Guid> resourceIds, int count, bool finished); 17 18 #endregion 18 19 … … 23 24 void UpdateJobData(DT.JobData dto); 24 25 void DeleteJobData(Guid id); 26 #endregion 27 28 #region StateLog Methods 29 DT.StateLog GetStateLog(Guid id); 30 IEnumerable<DT.StateLog> GetStateLogs(Expression<Func<StateLog, bool>> predicate); 31 Guid AddStateLog(DT.StateLog dto); 32 void UpdateStateLog(DT.StateLog dto); 33 void DeleteStateLog(Guid id); 25 34 #endregion 26 35
Note: See TracChangeset
for help on using the changeset viewer.