Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/14/10 12:07:47 (14 years ago)
Author:
kgrading
Message:

added Priority and resource restricted scheduling (#907)

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

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs

    r3013 r3018  
    103103                              " wasn't offline but hasn't sent heartbeats - setting offline");
    104104              client.State = State.offline;
    105               DaoLocator.ClientDao.Update(client);             
     105              DaoLocator.ClientDao.Update(client);
    106106              HiveLogger.Info(this.ToString() + ": Client " + client.Id +
    107107                              " wasn't offline but hasn't sent heartbeats - Resetting all his jobs");
     
    236236    /// <returns></returns>
    237237    public ResponseHB ProcessHeartBeat(HeartBeatData hbData) {
    238      
    239      /* ISession session = factory.GetSessionForCurrentThread();
    240       ITransaction tx = null;*/
    241 
    242       HiveLogger.Info(this.ToString() + ": BEGIN Processing Heartbeat for Client " + hbData.ClientId);
    243 
    244       //try {
    245         HiveLogger.Info(this.ToString() + ": BEGIN Fetching Adapters");
    246       /*  IClientAdapter clientAdapter =
    247           session.GetDataAdapter<ClientDto, IClientAdapter>();
    248 
    249         IJobAdapter jobAdapter =       
    250           session.GetDataAdapter<JobDto, IJobAdapter>(); */
    251         HiveLogger.Info(this.ToString() + ": END Fetched Adapters");
    252         HiveLogger.Info(this.ToString() + ": BEGIN Starting Transaction");
    253         //tx = session.BeginTransaction();
    254         HiveLogger.Info(this.ToString() + ": END Started Transaction");
     238      HiveLogger.Debug(this.ToString() + ": BEGIN Processing Heartbeat for Client " + hbData.ClientId);
     239      HiveLogger.Debug(this.ToString() + ": BEGIN Fetching Adapters");
     240      HiveLogger.Debug(this.ToString() + ": END Fetched Adapters");
     241      HiveLogger.Debug(this.ToString() + ": BEGIN Starting Transaction");
     242
     243      HiveLogger.Debug(this.ToString() + ": END Started Transaction");
    255244
    256245        ResponseHB response = new ResponseHB();
    257246        response.ActionRequest = new List<MessageContainer>();
    258247
    259         HiveLogger.Info(this.ToString() + ": BEGIN Started Client Fetching");
     248        HiveLogger.Debug(this.ToString() + ": BEGIN Started Client Fetching");
    260249        ClientDto client = DaoLocator.ClientDao.FindById(hbData.ClientId);
    261         HiveLogger.Info(this.ToString() + ": END Finished Client Fetching");
     250        HiveLogger.Debug(this.ToString() + ": END Finished Client Fetching");
    262251        // check if the client is logged in
    263252        if (client.State == State.offline || client.State == State.nullState) {
     
    275264
    276265        // save timestamp of this heartbeat
    277         HiveLogger.Info(this.ToString() + ": BEGIN Locking for Heartbeats");
     266        HiveLogger.Debug(this.ToString() + ": BEGIN Locking for Heartbeats");
    278267        heartbeatLock.EnterWriteLock();
    279         HiveLogger.Info(this.ToString() + ": END Locked for Heartbeats");
     268        HiveLogger.Debug(this.ToString() + ": END Locked for Heartbeats");
    280269        if (lastHeartbeats.ContainsKey(hbData.ClientId)) {
    281270          lastHeartbeats[hbData.ClientId] = DateTime.Now;
     
    287276        // check if client has a free core for a new job
    288277        // if true, ask scheduler for a new job for this client
    289         HiveLogger.Info(this.ToString() + ": BEGIN Looking for Client Jobs");
     278        HiveLogger.Debug(this.ToString() + ": BEGIN Looking for Client Jobs");
    290279        if (hbData.FreeCores > 0 && scheduler.ExistsJobForClient(hbData)) {
    291280          response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchJob));
     
    293282          response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage));
    294283        }
    295         HiveLogger.Info(this.ToString() + ": END Looked for Client Jobs");
     284        HiveLogger.Debug(this.ToString() + ": END Looked for Client Jobs");
    296285        response.Success = true;
    297286        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED;
    298287
    299         HiveLogger.Info(this.ToString() + ": BEGIN Processing Heartbeat Jobs");
     288        HiveLogger.Debug(this.ToString() + ": BEGIN Processing Heartbeat Jobs");
    300289        processJobProcess(hbData, response);
    301         HiveLogger.Info(this.ToString() + ": END Processed Heartbeat Jobs");
     290        HiveLogger.Debug(this.ToString() + ": END Processed Heartbeat Jobs");
    302291       
    303292        DaoLocator.ClientDao.Update(client);
    304293
    305294        //tx.Commit();
    306         HiveLogger.Info(this.ToString() + ": END Processed Heartbeat for Client " + hbData.ClientId);
     295        HiveLogger.Debug(this.ToString() + ": END Processed Heartbeat for Client " + hbData.ClientId);
    307296        return response;
    308       } /*
    309       catch (Exception ex) {
    310         if (tx != null)
    311           tx.Rollback();
    312         throw ex;
    313       }
    314       finally {
    315         if (session != null)
    316           session.EndSession();
    317       }   
    318     }     */
     297      }
    319298
    320299    /// <summary>
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/DefaultScheduler.cs

    r3011 r3018  
    1010
    1111namespace HeuristicLab.Hive.Server.Core {
    12   class DefaultScheduler: IScheduler {
    13 
     12  internal class DefaultScheduler : IScheduler {
    1413    //private ISessionFactory factory;
    1514
     
    2423
    2524    public bool ExistsJobForClient(HeuristicLab.Hive.Contracts.BusinessObjects.HeartBeatData hbData) {
    26       //ISession session = factory.GetSessionForCurrentThread();
    27 
    28       //try {
    29         /*IJobAdapter jobAdapter =
    30           session.GetDataAdapter<JobDto, IJobAdapter>();*/
    31 
    32         List<JobDto> allOfflineJobsForClient = new List<JobDto>(DaoLocator.JobDao.FindFittingJobsForClient(State.offline, hbData.FreeCores, hbData.FreeMemory));
    33           /*jobAdapter.FindJobs(State.offline,
    34           hbData.FreeCores,
    35           hbData.FreeMemory,
    36           hbData.ClientId));*/
    37         return (allOfflineJobsForClient != null && allOfflineJobsForClient.Count > 0);
    38       //}
    39       /*finally {
    40         if (session != null)
    41           session.EndSession();
    42       } */
    43     }   
     25      List<JobDto> allOfflineJobsForClient =
     26        new List<JobDto>(DaoLocator.JobDao.FindFittingJobsForClient(State.offline, hbData.FreeCores, hbData.FreeMemory,
     27                                                                    hbData.ClientId));
     28      return (allOfflineJobsForClient != null && allOfflineJobsForClient.Count > 0);
     29    }
    4430
    4531    public HeuristicLab.Hive.Contracts.BusinessObjects.JobDto GetNextJobForClient(Guid clientId) {
    46       /*ISession session = factory.GetSessionForCurrentThread();
     32      /// Critical section ///
     33      jobLock.WaitOne();
    4734
    48       try {
    49         IJobAdapter jobAdapter =
    50           session.GetDataAdapter<JobDto, IJobAdapter>();
    51 
    52         IClientAdapter clientAdapter =
    53           session.GetDataAdapter<ClientDto, IClientAdapter>();*/
    54 
    55         /// Critical section ///
    56         jobLock.WaitOne();
    57 
    58         ClientDto client = DaoLocator.ClientDao.FindById(clientId);
     35      ClientDto client = DaoLocator.ClientDao.FindById(clientId);
    5936      LinkedList<JobDto> allOfflineJobsForClient =
    6037        new LinkedList<JobDto>(DaoLocator.JobDao.FindFittingJobsForClient(State.offline, client.NrOfFreeCores,
    61                                                                           client.FreeMemory));
     38                                                                          client.FreeMemory, client.Id));
    6239
    63         JobDto jobToCalculate = null;
    64         if (allOfflineJobsForClient != null && allOfflineJobsForClient.Count > 0) {
    65           jobToCalculate = allOfflineJobsForClient.First.Value;
    66           jobToCalculate.State = State.calculating;
    67           jobToCalculate.Client = client;
    68           jobToCalculate.Client.State = State.calculating;         
    69           jobToCalculate.DateCalculated = DateTime.Now;
    70           DaoLocator.JobDao.AssignClientToJob(client.Id, jobToCalculate.Id);
    71           DaoLocator.JobDao.Update(jobToCalculate);
    72           DaoLocator.ClientDao.Update(jobToCalculate.Client);
    73         }
    74         jobLock.ReleaseMutex();
    75         /// End Critical section ///
     40      JobDto jobToCalculate = null;
     41      if (allOfflineJobsForClient != null && allOfflineJobsForClient.Count > 0) {
     42        jobToCalculate = allOfflineJobsForClient.First.Value;
     43        jobToCalculate.State = State.calculating;
     44        jobToCalculate.Client = client;
     45        jobToCalculate.Client.State = State.calculating;
     46        jobToCalculate.DateCalculated = DateTime.Now;
     47        DaoLocator.JobDao.AssignClientToJob(client.Id, jobToCalculate.Id);
     48        DaoLocator.JobDao.Update(jobToCalculate);
     49        DaoLocator.ClientDao.Update(jobToCalculate.Client);
     50      }
     51      jobLock.ReleaseMutex();
     52      /// End Critical section ///
    7653
    77         return jobToCalculate;
    78       }
    79       /*finally {
    80         if (session != null)
    81           session.EndSession();
    82       }
    83     }   */
     54      return jobToCalculate;
     55    }
    8456
    8557    #endregion
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs

    r3011 r3018  
    184184          DaoLocator.JobDao.InsertWithAttachedJob(job);
    185185          DaoLocator.PluginInfoDao.InsertPluginDependenciesForJob(job.JobInfo);
    186           //jobAdapter.UpdateSerializedJob(job);
     186         
    187187          response.Success = true;
    188188          response.Obj = job.JobInfo;
Note: See TracChangeset for help on using the changeset viewer.