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)

File:
1 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    }
Note: See TracChangeset for help on using the changeset viewer.