Changeset 15644
- Timestamp:
- 01/23/18 16:04:24 (7 years ago)
- Location:
- branches/HiveProjectManagement
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/TaskDao.cs
r15630 r15644 27 27 namespace HeuristicLab.Services.Hive.DataAccess.Daos { 28 28 public class TaskDao : GenericDao<Guid, Task> { 29 private Table<AssignedTaskResource> AssignedTaskResourceTable {30 get { return DataContext.GetTable<AssignedTaskResource>(); }31 }32 33 29 public TaskDao(DataContext dataContext) : base(dataContext) { } 34 30 … … 59 55 slave.FreeCores, 60 56 slave.FreeMemory).ToList(); 61 }62 63 /// <summary>64 /// returns all parent tasks which are waiting for their child tasks to finish65 /// </summary>66 /// <param name="resourceIds">list of resourceids which for which the task should be valid</param>67 /// <param name="count">maximum number of task to return</param>68 /// <param name="finished">if true, all parent task which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param>69 /// <returns></returns>70 public IEnumerable<Task> GetParentTasks_Old(IEnumerable<Guid> resourceIds, int count, bool finished) {71 var query = from ar in AssignedTaskResourceTable72 where resourceIds.Contains(ar.ResourceId)73 && ar.Task.State == TaskState.Waiting74 && ar.Task.IsParentTask75 && (finished ? ar.Task.FinishWhenChildJobsFinished : !ar.Task.FinishWhenChildJobsFinished)76 && (from child in Table77 where child.ParentTaskId == ar.Task.TaskId78 select child.State == TaskState.Finished79 || child.State == TaskState.Aborted80 || child.State == TaskState.Failed).All(x => x)81 && (from child in Table // avoid returning WaitForChildTasks task where no child-task exist (yet)82 where child.ParentTaskId == ar.Task.TaskId83 select child).Any()84 orderby ar.Task.Priority descending85 select ar.Task;86 return count == 0 ? query.ToArray() : query.Take(count).ToArray();87 57 } 88 58 … … 153 123 AND ajr.ResourceId = rbranch.ResourceId 154 124 "; 155 private const string GetWaitingTasksQueryStringOld = @"156 WITH pr AS (157 SELECT ResourceId, ParentResourceId158 FROM [Resource]159 WHERE ResourceId = {0}160 UNION ALL161 SELECT r.ResourceId, r.ParentResourceId162 FROM [Resource] r JOIN pr ON r.ResourceId = pr.ParentResourceId163 )164 SELECT DISTINCT t.TaskId, t.JobId, t.Priority165 FROM pr JOIN AssignedTaskResource ar ON ar.ResourceId = pr.ResourceId166 JOIN Task t ON t.TaskId = ar.TaskId167 WHERE NOT (t.IsParentTask = 1 AND t.FinishWhenChildJobsFinished = 1)168 AND t.TaskState = {1}169 AND t.CoresNeeded <= {2}170 AND t.MemoryNeeded <= {3}171 ";172 125 173 126 private const string UpdateExecutionTimeQuery = @" -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HeuristicLab.Services.Hive.DataAccess-3.3.csproj
r15630 r15644 106 106 <Compile Include="Daos\AssignedJobResourceDao.cs" /> 107 107 <Compile Include="Daos\AssignedProjectResourceDao.cs" /> 108 <Compile Include="Daos\AssignedTaskResourceDao.cs" />109 108 <Compile Include="Daos\DowntimeDao.cs" /> 110 109 <Compile Include="Daos\GenericDao.cs" /> -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml
r15630 r15644 41 41 <Association Name="Resource_Downtime" Member="Downtimes" Storage="_UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="Downtime" /> 42 42 <Association Name="Resource_StateLog" Member="StateLogs" ThisKey="ResourceId" OtherKey="SlaveId" Type="StateLog" /> 43 <Association Name="Resource_AssignedTaskResource" Member="AssignedTaskResources" ThisKey="ResourceId" OtherKey="ResourceId" Type="AssignedTaskResource" />44 43 <Association Name="Resource_AssignedJobResource" Member="AssignedJobResources" ThisKey="ResourceId" OtherKey="ResourceId" Type="AssignedJobResource" /> 45 44 <Association Name="Resource_Resource" Member="ParentResource" ThisKey="ParentResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" /> … … 80 79 <Association Name="Task_TaskData" Member="JobData" ThisKey="TaskId" OtherKey="TaskId" Type="TaskData" Cardinality="One" /> 81 80 <Association Name="Task_StateLog" Member="StateLogs" ThisKey="TaskId" OtherKey="TaskId" Type="StateLog" /> 82 <Association Name="Task_AssignedTaskResource" Member="AssignedTaskResources" ThisKey="TaskId" OtherKey="TaskId" Type="AssignedTaskResource" />83 81 <Association Name="Task_Task" Member="ParentJob" Storage="_Job1" ThisKey="ParentTaskId" OtherKey="TaskId" Type="Task" IsForeignKey="true" /> 84 82 <Association Name="Job_Task" Member="Job" Storage="_HiveExperiment" ThisKey="JobId" OtherKey="JobId" Type="Job" IsForeignKey="true" /> … … 276 274 </Type> 277 275 </Table> 278 <Table Name="dbo.AssignedTaskResource" Member="AssignedTaskResources">279 <Type Name="AssignedTaskResource">280 <Column Name="ResourceId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />281 <Column Name="TaskId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />282 <Association Name="Task_AssignedTaskResource" Member="Task" ThisKey="TaskId" OtherKey="TaskId" Type="Task" IsForeignKey="true" />283 <Association Name="Resource_AssignedTaskResource" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" />284 </Type>285 </Table>286 276 <Table Name="dbo.AssignedJobResource" Member="AssignedJobResources"> 287 277 <Type Name="AssignedJobResource"> -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml.layout
r15630 r15644 155 155 </nodes> 156 156 </associationConnector> 157 <associationConnector edgePoints="[(6.5 : 2.50564697265625); (3.75 : 2.50564697265625)]" fixedFrom=" Algorithm" fixedTo="Algorithm">157 <associationConnector edgePoints="[(6.5 : 2.50564697265625); (3.75 : 2.50564697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 158 158 <AssociationMoniker Name="/HiveDataContext/Task/Task_StateLog" /> 159 159 <nodes> … … 162 162 </nodes> 163 163 </associationConnector> 164 <associationConnector edgePoints="[(6.125 : 3.37100341796875); (6.5 : 3.37100341796875)]" fixedFrom=" Algorithm" fixedTo="Algorithm">164 <associationConnector edgePoints="[(6.125 : 3.37100341796875); (6.5 : 3.37100341796875)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 165 165 <AssociationMoniker Name="/HiveDataContext/Job/Job_Task" /> 166 166 <nodes> … … 169 169 </nodes> 170 170 </associationConnector> 171 <associationConnector edgePoints="[(4.125 : 4.20274983723958); (3.75 : 4.20274983723958)]" fixedFrom=" Algorithm" fixedTo="Algorithm">171 <associationConnector edgePoints="[(4.125 : 4.20274983723958); (3.75 : 4.20274983723958)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 172 172 <AssociationMoniker Name="/HiveDataContext/Job/Job_JobPermission" /> 173 173 <nodes> … … 279 279 </nodes> 280 280 </associationConnector> 281 <associationConnector edgePoints="[(11.25 : 9.42390055338542); (10.375 : 9.42390055338542); (10.375 : 8); (4 : 8); (4 : 5.15549967447917); (4.80957165625 : 5.15549967447917); (4.80957165625 : 4.78049967447917)]" fixedFrom=" Algorithm" fixedTo="Algorithm">281 <associationConnector edgePoints="[(11.25 : 9.42390055338542); (10.375 : 9.42390055338542); (10.375 : 8); (4 : 8); (4 : 5.15549967447917); (4.80957165625 : 5.15549967447917); (4.80957165625 : 4.78049967447917)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 282 282 <AssociationMoniker Name="/HiveDataContext/Project/Project_Job" /> 283 283 <nodes> 284 284 <classShapeMoniker Id="30778876-b5f6-4a97-9ec7-792011973d75" /> 285 285 <classShapeMoniker Id="e6f840cc-2968-4be1-b234-eef624ccacbb" /> 286 </nodes>287 </associationConnector>288 <classShape Id="72ac5c1b-0fdf-43a1-bbe7-3774893b40af" absoluteBounds="11.25, 4.5, 2, 1.1939925130208327">289 <DataClassMoniker Name="/HiveDataContext/AssignedTaskResource" />290 <nestedChildShapes>291 <elementListCompartment Id="e9acd881-ab35-401c-b4f8-03dafc98422e" absoluteBounds="11.265, 4.96, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />292 </nestedChildShapes>293 </classShape>294 <associationConnector edgePoints="[(8.031252 : 4.1170068359375); (8.031252 : 4.4375); (11.15625 : 4.4375); (11.15625 : 5.09699625651042); (11.25 : 5.09699625651042)]" fixedFrom="NotFixed" fixedTo="NotFixed">295 <AssociationMoniker Name="/HiveDataContext/Task/Task_AssignedTaskResource" />296 <nodes>297 <classShapeMoniker Id="695bfc39-59f3-4e60-8644-f847964bf62c" />298 <classShapeMoniker Id="72ac5c1b-0fdf-43a1-bbe7-3774893b40af" />299 </nodes>300 </associationConnector>301 <associationConnector edgePoints="[(12.25 : 2.9631982421875); (12.25 : 4.5)]" fixedFrom="NotFixed" fixedTo="NotFixed">302 <AssociationMoniker Name="/HiveDataContext/Resource/Resource_AssignedTaskResource" />303 <nodes>304 <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />305 <classShapeMoniker Id="72ac5c1b-0fdf-43a1-bbe7-3774893b40af" />306 286 </nodes> 307 287 </associationConnector> … … 326 306 </nestedChildShapes> 327 307 </classShape> 328 <associationConnector edgePoints="[(1 1.718748 : 2.9631982421875); (11.718748 : 4.375); (11.0625 : 4.375); (11.0625 : 4.79849862825521); (10.875 : 4.79849862825521)]" fixedFrom="NotFixed" fixedTo="NotFixed">308 <associationConnector edgePoints="[(12.25 : 2.9631982421875); (12.25 : 5.09699625651042); (10.875 : 5.09699625651042)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 329 309 <AssociationMoniker Name="/HiveDataContext/Resource/Resource_AssignedJobResource" /> 330 310 <nodes> … … 333 313 </nodes> 334 314 </associationConnector> 335 <associationConnector edgePoints="[(5.498537828125 : 4.78049967447917); (5.498537828125 : 5.14024983723958); (7.41666666666667 : 5.14024983723958 : JumpStart); (7.58333333333333 : 5.14024983723958 : JumpEnd); (8.875 : 5.14024983723958)]" fixedFrom=" Algorithm" fixedTo="Algorithm">315 <associationConnector edgePoints="[(5.498537828125 : 4.78049967447917); (5.498537828125 : 5.14024983723958); (7.41666666666667 : 5.14024983723958 : JumpStart); (7.58333333333333 : 5.14024983723958 : JumpEnd); (8.875 : 5.14024983723958)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 336 316 <AssociationMoniker Name="/HiveDataContext/Job/Job_AssignedJobResource" /> 337 317 <nodes> -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs
r15643 r15644 94 94 partial void UpdateProjectPermission(ProjectPermission instance); 95 95 partial void DeleteProjectPermission(ProjectPermission instance); 96 partial void InsertAssignedTaskResource(AssignedTaskResource instance);97 partial void UpdateAssignedTaskResource(AssignedTaskResource instance);98 partial void DeleteAssignedTaskResource(AssignedTaskResource instance);99 96 partial void InsertAssignedJobResource(AssignedJobResource instance); 100 97 partial void UpdateAssignedJobResource(AssignedJobResource instance); … … 291 288 { 292 289 return this.GetTable<ProjectPermission>(); 293 }294 }295 296 public System.Data.Linq.Table<AssignedTaskResource> AssignedTaskResources297 {298 get299 {300 return this.GetTable<AssignedTaskResource>();301 290 } 302 291 } … … 390 379 } 391 380 392 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteRule="CASCADE" , DeleteOnNull=true)]381 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteRule="CASCADE")] 393 382 public Resource Resource 394 383 { … … 424 413 } 425 414 426 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, DeleteRule="CASCADE" , DeleteOnNull=true)]415 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, DeleteRule="CASCADE")] 427 416 public Project Project 428 417 { … … 938 927 private EntitySet<StateLog> _StateLogs; 939 928 940 private EntitySet<AssignedTaskResource> _AssignedTaskResources;941 942 929 private EntitySet<AssignedJobResource> _AssignedJobResources; 943 930 … … 968 955 this._UptimeCalendars = new EntitySet<Downtime>(new Action<Downtime>(this.attach_UptimeCalendars), new Action<Downtime>(this.detach_UptimeCalendars)); 969 956 this._StateLogs = new EntitySet<StateLog>(new Action<StateLog>(this.attach_StateLogs), new Action<StateLog>(this.detach_StateLogs)); 970 this._AssignedTaskResources = new EntitySet<AssignedTaskResource>(new Action<AssignedTaskResource>(this.attach_AssignedTaskResources), new Action<AssignedTaskResource>(this.detach_AssignedTaskResources));971 957 this._AssignedJobResources = new EntitySet<AssignedJobResource>(new Action<AssignedJobResource>(this.attach_AssignedJobResources), new Action<AssignedJobResource>(this.detach_AssignedJobResources)); 972 958 this._ParentResource = default(EntityRef<Resource>); … … 1098 1084 } 1099 1085 1100 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_AssignedResources", ThisKey="ResourceId", OtherKey="ResourceId" , DeleteRule="CASCADE")]1086 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_AssignedResources", ThisKey="ResourceId", OtherKey="ResourceId")] 1101 1087 public EntitySet<AssignedProjectResource> AssignedProjectResources 1102 1088 { … … 1150 1136 } 1151 1137 1152 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedTaskResource", Storage="_AssignedTaskResources", ThisKey="ResourceId", OtherKey="ResourceId")] 1153 public EntitySet<AssignedTaskResource> AssignedTaskResources 1154 { 1155 get 1156 { 1157 return this._AssignedTaskResources; 1158 } 1159 set 1160 { 1161 this._AssignedTaskResources.Assign(value); 1162 } 1163 } 1164 1165 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_AssignedJobResources", ThisKey="ResourceId", OtherKey="ResourceId", DeleteRule="CASCADE")] 1138 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_AssignedJobResources", ThisKey="ResourceId", OtherKey="ResourceId")] 1166 1139 public EntitySet<AssignedJobResource> AssignedJobResources 1167 1140 { … … 1273 1246 1274 1247 private void detach_StateLogs(StateLog entity) 1275 {1276 this.SendPropertyChanging();1277 entity.Resource = null;1278 }1279 1280 private void attach_AssignedTaskResources(AssignedTaskResource entity)1281 {1282 this.SendPropertyChanging();1283 entity.Resource = this;1284 }1285 1286 private void detach_AssignedTaskResources(AssignedTaskResource entity)1287 1248 { 1288 1249 this.SendPropertyChanging(); … … 1683 1644 private EntitySet<StateLog> _StateLogs; 1684 1645 1685 private EntitySet<AssignedTaskResource> _AssignedTaskResources;1686 1687 1646 private EntityRef<Task> _Job1; 1688 1647 … … 1725 1684 this._JobData = default(EntityRef<TaskData>); 1726 1685 this._StateLogs = new EntitySet<StateLog>(new Action<StateLog>(this.attach_StateLogs), new Action<StateLog>(this.detach_StateLogs)); 1727 this._AssignedTaskResources = new EntitySet<AssignedTaskResource>(new Action<AssignedTaskResource>(this.attach_AssignedTaskResources), new Action<AssignedTaskResource>(this.detach_AssignedTaskResources));1728 1686 this._Job1 = default(EntityRef<Task>); 1729 1687 this._HiveExperiment = default(EntityRef<Job>); … … 2047 2005 } 2048 2006 2049 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Task_AssignedTaskResource", Storage="_AssignedTaskResources", ThisKey="TaskId", OtherKey="TaskId")]2050 public EntitySet<AssignedTaskResource> AssignedTaskResources2051 {2052 get2053 {2054 return this._AssignedTaskResources;2055 }2056 set2057 {2058 this._AssignedTaskResources.Assign(value);2059 }2060 }2061 2062 2007 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Task_Task", Storage="_Job1", ThisKey="ParentTaskId", OtherKey="TaskId", IsForeignKey=true)] 2063 2008 public Task ParentJob … … 2179 2124 2180 2125 private void detach_StateLogs(StateLog entity) 2181 {2182 this.SendPropertyChanging();2183 entity.Task = null;2184 }2185 2186 private void attach_AssignedTaskResources(AssignedTaskResource entity)2187 {2188 this.SendPropertyChanging();2189 entity.Task = this;2190 }2191 2192 private void detach_AssignedTaskResources(AssignedTaskResource entity)2193 2126 { 2194 2127 this.SendPropertyChanging(); … … 2669 2602 } 2670 2603 2671 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_Task", Storage="_Jobs", ThisKey="JobId", OtherKey="JobId" , DeleteRule="CASCADE")]2604 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_Task", Storage="_Jobs", ThisKey="JobId", OtherKey="JobId")] 2672 2605 public EntitySet<Task> Tasks 2673 2606 { … … 2682 2615 } 2683 2616 2684 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperimentPermissions", ThisKey="JobId", OtherKey="JobId" , DeleteRule="CASCADE")]2617 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperimentPermissions", ThisKey="JobId", OtherKey="JobId")] 2685 2618 public EntitySet<JobPermission> JobPermissions 2686 2619 { … … 2695 2628 } 2696 2629 2697 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_AssignedJobResources", ThisKey="JobId", OtherKey="JobId" , DeleteRule="CASCADE")]2630 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_AssignedJobResources", ThisKey="JobId", OtherKey="JobId")] 2698 2631 public EntitySet<AssignedJobResource> AssignedJobResources 2699 2632 { … … 3533 3466 } 3534 3467 3535 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperiment", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true , DeleteRule="CASCADE", DeleteOnNull=true)]3468 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperiment", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true)] 3536 3469 public Job Job 3537 3470 { … … 5833 5766 } 5834 5767 5835 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_AssignedResources", ThisKey="ProjectId", OtherKey="ProjectId" , DeleteRule="CASCADE")]5768 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_AssignedResources", ThisKey="ProjectId", OtherKey="ProjectId")] 5836 5769 public EntitySet<AssignedProjectResource> AssignedProjectResources 5837 5770 { … … 5872 5805 } 5873 5806 5874 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_ProjectPermissions", ThisKey="ProjectId", OtherKey="ProjectId" , DeleteRule="CASCADE")]5807 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_ProjectPermissions", ThisKey="ProjectId", OtherKey="ProjectId")] 5875 5808 public EntitySet<ProjectPermission> ProjectPermissions 5876 5809 { … … 6084 6017 } 6085 6018 6086 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true , DeleteRule="CASCADE", DeleteOnNull=true)]6019 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true)] 6087 6020 public Project Project 6088 6021 { … … 6114 6047 } 6115 6048 this.SendPropertyChanged("Project"); 6116 }6117 }6118 }6119 6120 public event PropertyChangingEventHandler PropertyChanging;6121 6122 public event PropertyChangedEventHandler PropertyChanged;6123 6124 protected virtual void SendPropertyChanging()6125 {6126 if ((this.PropertyChanging != null))6127 {6128 this.PropertyChanging(this, emptyChangingEventArgs);6129 }6130 }6131 6132 protected virtual void SendPropertyChanged(String propertyName)6133 {6134 if ((this.PropertyChanged != null))6135 {6136 this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));6137 }6138 }6139 }6140 6141 [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.AssignedTaskResource")]6142 public partial class AssignedTaskResource : INotifyPropertyChanging, INotifyPropertyChanged6143 {6144 6145 private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);6146 6147 private System.Guid _ResourceId;6148 6149 private System.Guid _TaskId;6150 6151 private EntityRef<Task> _Task;6152 6153 private EntityRef<Resource> _Resource;6154 6155 #region Extensibility Method Definitions6156 partial void OnLoaded();6157 partial void OnValidate(System.Data.Linq.ChangeAction action);6158 partial void OnCreated();6159 partial void OnResourceIdChanging(System.Guid value);6160 partial void OnResourceIdChanged();6161 partial void OnTaskIdChanging(System.Guid value);6162 partial void OnTaskIdChanged();6163 #endregion6164 6165 public AssignedTaskResource()6166 {6167 this._Task = default(EntityRef<Task>);6168 this._Resource = default(EntityRef<Resource>);6169 OnCreated();6170 }6171 6172 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ResourceId", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]6173 public System.Guid ResourceId6174 {6175 get6176 {6177 return this._ResourceId;6178 }6179 set6180 {6181 if ((this._ResourceId != value))6182 {6183 if (this._Resource.HasLoadedOrAssignedValue)6184 {6185 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();6186 }6187 this.OnResourceIdChanging(value);6188 this.SendPropertyChanging();6189 this._ResourceId = value;6190 this.SendPropertyChanged("ResourceId");6191 this.OnResourceIdChanged();6192 }6193 }6194 }6195 6196 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TaskId", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]6197 public System.Guid TaskId6198 {6199 get6200 {6201 return this._TaskId;6202 }6203 set6204 {6205 if ((this._TaskId != value))6206 {6207 if (this._Task.HasLoadedOrAssignedValue)6208 {6209 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();6210 }6211 this.OnTaskIdChanging(value);6212 this.SendPropertyChanging();6213 this._TaskId = value;6214 this.SendPropertyChanged("TaskId");6215 this.OnTaskIdChanged();6216 }6217 }6218 }6219 6220 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Task_AssignedTaskResource", Storage="_Task", ThisKey="TaskId", OtherKey="TaskId", IsForeignKey=true)]6221 public Task Task6222 {6223 get6224 {6225 return this._Task.Entity;6226 }6227 set6228 {6229 Task previousValue = this._Task.Entity;6230 if (((previousValue != value)6231 || (this._Task.HasLoadedOrAssignedValue == false)))6232 {6233 this.SendPropertyChanging();6234 if ((previousValue != null))6235 {6236 this._Task.Entity = null;6237 previousValue.AssignedTaskResources.Remove(this);6238 }6239 this._Task.Entity = value;6240 if ((value != null))6241 {6242 value.AssignedTaskResources.Add(this);6243 this._TaskId = value.TaskId;6244 }6245 else6246 {6247 this._TaskId = default(System.Guid);6248 }6249 this.SendPropertyChanged("Task");6250 }6251 }6252 }6253 6254 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedTaskResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true)]6255 public Resource Resource6256 {6257 get6258 {6259 return this._Resource.Entity;6260 }6261 set6262 {6263 Resource previousValue = this._Resource.Entity;6264 if (((previousValue != value)6265 || (this._Resource.HasLoadedOrAssignedValue == false)))6266 {6267 this.SendPropertyChanging();6268 if ((previousValue != null))6269 {6270 this._Resource.Entity = null;6271 previousValue.AssignedTaskResources.Remove(this);6272 }6273 this._Resource.Entity = value;6274 if ((value != null))6275 {6276 value.AssignedTaskResources.Add(this);6277 this._ResourceId = value.ResourceId;6278 }6279 else6280 {6281 this._ResourceId = default(System.Guid);6282 }6283 this.SendPropertyChanged("Resource");6284 6049 } 6285 6050 } … … 6386 6151 } 6387 6152 6388 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true , DeleteRule="CASCADE", DeleteOnNull=true)]6153 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true)] 6389 6154 public Resource Resource 6390 6155 { … … 6420 6185 } 6421 6186 6422 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_Job", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true , DeleteRule="CASCADE", DeleteOnNull=true)]6187 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_Job", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true)] 6423 6188 public Job Job 6424 6189 { -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Interfaces/IPersistenceManager.cs
r15552 r15644 31 31 32 32 #region Hive daos 33 AssignedTaskResourceDao AssignedTaskResourceDao { get; }34 33 AssignedJobResourceDao AssignedJobResourceDao { get; } 35 34 AssignedProjectResourceDao AssignedProjectResourceDao { get; } -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Manager/PersistenceManager.cs
r15552 r15644 37 37 38 38 #region Hive daos 39 40 private AssignedTaskResourceDao assignedTaskResourceDao;41 public AssignedTaskResourceDao AssignedTaskResourceDao {42 get { return assignedTaskResourceDao ?? (assignedTaskResourceDao = new AssignedTaskResourceDao(dataContext)); }43 }44 39 45 40 private AssignedJobResourceDao assignedJobResourceDao; -
branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
r15643 r15644 69 69 70 70 #region Task Methods 71 72 public Guid AddTask(DT.Task task, DT.TaskData taskData, IEnumerable<Guid> resourceIds) {73 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);74 var pm = PersistenceManager;75 using (new PerformanceLogger("AddTask")) {76 var taskDao = pm.TaskDao;77 var stateLogDao = pm.StateLogDao;78 79 var newTask = task.ToEntity();80 newTask.JobData = taskData.ToEntity();81 newTask.JobData.LastUpdate = DateTime.Now;82 newTask.AssignedTaskResources.AddRange(resourceIds.Select(83 x => new DA.AssignedTaskResource {84 ResourceId = x85 }));86 newTask.State = DA.TaskState.Waiting;87 return pm.UseTransaction(() => {88 taskDao.Save(newTask);89 pm.SubmitChanges();90 stateLogDao.Save(new DA.StateLog {91 State = DA.TaskState.Waiting,92 DateTime = DateTime.Now,93 TaskId = newTask.TaskId,94 UserId = UserManager.CurrentUserId,95 SlaveId = null,96 Exception = null97 });98 pm.SubmitChanges();99 return newTask.TaskId;100 }, false, true);101 }102 }103 71 104 72 public Guid AddTask(DT.Task task, DT.TaskData taskData) { -
branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs
r15641 r15644 212 212 return actions; 213 213 } 214 215 /// <summary>216 /// Update the progress of each task217 /// Checks if all the task sent by heartbeat are supposed to be calculated by this slave218 /// </summary>219 private IEnumerable<MessageContainer> UpdateTasks_Old(IPersistenceManager pm, Heartbeat heartbeat, bool isAllowedToCalculate) {220 var taskDao = pm.TaskDao;221 var assignedResourceDao = pm.AssignedTaskResourceDao;222 var actions = new List<MessageContainer>();223 if (heartbeat.JobProgress == null || !heartbeat.JobProgress.Any())224 return actions;225 226 if (!isAllowedToCalculate && heartbeat.JobProgress.Count != 0) {227 actions.Add(new MessageContainer(MessageContainer.MessageType.PauseAll));228 } else {229 // select all tasks and statelogs with one query230 var taskIds = heartbeat.JobProgress.Select(x => x.Key).ToList();231 var taskInfos = pm.UseTransaction(() =>232 (from task in taskDao.GetAll()233 where taskIds.Contains(task.TaskId)234 let lastStateLog = task.StateLogs.OrderByDescending(x => x.DateTime).FirstOrDefault()235 select new {236 TaskId = task.TaskId,237 Command = task.Command,238 SlaveId = lastStateLog != null ? lastStateLog.SlaveId : default(Guid)239 }).ToList()240 );241 242 // process the jobProgresses243 foreach (var jobProgress in heartbeat.JobProgress) {244 var progress = jobProgress;245 var curTask = taskInfos.SingleOrDefault(x => x.TaskId == progress.Key);246 if (curTask == null) {247 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, progress.Key));248 LogFactory.GetLogger(this.GetType().Namespace).Log("Task on slave " + heartbeat.SlaveId + " does not exist in DB: " + jobProgress.Key);249 } else {250 var slaveId = curTask.SlaveId;251 if (slaveId == Guid.Empty || slaveId != heartbeat.SlaveId) {252 // assigned slave does not match heartbeat253 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, curTask.TaskId));254 LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate task: " + curTask.TaskId);255 } else if (!assignedResourceDao.TaskIsAllowedToBeCalculatedBySlave(curTask.TaskId, heartbeat.SlaveId)) {256 // assigned resources ids of task do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group257 actions.Add(new MessageContainer(MessageContainer.MessageType.PauseTask, curTask.TaskId));258 } else {259 // update task execution time260 pm.UseTransaction(() => {261 taskDao.UpdateExecutionTime(curTask.TaskId, progress.Value.TotalMilliseconds);262 });263 switch (curTask.Command) {264 case DA.Command.Stop:265 actions.Add(new MessageContainer(MessageContainer.MessageType.StopTask, curTask.TaskId));266 break;267 case DA.Command.Pause:268 actions.Add(new MessageContainer(MessageContainer.MessageType.PauseTask, curTask.TaskId));269 break;270 case DA.Command.Abort:271 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, curTask.TaskId));272 break;273 }274 }275 }276 }277 }278 return actions;279 }280 214 } 281 215 } -
branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs
r15630 r15644 31 31 public interface IHiveService { 32 32 #region Task Methods 33 //[OperationContract]34 //Guid AddTask(Task task, TaskData taskData, IEnumerable<Guid> resourceIds);35 33 36 34 [OperationContract]
Note: See TracChangeset
for help on using the changeset viewer.