Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
trunk/sources/HeuristicLab.Hive.Server.Core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.