Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/03/09 12:47:47 (16 years ago)
Author:
msteinbi
Message:

Scheduler checks for free cores now (#507)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Scheduler/DefaultScheduler.cs

    r1468 r1500  
    3030          session.GetDataAdapter<Job, IJobAdapter>();
    3131
    32         List<Job> allOfflineJobs = new List<Job>(jobAdapter.GetJobsByState(State.offline));
    33         return (allOfflineJobs.Count > 0);
     32        List<Job> allOfflineJobsForClient = new List<Job>(jobAdapter.FindJobs(State.offline, hbData.FreeCores, hbData.FreeMemory));
     33        return (allOfflineJobsForClient != null && allOfflineJobsForClient.Count > 0);
    3434      }
    3535      finally {
     
    5252        jobLock.WaitOne();
    5353
    54         LinkedList<Job> allOfflineJobs = new LinkedList<Job>(jobAdapter.GetJobsByState(State.offline));
     54        ClientInfo client = clientAdapter.GetById(clientId);
     55        LinkedList<Job> allOfflineJobsForClient = new LinkedList<Job>(jobAdapter.FindJobs(State.offline, client.NrOfFreeCores, client.FreeMemory ));
    5556
    56         Job job2Calculate = null;
    57         if (allOfflineJobs != null && allOfflineJobs.Count > 0) {
    58           job2Calculate = allOfflineJobs.First.Value;
    59           job2Calculate.State = State.calculating;
    60           job2Calculate.Client = clientAdapter.GetById(clientId);
    61           job2Calculate.Client.State = State.calculating;
     57        Job jobToCalculate = null;
     58        if (allOfflineJobsForClient != null && allOfflineJobsForClient.Count > 0) {
     59          jobToCalculate = allOfflineJobsForClient.First.Value;
     60          jobToCalculate.State = State.calculating;
     61          jobToCalculate.Client = client;
     62          jobToCalculate.Client.State = State.calculating;
    6263
    63           job2Calculate.DateCalculated = DateTime.Now;
    64           jobAdapter.Update(job2Calculate);
     64          jobToCalculate.DateCalculated = DateTime.Now;
     65          jobAdapter.Update(jobToCalculate);
    6566        }
    6667        jobLock.ReleaseMutex();
    6768        /// End Critical section ///
    6869
    69         return job2Calculate;
     70        return jobToCalculate;
    7071      }
    7172      finally {
Note: See TracChangeset for help on using the changeset viewer.