Changeset 8687
- Timestamp:
- 09/24/12 15:24:24 (12 years ago)
- Location:
- branches/HiveTaskScheduler
- Files:
-
- 5 added
- 13 edited
- 16 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveTaskScheduler/HeuristicLab 3.3 Services.sln
r8646 r8687 6 6 ConfigMerger.exe = ConfigMerger.exe 7 7 ..\documentation\License\gpl-3.0.txt = ..\documentation\License\gpl-3.0.txt 8 HeuristicLab 3.3 Services.vsmdi = HeuristicLab 3.3 Services.vsmdi9 8 LocalTestRun.testrunconfig = LocalTestRun.testrunconfig 10 9 PreBuildEvent.cmd = PreBuildEvent.cmd … … 24 23 ProjectSection(WebsiteProperties) = preProject 25 24 TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0" 26 ProjectReferences = "{CF9DA321-AC1B-4FD3-9EC3-67BC6B861BDE}|HeuristicLab.Services.Hive-3.3.dll;{EC2C8109-6E1E-4C88-9A2B-908CFF2EF4AC}|HeuristicLab.Services.Hive.DataAccess-3.3.dll; "25 ProjectReferences = "{CF9DA321-AC1B-4FD3-9EC3-67BC6B861BDE}|HeuristicLab.Services.Hive-3.3.dll;{EC2C8109-6E1E-4C88-9A2B-908CFF2EF4AC}|HeuristicLab.Services.Hive.DataAccess-3.3.dll;{9FAC0B23-2730-452A-9BA0-D7CA1746C541}|HeuristicLab.Services.Access.dll;{BE9B0229-9150-49A4-AEA6-BB58E055992F}|HeuristicLab.GeoIP.dll;{0F652437-998A-4EAB-8BF1-444B5FE8CE97}|HeuristicLab.Services.Access.DataAccess.dll;" 27 26 Debug.AspNetCompiler.VirtualPath = "/Hive-3.3" 28 27 Debug.AspNetCompiler.PhysicalPath = "HeuristicLab.Services.Hive.Web\Hive-3.3\" -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml
r7916 r8687 42 42 <Association Name="Resource_Downtime" Member="Downtimes" Storage="_UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="Downtime" /> 43 43 <Association Name="Resource_StateLog" Member="StateLogs" ThisKey="ResourceId" OtherKey="SlaveId" Type="StateLog" /> 44 <Association Name="Resource_ SlavePermission" Member="ResourcePermissions" ThisKey="ResourceId" OtherKey="ResourceId" Type="ResourcePermission" />44 <Association Name="Resource_ResourcePermission" Member="ResourcePermissions" ThisKey="ResourceId" OtherKey="ResourceId" Type="ResourcePermission" /> 45 45 <Association Name="Resource_Resource" Member="ParentResource" ThisKey="ParentResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" /> 46 46 <Type Name="Slave" InheritanceCode="Slave" IsInheritanceDefault="true"> … … 200 200 <Column Name="GrantedUserId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" /> 201 201 <Column Name="GrantedByUserId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" CanBeNull="false" /> 202 <Association Name="Resource_SlavePermission" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" /> 202 <Association Name="Resource_ResourcePermission" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" /> 203 </Type> 204 </Table> 205 <Table Name="" Member="UserPriorities"> 206 <Type Name="UserPriority"> 207 <Column Name="UserId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" /> 203 208 </Type> 204 209 </Table> -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml.layout
r7916 r8687 57 57 </nestedChildShapes> 58 58 </classShape> 59 <inheritanceConnector edgePoints="[(11.25 : 1.98159912109375); (10.875 : 1.98159912109375)]" fixedFrom=" Algorithm" fixedTo="Algorithm" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">59 <inheritanceConnector edgePoints="[(11.25 : 1.98159912109375); (10.875 : 1.98159912109375)]" fixedFrom="NotFixed" fixedTo="NotFixed" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62"> 60 60 <nodes> 61 61 <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" /> … … 63 63 </nodes> 64 64 </inheritanceConnector> 65 <inheritanceConnector edgePoints="[(13.25 : 1.40469482421875); (13.5 : 1.40469482421875)]" fixedFrom=" Algorithm" fixedTo="Algorithm" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">65 <inheritanceConnector edgePoints="[(13.25 : 1.40469482421875); (13.5 : 1.40469482421875)]" fixedFrom="NotFixed" fixedTo="NotFixed" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62"> 66 66 <nodes> 67 67 <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" /> … … 121 121 </nestedChildShapes> 122 122 </classShape> 123 <associationConnector edgePoints="[(11.25 : 1. 45954756054688); (10.9375 : 1.45954756054688); (10.9375 : 0.6875); (2.75 : 0.6875); (2.75 : 1)]" fixedFrom="Algorithm" fixedTo="Algorithm">123 <associationConnector edgePoints="[(11.25 : 1.98159912109375); (10.9375 : 1.98159912109375); (10.9375 : 0.6875); (2.75 : 0.6875); (2.75 : 1)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 124 124 <AssociationMoniker Name="/HiveDataContext/Resource/Resource_StateLog" /> 125 125 <nodes> … … 172 172 </nodes> 173 173 </associationConnector> 174 <associationConnector edgePoints="[(13.25 : 2.73159912109375); (13.5 : 2.73159912109375)]" fixedFrom=" Algorithm" fixedTo="Algorithm">174 <associationConnector edgePoints="[(13.25 : 2.73159912109375); (13.5 : 2.73159912109375)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 175 175 <AssociationMoniker Name="/HiveDataContext/Resource/Resource_Downtime" /> 176 176 <nodes> … … 234 234 </nestedChildShapes> 235 235 </classShape> 236 <associationConnector edgePoints="[(12.5942481820367 : 2.9631982421875); (12.5942481820367 : 3.875)]" fixedFrom=" Algorithm" fixedTo="Algorithm">237 <AssociationMoniker Name="/HiveDataContext/Resource/Resource_ SlavePermission" />236 <associationConnector edgePoints="[(12.5942481820367 : 2.9631982421875); (12.5942481820367 : 3.875)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 237 <AssociationMoniker Name="/HiveDataContext/Resource/Resource_ResourcePermission" /> 238 238 <nodes> 239 239 <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" /> … … 241 241 </nodes> 242 242 </associationConnector> 243 <classShape Id="f9e8867f-fd15-4a72-8ca4-4f02cd3f141f" absoluteBounds="4.125, 5.5, 2, 1.0016910807291666"> 244 <DataClassMoniker Name="/HiveDataContext/UserPriority" /> 245 <nestedChildShapes> 246 <elementListCompartment Id="ee41f516-7d9c-4a1d-a1b8-bbe00a6ffea8" absoluteBounds="4.14, 5.96, 1.9700000000000002, 0.44169108072916663" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 247 </nestedChildShapes> 248 </classShape> 243 249 </nestedChildShapes> 244 250 </ordesignerObjectsDiagram> -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs
r7916 r8687 82 82 partial void UpdateResourcePermission(ResourcePermission instance); 83 83 partial void DeleteResourcePermission(ResourcePermission instance); 84 partial void InsertUserPriority(UserPriority instance); 85 partial void UpdateUserPriority(UserPriority instance); 86 partial void DeleteUserPriority(UserPriority instance); 84 87 #endregion 85 88 … … 247 250 { 248 251 return this.GetTable<ResourcePermission>(); 252 } 253 } 254 255 public System.Data.Linq.Table<UserPriority> UserPriorities 256 { 257 get 258 { 259 return this.GetTable<UserPriority>(); 249 260 } 250 261 } … … 1087 1098 } 1088 1099 1089 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_ SlavePermission", Storage="_ResourcePermissions", ThisKey="ResourceId", OtherKey="ResourceId")]1100 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_ResourcePermission", Storage="_ResourcePermissions", ThisKey="ResourceId", OtherKey="ResourceId")] 1090 1101 public EntitySet<ResourcePermission> ResourcePermissions 1091 1102 { … … 4359 4370 } 4360 4371 4361 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_ SlavePermission", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true)]4372 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_ResourcePermission", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true)] 4362 4373 public Resource Resource 4363 4374 { … … 4413 4424 } 4414 4425 } 4426 4427 [global::System.Data.Linq.Mapping.TableAttribute(Name="")] 4428 public partial class UserPriority : INotifyPropertyChanging, INotifyPropertyChanged 4429 { 4430 4431 private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); 4432 4433 private System.Guid _UserId; 4434 4435 #region Extensibility Method Definitions 4436 partial void OnLoaded(); 4437 partial void OnValidate(System.Data.Linq.ChangeAction action); 4438 partial void OnCreated(); 4439 partial void OnUserIdChanging(System.Guid value); 4440 partial void OnUserIdChanged(); 4441 #endregion 4442 4443 public UserPriority() 4444 { 4445 OnCreated(); 4446 } 4447 4448 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)] 4449 public System.Guid UserId 4450 { 4451 get 4452 { 4453 return this._UserId; 4454 } 4455 set 4456 { 4457 if ((this._UserId != value)) 4458 { 4459 this.OnUserIdChanging(value); 4460 this.SendPropertyChanging(); 4461 this._UserId = value; 4462 this.SendPropertyChanged("UserId"); 4463 this.OnUserIdChanged(); 4464 } 4465 } 4466 } 4467 4468 public event PropertyChangingEventHandler PropertyChanging; 4469 4470 public event PropertyChangedEventHandler PropertyChanged; 4471 4472 protected virtual void SendPropertyChanging() 4473 { 4474 if ((this.PropertyChanging != null)) 4475 { 4476 this.PropertyChanging(this, emptyChangingEventArgs); 4477 } 4478 } 4479 4480 protected virtual void SendPropertyChanged(String propertyName) 4481 { 4482 if ((this.PropertyChanged != null)) 4483 { 4484 this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 4485 } 4486 } 4487 } 4415 4488 } 4416 4489 #pragma warning restore 1591 -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Initialize Hive Database.sql
r7916 r8687 121 121 CONSTRAINT [PK_Lifecycle] PRIMARY KEY ([LifecycleId]) 122 122 ) 123 CREATE TABLE [UserPriority]( 124 [UserId] UniqueIdentifier NOT NULL, 125 CONSTRAINT [PK_UserPriority] PRIMARY KEY ([UserId]) 126 ) 123 127 CREATE TABLE [DeletedJobStatistics]( 124 128 [UserId] UniqueIdentifier NOT NULL, -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/Convert.cs
r7916 r8687 527 527 } 528 528 #endregion 529 530 #region UserPriority 531 public static DT.UserPriority ToDto(DB.UserPriority source) { 532 if (source == null) return null; 533 return new DT.UserPriority() { UserId = source.UserId }; 534 } 535 public static DB.UserPriority ToEntity(DT.UserPriority source) { 536 if (source == null) return null; 537 var entity = new DB.UserPriority(); ToEntity(source, entity); 538 return entity; 539 } 540 public static void ToEntity(DT.UserPriority source, DB.UserPriority target) { 541 if ((source != null) && (target != null)) { 542 target.UserId = source.UserId; 543 } 544 } 545 #endregion 529 546 } 530 547 } -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj
r8600 r8687 114 114 <Compile Include="Convert.cs" /> 115 115 <Compile Include="DataTransfer\Command.cs" /> 116 <Compile Include="DataTransfer\UserPriority.cs" /> 116 117 <Compile Include="DataTransfer\ResourcePermission.cs" /> 117 118 <Compile Include="DataTransfer\Downtime.cs" /> … … 139 140 <Compile Include="HiveJanitor.cs" /> 140 141 <Compile Include="Interfaces\IHiveDao.cs" /> 142 <Compile Include="Interfaces\ITaskScheduler.cs" /> 143 <Compile Include="Scheduler\RoundRobinTaskScheduler.cs" /> 141 144 <Compile Include="Settings.cs" /> 142 145 <None Include="app.config" /> … … 196 199 </PropertyGroup> 197 200 <PropertyGroup> 198 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)201 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 199 202 set ProjectDir=$(ProjectDir) 200 203 set SolutionDir=$(SolutionDir) … … 202 205 203 206 call PreBuildEvent.cmd</PreBuildEvent> 204 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">207 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 205 208 export ProjectDir=$(ProjectDir) 206 209 export SolutionDir=$(SolutionDir) -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/HiveDao.cs
r7916 r8687 112 112 } 113 113 114 public IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave , int count) {114 public IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave) { 115 115 using (var db = CreateContext()) { 116 116 var resourceIds = GetParentResources(slave.Id).Select(r => r.Id); … … 127 127 orderby ar.Task.Priority descending, db.Random() // take random task to avoid the race condition that occurs when this method is called concurrently (the same task would be returned) 128 128 select DT.Convert.ToDto(ar.Task); 129 var waitingTasks = (count == 0 ? query : query.Take(count)).ToArray();129 var waitingTasks = query.ToArray(); 130 130 return waitingTasks; 131 131 } … … 857 857 #endregion 858 858 859 #region UserPriority Methods 860 public IEnumerable<DT.UserPriority> GetUserPriorities(Expression<Func<UserPriority, bool>> predicate) { 861 using (var db = CreateContext()) { 862 return db.UserPriorities.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 863 } 864 } 865 #endregion 866 859 867 #region Helpers 860 868 private void CollectChildTasks(HiveDataContext db, Guid parentTaskId, List<Task> collection) { -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/HiveService.cs
r8071 r8687 499 499 #endregion 500 500 501 #region Resource Methods 502 public IEnumerable<Resource> GetChildResources(Guid resourceId) { 503 return dao.GetChildResources(resourceId); 504 } 505 #endregion 506 501 507 #region Slave Methods 502 508 public int GetNewHeartbeatInterval(Guid slaveId) { … … 671 677 #endregion 672 678 679 #region UserPriority Methods 680 public IEnumerable<UserPriority> GetUserPriorities() { 681 return trans.UseTransaction(() => dao.GetUserPriorities(x => true)); 682 } 683 #endregion 684 673 685 #region Helper Methods 674 686 private IEnumerable<Task> GetChildTasks(Guid? parentTaskId, bool recursive, bool includeParent) { … … 687 699 } 688 700 #endregion 701 702 #region Statistics Methods 703 public IEnumerable<Statistics> GetStatistics() { 704 return dao.GetStatistics(x => true); 705 } 706 public IEnumerable<Statistics> GetStatisticsForTimePeriod(DateTime from, DateTime to) { 707 return dao.GetStatistics(x => x.Timestamp >= from && x.Timestamp <= to); 708 } 709 #endregion 689 710 } 690 711 } -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs
r7916 r8687 34 34 void UpdateTask(DT.Task dto); 35 35 void DeleteTask(Guid id); 36 IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave , int count);36 IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave); 37 37 IEnumerable<DT.Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished); 38 38 DT.Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception); … … 151 151 List<DT.UserStatistics> GetUserStatistics(); 152 152 #endregion 153 154 #region UserPriority Methods 155 IEnumerable<DT.UserPriority> GetUserPriorities(Expression<Func<UserPriority, bool>> predicate); 156 #endregion 153 157 } 154 158 } -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/Interfaces/IServiceLocator.cs
r8051 r8687 31 31 Access.IUserManager UserManager { get; } 32 32 HeartbeatManager HeartbeatManager { get; } 33 ITaskScheduler TaskScheduler { get; } 33 34 } 34 35 } -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs
r7723 r8687 31 31 get { return ServiceLocator.Instance.HiveDao; } 32 32 } 33 private I AuthorizationManager auth{34 get { return ServiceLocator.Instance. AuthorizationManager; }33 private ITaskScheduler taskScheduler { 34 get { return ServiceLocator.Instance.TaskScheduler; } 35 35 } 36 36 … … 63 63 // assign new task 64 64 if (heartbeat.AssignJob && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) { 65 var availableJobs = dao.GetWaitingTasks(slave, 1);66 if (availableJobs. Count() > 0) {65 var availableJobs = taskScheduler.Schedule(dao.GetWaitingTasks(slave)); 66 if (availableJobs.Any()) { 67 67 var job = availableJobs.First(); 68 68 if (AssignJob(slave, job)) -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs
r8071 r8687 168 168 #endregion 169 169 170 #region Resource Methods 171 [OperationContract] 172 IEnumerable<Resource> GetChildResources(Guid resourceId); 173 #endregion 174 170 175 #region Slave Methods 171 176 [OperationContract] … … 238 243 [OperationContract] 239 244 Guid GetUserIdByUsername(string username); 245 #endregion 246 247 #region UserPriorities Methods 248 [OperationContract] 249 IEnumerable<UserPriority> GetUserPriorities(); 250 #endregion 251 252 #region Statistics Methods 253 [OperationContract] 254 IEnumerable<Statistics> GetStatistics(); 255 [OperationContract] 256 IEnumerable<Statistics> GetStatisticsForTimePeriod(DateTime from, DateTime to); 240 257 #endregion 241 258 } -
branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/ServiceLocator.cs
r8051 r8687 89 89 } 90 90 } 91 92 private ITaskScheduler taskScheduler; 93 public ITaskScheduler TaskScheduler { 94 get { 95 if (taskScheduler == null) taskScheduler = new RoundRobinTaskScheduler(); 96 return taskScheduler; 97 } 98 } 91 99 } 92 100 }
Note: See TracChangeset
for help on using the changeset viewer.