Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8687


Ignore:
Timestamp:
09/24/12 15:24:24 (12 years ago)
Author:
jkarder
Message:

#1712: initial commit

Location:
branches/HiveTaskScheduler
Files:
5 added
13 edited
16 copied

Legend:

Unmodified
Added
Removed
  • branches/HiveTaskScheduler/HeuristicLab 3.3 Services.sln

    r8646 r8687  
    66    ConfigMerger.exe = ConfigMerger.exe
    77    ..\documentation\License\gpl-3.0.txt = ..\documentation\License\gpl-3.0.txt
    8     HeuristicLab 3.3 Services.vsmdi = HeuristicLab 3.3 Services.vsmdi
    98    LocalTestRun.testrunconfig = LocalTestRun.testrunconfig
    109    PreBuildEvent.cmd = PreBuildEvent.cmd
     
    2423  ProjectSection(WebsiteProperties) = preProject
    2524    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;"
    2726    Debug.AspNetCompiler.VirtualPath = "/Hive-3.3"
    2827    Debug.AspNetCompiler.PhysicalPath = "HeuristicLab.Services.Hive.Web\Hive-3.3\"
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml

    r7916 r8687  
    4242      <Association Name="Resource_Downtime" Member="Downtimes" Storage="_UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="Downtime" />
    4343      <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" />
    4545      <Association Name="Resource_Resource" Member="ParentResource" ThisKey="ParentResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" />
    4646      <Type Name="Slave" InheritanceCode="Slave" IsInheritanceDefault="true">
     
    200200      <Column Name="GrantedUserId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
    201201      <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" />
    203208    </Type>
    204209  </Table>
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml.layout

    r7916 r8687  
    5757      </nestedChildShapes>
    5858    </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">
    6060      <nodes>
    6161        <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />
     
    6363      </nodes>
    6464    </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">
    6666      <nodes>
    6767        <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />
     
    121121      </nestedChildShapes>
    122122    </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">
    124124      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_StateLog" />
    125125      <nodes>
     
    172172      </nodes>
    173173    </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">
    175175      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_Downtime" />
    176176      <nodes>
     
    234234      </nestedChildShapes>
    235235    </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" />
    238238      <nodes>
    239239        <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />
     
    241241      </nodes>
    242242    </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>
    243249  </nestedChildShapes>
    244250</ordesignerObjectsDiagram>
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs

    r7916 r8687  
    8282    partial void UpdateResourcePermission(ResourcePermission instance);
    8383    partial void DeleteResourcePermission(ResourcePermission instance);
     84    partial void InsertUserPriority(UserPriority instance);
     85    partial void UpdateUserPriority(UserPriority instance);
     86    partial void DeleteUserPriority(UserPriority instance);
    8487    #endregion
    8588   
     
    247250      {
    248251        return this.GetTable<ResourcePermission>();
     252      }
     253    }
     254   
     255    public System.Data.Linq.Table<UserPriority> UserPriorities
     256    {
     257      get
     258      {
     259        return this.GetTable<UserPriority>();
    249260      }
    250261    }
     
    10871098    }
    10881099   
    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")]
    10901101    public EntitySet<ResourcePermission> ResourcePermissions
    10911102    {
     
    43594370    }
    43604371   
    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)]
    43624373    public Resource Resource
    43634374    {
     
    44134424    }
    44144425  }
     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  }
    44154488}
    44164489#pragma warning restore 1591
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Initialize Hive Database.sql

    r7916 r8687  
    121121  CONSTRAINT [PK_Lifecycle] PRIMARY KEY ([LifecycleId])
    122122  )
     123CREATE TABLE [UserPriority](
     124  [UserId] UniqueIdentifier NOT NULL,
     125  CONSTRAINT [PK_UserPriority] PRIMARY KEY ([UserId])
     126  )
    123127CREATE TABLE [DeletedJobStatistics](
    124128  [UserId] UniqueIdentifier NOT NULL,
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/Convert.cs

    r7916 r8687  
    527527    }
    528528    #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
    529546  }
    530547}
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj

    r8600 r8687  
    114114    <Compile Include="Convert.cs" />
    115115    <Compile Include="DataTransfer\Command.cs" />
     116    <Compile Include="DataTransfer\UserPriority.cs" />
    116117    <Compile Include="DataTransfer\ResourcePermission.cs" />
    117118    <Compile Include="DataTransfer\Downtime.cs" />
     
    139140    <Compile Include="HiveJanitor.cs" />
    140141    <Compile Include="Interfaces\IHiveDao.cs" />
     142    <Compile Include="Interfaces\ITaskScheduler.cs" />
     143    <Compile Include="Scheduler\RoundRobinTaskScheduler.cs" />
    141144    <Compile Include="Settings.cs" />
    142145    <None Include="app.config" />
     
    196199  </PropertyGroup>
    197200  <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)
    199202set ProjectDir=$(ProjectDir)
    200203set SolutionDir=$(SolutionDir)
     
    202205
    203206call PreBuildEvent.cmd</PreBuildEvent>
    204 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     207    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    205208export ProjectDir=$(ProjectDir)
    206209export SolutionDir=$(SolutionDir)
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/HiveDao.cs

    r7916 r8687  
    112112    }
    113113
    114     public IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave, int count) {
     114    public IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave) {
    115115      using (var db = CreateContext()) {
    116116        var resourceIds = GetParentResources(slave.Id).Select(r => r.Id);
     
    127127                    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)
    128128                    select DT.Convert.ToDto(ar.Task);
    129         var waitingTasks = (count == 0 ? query : query.Take(count)).ToArray();
     129        var waitingTasks = query.ToArray();
    130130        return waitingTasks;
    131131      }
     
    857857    #endregion
    858858
     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
    859867    #region Helpers
    860868    private void CollectChildTasks(HiveDataContext db, Guid parentTaskId, List<Task> collection) {
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r8071 r8687  
    499499    #endregion
    500500
     501    #region Resource Methods
     502    public IEnumerable<Resource> GetChildResources(Guid resourceId) {
     503      return dao.GetChildResources(resourceId);
     504    }
     505    #endregion
     506
    501507    #region Slave Methods
    502508    public int GetNewHeartbeatInterval(Guid slaveId) {
     
    671677    #endregion
    672678
     679    #region UserPriority Methods
     680    public IEnumerable<UserPriority> GetUserPriorities() {
     681      return trans.UseTransaction(() => dao.GetUserPriorities(x => true));
     682    }
     683    #endregion
     684
    673685    #region Helper Methods
    674686    private IEnumerable<Task> GetChildTasks(Guid? parentTaskId, bool recursive, bool includeParent) {
     
    687699    }
    688700    #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
    689710  }
    690711}
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs

    r7916 r8687  
    3434    void UpdateTask(DT.Task dto);
    3535    void DeleteTask(Guid id);
    36     IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave, int count);
     36    IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave);
    3737    IEnumerable<DT.Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished);
    3838    DT.Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception);
     
    151151    List<DT.UserStatistics> GetUserStatistics();
    152152    #endregion
     153
     154    #region UserPriority Methods
     155    IEnumerable<DT.UserPriority> GetUserPriorities(Expression<Func<UserPriority, bool>> predicate);
     156    #endregion
    153157  }
    154158}
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/Interfaces/IServiceLocator.cs

    r8051 r8687  
    3131    Access.IUserManager UserManager { get; }
    3232    HeartbeatManager HeartbeatManager { get; }
     33    ITaskScheduler TaskScheduler { get; }
    3334  }
    3435}
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs

    r7723 r8687  
    3131      get { return ServiceLocator.Instance.HiveDao; }
    3232    }
    33     private IAuthorizationManager auth {
    34       get { return ServiceLocator.Instance.AuthorizationManager; }
     33    private ITaskScheduler taskScheduler {
     34      get { return ServiceLocator.Instance.TaskScheduler; }
    3535    }
    3636
     
    6363        // assign new task
    6464        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()) {
    6767            var job = availableJobs.First();
    6868            if (AssignJob(slave, job))
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r8071 r8687  
    168168    #endregion
    169169
     170    #region Resource Methods
     171    [OperationContract]
     172    IEnumerable<Resource> GetChildResources(Guid resourceId);
     173    #endregion
     174
    170175    #region Slave Methods
    171176    [OperationContract]
     
    238243    [OperationContract]
    239244    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);
    240257    #endregion
    241258  }
  • branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/ServiceLocator.cs

    r8051 r8687  
    8989      }
    9090    }
     91
     92    private ITaskScheduler taskScheduler;
     93    public ITaskScheduler TaskScheduler {
     94      get {
     95        if (taskScheduler == null) taskScheduler = new RoundRobinTaskScheduler();
     96        return taskScheduler;
     97      }
     98    }
    9199  }
    92100}
Note: See TracChangeset for help on using the changeset viewer.