Changeset 1272


Ignore:
Timestamp:
03/06/09 14:21:11 (10 years ago)
Author:
msteinbi
Message:

Main structure of Sheduler (including Interface and first minimalistic implementation) (#507)

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Contracts/ApplicationConstants.cs

    r1170 r1272  
    5959    public static string RESPONSE_CLIENT_PERMISSIONOWNER_DOESNT_EXIST = "Client.PermissionOwnerDoesntExist";
    6060
    61     public static string RESPONSE_COMMUNICATOR_HARDBEAT_RECEIVED = "Communicator.HeardbeatReceived";
     61    public static string RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED = "Communicator.HeardbeatReceived";
    6262    public static string RESPONSE_COMMUNICATOR_JOB_PULLED = "Communicator.JobPulled";
    6363    public static string RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED = "Communicator.JobResultReceived";
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs

    r1170 r1272  
    5454    ILifecycleManager lifecycleManager;
    5555    IInternalJobManager jobManager;
     56    IScheduler scheduler;
    5657
    5758    /// <summary>
     
    6768      jobManager = ServiceLocator.GetJobManager() as
    6869        IInternalJobManager;
     70      scheduler = ServiceLocator.GetScheduler();
    6971
    7072      lifecycleManager.RegisterHeartbeat(
     
    187189
    188190      response.Success = true;
    189       response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HARDBEAT_RECEIVED;
    190       List<Job> allOfflineJobs = new List<Job>(jobAdapter.GetJobsByState(State.offline));
    191       if (allOfflineJobs.Count > 0 && hbData.freeCores > 0)
     191      response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED;
     192      if (hbData.freeCores > 0 && scheduler.ExistsJobForClient(hbData))
    192193        response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchJob));
    193194      else
     
    225226    public ResponseJob PullJob(Guid clientId) {
    226227      ResponseJob response = new ResponseJob();
    227      
    228       /// Critical section ///
    229       jobLock.WaitOne();
    230 
    231       LinkedList<Job> allOfflineJobs = new LinkedList<Job>(jobAdapter.GetJobsByState(State.offline));
    232       if (allOfflineJobs != null && allOfflineJobs.Count > 0) {
    233         Job job2Calculate = allOfflineJobs.First.Value;
    234         job2Calculate.State = State.calculating;
    235         job2Calculate.Client = clientAdapter.GetById(clientId);
    236         job2Calculate.Client.State = State.calculating;
    237 
    238         job2Calculate.DateCalculated = DateTime.Now;
     228
     229      Job job2Calculate = scheduler.GetNextJobForClient(clientId);
     230      if (job2Calculate != null) {
    239231        response.Job = job2Calculate;
    240         jobAdapter.Update(job2Calculate);
    241232        response.Success = true;
    242233        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED;
    243234      } else {
    244         response.Success = true;
     235        response.Success = false;
     236        response.Job = null;
    245237        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT;
    246238      }
    247 
    248       jobLock.ReleaseMutex();
    249       /// End Critical section ///
    250 
    251239      return response;
    252240    }
  • trunk/sources/HeuristicLab.Hive.Server.Core/HeuristicLab.Hive.Server.Core.csproj

    r1141 r1272  
    8383    <Compile Include="InternalInterfaces\DataAccess\IUserGroupAdapter.cs" />
    8484    <Compile Include="InternalInterfaces\IInternalJobManager.cs" />
     85    <Compile Include="InternalInterfaces\IScheduler.cs" />
    8586    <Compile Include="JobManager.cs" />
    8687    <Compile Include="LifecycleManager.cs" />
  • trunk/sources/HeuristicLab.Hive.Server.Core/ServiceLocator.cs

    r1099 r1272  
    2525using HeuristicLab.Hive.Contracts.Interfaces;
    2626using HeuristicLab.Hive.Server.Core;
     27using HeuristicLab.Hive.Server.Core.InternalInterfaces;
    2728
    2829/// <summary>
     
    6162  private static IJobResultsAdapter jobResultsAdapter = null;
    6263
     64  private static IScheduler scheduler = null;
     65
    6366
    6467  /// <summary>
     
    239242    return jobResultsAdapter;
    240243  }
     244
     245  /// <summary>
     246  /// Gets the scheduler
     247  /// </summary>
     248  /// <returns></returns>
     249  [MethodImpl(MethodImplOptions.Synchronized)]
     250  public static IScheduler GetScheduler() {
     251    if (scheduler == null) {
     252      scheduler = discoveryService.GetInstances<IScheduler>()[0];
     253    }
     254
     255    return scheduler;
     256  }
    241257}
  • trunk/sources/HeuristicLab.Hive.Server.Scheduler/HeuristicLab.Hive.Server.Scheduler.csproj

    r858 r1272  
    6464  </ItemGroup>
    6565  <ItemGroup>
     66    <Compile Include="DefaultScheduler.cs" />
    6667    <Compile Include="HiveServerSchedulerPlugin.cs" />
    6768    <Compile Include="Properties\AssemblyInfo.cs" />
     
    7273  </ItemGroup>
    7374  <ItemGroup>
     75    <ProjectReference Include="..\HeuristicLab.Hive.Contracts\HeuristicLab.Hive.Contracts.csproj">
     76      <Project>{134F93D7-E7C8-4ECD-9923-7F63259A60D8}</Project>
     77      <Name>HeuristicLab.Hive.Contracts</Name>
     78    </ProjectReference>
     79    <ProjectReference Include="..\HeuristicLab.Hive.Server.Core\HeuristicLab.Hive.Server.Core.csproj">
     80      <Project>{898B31CF-81DC-453B-AEB3-BDF83197A7EE}</Project>
     81      <Name>HeuristicLab.Hive.Server.Core</Name>
     82    </ProjectReference>
    7483    <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
    7584      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
Note: See TracChangeset for help on using the changeset viewer.