Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/01/11 15:51:11 (14 years ago)
Author:
cneumuel
Message:

#1233

  • changed the workflow of aquireing a new job from server.
    • if a job is available for calculation, the slave receives the jobId already with the heartbeats. The job is then exclusively assigned to this slave.
  • extended the metainfo for a slave by OperatingSystem and CpuArchitecture
  • enhanced the way plugin-dependencies are discovered by using the types used by XmlGenerator. Now only mimimum amount of plugins are transferred.
  • selection of waiting jobs now consideres assigned slave-group
  • more unit tests for service
  • added unit tests for experiment manager
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Convert.cs

    r5402 r5404  
    143143    public static DT.Slave ToDto(Slave source) {
    144144      if (source == null) return null;
    145       return new DT.Slave { Id = source.ResourceId, ParentResourceId = source.ParentResourceId, Cores = source.Cores, CpuSpeed = source.CpuSpeed, FreeCores = source.FreeCores, FreeMemory = source.FreeMemory, IsAllowedToCalculate = source.IsAllowedToCalculate, Memory = source.Memory, Name = source.Name, SlaveState = source.SlaveState };
     145      return new DT.Slave { Id = source.ResourceId, ParentResourceId = source.ParentResourceId, Cores = source.Cores, CpuSpeed = source.CpuSpeed, FreeCores = source.FreeCores, FreeMemory = source.FreeMemory, IsAllowedToCalculate = source.IsAllowedToCalculate, Memory = source.Memory, Name = source.Name, SlaveState = source.SlaveState, CpuArchitecture = source.CpuArchitecture, OperatingSystem = source.OperatingSystem };
    146146    }
    147147    public static Slave ToEntity(DT.Slave source) {
     
    152152    public static void ToEntity(DT.Slave source, Slave target) {
    153153      if ((source != null) && (target != null)) {
    154         target.ResourceId = source.Id; target.ParentResourceId = source.ParentResourceId; target.Cores = source.Cores; target.CpuSpeed = source.CpuSpeed; target.FreeCores = source.FreeCores; target.FreeMemory = source.FreeMemory; target.IsAllowedToCalculate = source.IsAllowedToCalculate; target.Memory = source.Memory; target.Name = source.Name; target.SlaveState = source.SlaveState;
     154        target.ResourceId = source.Id; target.ParentResourceId = source.ParentResourceId; target.Cores = source.Cores; target.CpuSpeed = source.CpuSpeed; target.FreeCores = source.FreeCores; target.FreeMemory = source.FreeMemory; target.IsAllowedToCalculate = source.IsAllowedToCalculate; target.Memory = source.Memory; target.Name = source.Name; target.SlaveState = source.SlaveState; target.CpuArchitecture = source.CpuArchitecture; target.OperatingSystem = source.OperatingSystem;
    155155      }
    156156    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HeuristicLab.Services.Hive.DataAccess-3.4.csproj

    r5402 r5404  
    103103    <Compile Include="Convert.cs" />
    104104    <None Include="HeuristicLabServicesHiveDataAccessPlugin.cs.frame" />
     105    <Compile Include="Exceptions\DaoException.cs" />
    105106    <Compile Include="HeuristicLabServicesHiveDataAccessPlugin.cs" />
    106107    <Compile Include="HiveDao.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs

    r5402 r5404  
    8282    }
    8383
    84     public IEnumerable<DT.Job> GetWaitingParentJobs(Guid slaveId) {
    85       using (var db = CreateContext()) {
    86         // todo: slaveId is unused!
     84    public IEnumerable<DT.Job> GetWaitingParentJobs(IEnumerable<Guid> resourceIds, int count) {
     85      using (var db = CreateContext()) {
    8786        var query = from ar in db.AssignedResources
    88                     where ar.Job.JobState == JobState.WaitingForChildJobs &&
    89                       (from child in db.Jobs
    90                        where child.ParentJobId == ar.Job.JobId
    91                        select child.JobState == JobState.Finished).All(x => x) &&
    92                       (from child in db.Jobs // avoid returning WaitForChildJobs jobs where no child-jobs exist (yet)
    93                        where child.ParentJobId == ar.Job.JobId
    94                        select child).Count() > 0
     87                    where resourceIds.Contains(ar.ResourceId)
     88                       && ar.Job.JobState == JobState.WaitingForChildJobs
     89                       && (from child in db.Jobs
     90                           where child.ParentJobId == ar.Job.JobId
     91                           select child.JobState == JobState.Finished).All(x => x)
     92                       && (from child in db.Jobs // avoid returning WaitForChildJobs jobs where no child-jobs exist (yet)
     93                           where child.ParentJobId == ar.Job.JobId
     94                           select child).Count() > 0
    9595                    orderby ar.Job.Priority descending
    9696                    select Convert.ToDto(ar.Job);
    97         return query.ToArray();
    98       }
    99     }
    100 
    101     public IEnumerable<DT.Job> GetWaitingJobs(DT.Slave slave) {
    102       using (var db = CreateContext()) {
    103         var query = from j in db.Jobs
    104                     where j.JobState == JobState.Waiting && j.CoresNeeded <= slave.FreeCores && j.MemoryNeeded <= slave.FreeMemory
    105                     orderby j.Priority descending
    106                     select Convert.ToDto(j);
    107         var waitingJobs = query.ToArray();
    108         var waitingParentJobs = GetWaitingParentJobs(slave.Id);
     97        return count == 0 ? query.ToArray() : query.Take(count).ToArray();
     98      }
     99    }
     100
     101    public IEnumerable<DT.Job> GetWaitingJobs(DT.Slave slave, int count) {
     102      using (var db = CreateContext()) {
     103        var resourceIds = GetParentResources(slave.Id).Select(r => r.Id);
     104        var waitingParentJobs = GetWaitingParentJobs(resourceIds, count);
     105        if (count > 0 && waitingParentJobs.Count() >= count) return waitingParentJobs.Take(count).ToArray();
     106
     107        var query = from ar in db.AssignedResources
     108                    where resourceIds.Contains(ar.ResourceId)
     109                       && ar.Job.JobState == JobState.Waiting
     110                       && ar.Job.CoresNeeded <= slave.FreeCores
     111                       && ar.Job.MemoryNeeded <= slave.FreeMemory
     112                    orderby ar.Job.Priority descending
     113                    select Convert.ToDto(ar.Job);
     114        var waitingJobs = (count == 0 ? query : query.Take(count)).ToArray();
    109115        return waitingJobs.Union(waitingParentJobs).OrderByDescending(x => x.Priority);
    110116      }
     
    350356      using (var db = CreateContext()) {
    351357        var entity = db.Resources.OfType<SlaveGroup>().FirstOrDefault(x => x.ResourceId == id);
    352         if (entity != null) db.Resources.DeleteOnSubmit(entity);
     358        if (entity != null) {
     359          if (db.Resources.Where(r => r.ParentResourceId == id).Count() > 0) {
     360            throw new DaoException("Cannot delete SlaveGroup as long as there are Slaves in the group");
     361          }
     362          db.Resources.DeleteOnSubmit(entity);
     363        }
    353364        db.SubmitChanges();
    354365      }
     
    408419        return job.AssignedResources.Select(x => Convert.ToDto(x.Resource)).ToArray();
    409420      }
     421    }
     422
     423    /// <summary>
     424    /// Returns all parent resources of a resource (the given resource is also added)
     425    /// </summary>
     426    private IEnumerable<DT.Resource> GetParentResources(Guid resourceId) {
     427      using (var db = CreateContext()) {
     428        var resources = new List<Resource>();
     429        CollectParentResources(resources, db.Resources.Where(r => r.ResourceId == resourceId).Single());
     430        return resources.Select(r => Convert.ToDto(r)).ToArray();
     431      }
     432    }
     433
     434    private void CollectParentResources(List<Resource> resources, Resource resource) {
     435      if (resource == null) return;
     436      resources.Add(resource);
     437      CollectParentResources(resources, resource.ParentResource);
    410438    }
    411439    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml

    r5402 r5404  
    4949        <Column Name="FreeMemory" Type="System.Int32" DbType="Int" CanBeNull="true" />
    5050        <Column Name="IsAllowedToCalculate" Type="System.Boolean" DbType="Bit" CanBeNull="false" />
     51        <Column Name="CpuArchitecture" Type="global::HeuristicLab.Services.Hive.Common.DataTransfer.CpuArchitecture" DbType="VarChar(3)" CanBeNull="false" />
     52        <Column Name="OperatingSystem" Type="System.String" DbType="VarChar(MAX)" CanBeNull="false" />
    5153        <Association Name="Slave_Job" Member="Jobs" ThisKey="ResourceId" OtherKey="SlaveId" Type="Job" />
    5254      </Type>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml.layout

    r5402 r5404  
    4545      </nestedChildShapes>
    4646    </classShape>
    47     <classShape Id="26f4edfa-91dd-4941-a058-359f89e567a8" absoluteBounds="8.875, 1, 2, 2.3478011067708335">
     47    <classShape Id="26f4edfa-91dd-4941-a058-359f89e567a8" absoluteBounds="8.875, 1, 2, 2.7324039713541666">
    4848      <DataClassMoniker Name="/HiveDataContext/Slave" />
    4949      <nestedChildShapes>
    50         <elementListCompartment Id="1e61f36b-08dc-4df7-8594-c9dcd95c0791" absoluteBounds="8.89, 1.46, 1.9700000000000002, 1.7878011067708333" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     50        <elementListCompartment Id="1e61f36b-08dc-4df7-8594-c9dcd95c0791" absoluteBounds="8.89, 1.46, 1.9700000000000002, 2.1724039713541665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    5151      </nestedChildShapes>
    5252    </classShape>
     
    6969      </nodes>
    7070    </inheritanceConnector>
    71     <associationConnector edgePoints="[(12.25 : 2.57859537760417); (12.25 : 4.44314697265625); (10.875 : 4.44314697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     71    <associationConnector edgePoints="[(11.9843735 : 2.57859537760417); (11.9843735 : 4.44314697265625); (10.875 : 4.44314697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    7272      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_AssignedResource" />
    7373      <nodes>
     
    9797      </nodes>
    9898    </associationConnector>
    99     <associationConnector edgePoints="[(8.875 : 2.17390055338542); (8.5 : 2.17390055338542)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     99    <associationConnector edgePoints="[(8.875 : 2.36620198567708); (8.5 : 2.36620198567708)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    100100      <AssociationMoniker Name="/HiveDataContext/Slave/Slave_Job" />
    101101      <nodes>
     
    130130      </nestedChildShapes>
    131131    </classShape>
    132     <associationConnector edgePoints="[(11 : 6.28929768880208); (11.625 : 6.28929768880208)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     132    <associationConnector edgePoints="[(11 : 6.28929768880208); (11.625 : 6.28929768880208)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    133133      <AssociationMoniker Name="/HiveDataContext/Plugin/Plugin_PluginData" />
    134134      <nodes>
     
    144144      </nodes>
    145145    </associationConnector>
    146     <associationConnector edgePoints="[(9 : 6.19314697265625); (8.5 : 6.19314697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     146    <associationConnector edgePoints="[(9 : 6.19314697265625); (8.5 : 6.19314697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    147147      <AssociationMoniker Name="/HiveDataContext/Plugin/Plugin_RequiredPlugin" />
    148148      <nodes>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.designer.cs

    r5402 r5404  
    33// <auto-generated>
    44//     This code was generated by a tool.
    5 //     Runtime Version:4.0.30319.1
     5//     Runtime Version:4.0.30319.208
    66//
    77//     Changes to this file may cause incorrect behavior and will be lost if
     
    10601060    private bool _IsAllowedToCalculate;
    10611061   
     1062    private global::HeuristicLab.Services.Hive.Common.DataTransfer.CpuArchitecture _CpuArchitecture;
     1063   
     1064    private string _OperatingSystem;
     1065   
    10621066    private EntitySet<Job> _Jobs;
    10631067   
     
    10821086    partial void OnIsAllowedToCalculateChanging(bool value);
    10831087    partial void OnIsAllowedToCalculateChanged();
     1088    partial void OnCpuArchitectureChanging(global::HeuristicLab.Services.Hive.Common.DataTransfer.CpuArchitecture value);
     1089    partial void OnCpuArchitectureChanged();
     1090    partial void OnOperatingSystemChanging(string value);
     1091    partial void OnOperatingSystemChanged();
    10841092    #endregion
    10851093   
     
    12461254          this.SendPropertyChanged("IsAllowedToCalculate");
    12471255          this.OnIsAllowedToCalculateChanged();
     1256        }
     1257      }
     1258    }
     1259   
     1260    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CpuArchitecture", DbType="VarChar(3)", CanBeNull=false)]
     1261    public global::HeuristicLab.Services.Hive.Common.DataTransfer.CpuArchitecture CpuArchitecture
     1262    {
     1263      get
     1264      {
     1265        return this._CpuArchitecture;
     1266      }
     1267      set
     1268      {
     1269        if ((this._CpuArchitecture != value))
     1270        {
     1271          this.OnCpuArchitectureChanging(value);
     1272          this.SendPropertyChanging();
     1273          this._CpuArchitecture = value;
     1274          this.SendPropertyChanged("CpuArchitecture");
     1275          this.OnCpuArchitectureChanged();
     1276        }
     1277      }
     1278    }
     1279   
     1280    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OperatingSystem", DbType="VarChar(MAX)", CanBeNull=false)]
     1281    public string OperatingSystem
     1282    {
     1283      get
     1284      {
     1285        return this._OperatingSystem;
     1286      }
     1287      set
     1288      {
     1289        if ((this._OperatingSystem != value))
     1290        {
     1291          this.OnOperatingSystemChanging(value);
     1292          this.SendPropertyChanging();
     1293          this._OperatingSystem = value;
     1294          this.SendPropertyChanged("OperatingSystem");
     1295          this.OnOperatingSystemChanged();
    12481296        }
    12491297      }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Interfaces/IHiveDao.cs

    r5155 r5404  
    1515    void UpdateJob(DT.Job dto);
    1616    void DeleteJob(Guid id);
    17     IEnumerable<DT.Job> GetWaitingJobs(DT.Slave slave);
     17    IEnumerable<DT.Job> GetWaitingJobs(DT.Slave slave, int count);
    1818    #endregion
    1919
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Tools/prepareHiveDatabase.sql

    r5402 r5404  
    4040ALTER TABLE dbo.Job ALTER COLUMN JobId ADD ROWGUIDCOL;
    4141ALTER TABLE dbo.Job WITH NOCHECK ADD CONSTRAINT [DF_Job_JobId] DEFAULT (newid()) FOR JobId;
     42
     43--ALTER TABLE [dbo].[Job]  DROP  CONSTRAINT [Slave_Job]
     44--ALTER TABLE [dbo].[Job]  WITH CHECK ADD  CONSTRAINT [Slave_Job] FOREIGN KEY([ResourceId])
     45--REFERENCES [dbo].[Resource] ([ResourceId])
     46--ON UPDATE CASCADE
     47--ON DELETE SET NULL
     48--GO
    4249
    4350ALTER TABLE dbo.Plugin ALTER COLUMN PluginId ADD ROWGUIDCOL;
Note: See TracChangeset for help on using the changeset viewer.