Changeset 3018 for trunk/sources/HeuristicLab.Hive.Server.Core
- Timestamp:
- 03/14/10 12:07:47 (14 years ago)
- 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 103 103 " wasn't offline but hasn't sent heartbeats - setting offline"); 104 104 client.State = State.offline; 105 DaoLocator.ClientDao.Update(client); 105 DaoLocator.ClientDao.Update(client); 106 106 HiveLogger.Info(this.ToString() + ": Client " + client.Id + 107 107 " wasn't offline but hasn't sent heartbeats - Resetting all his jobs"); … … 236 236 /// <returns></returns> 237 237 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"); 255 244 256 245 ResponseHB response = new ResponseHB(); 257 246 response.ActionRequest = new List<MessageContainer>(); 258 247 259 HiveLogger. Info(this.ToString() + ": BEGIN Started Client Fetching");248 HiveLogger.Debug(this.ToString() + ": BEGIN Started Client Fetching"); 260 249 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"); 262 251 // check if the client is logged in 263 252 if (client.State == State.offline || client.State == State.nullState) { … … 275 264 276 265 // save timestamp of this heartbeat 277 HiveLogger. Info(this.ToString() + ": BEGIN Locking for Heartbeats");266 HiveLogger.Debug(this.ToString() + ": BEGIN Locking for Heartbeats"); 278 267 heartbeatLock.EnterWriteLock(); 279 HiveLogger. Info(this.ToString() + ": END Locked for Heartbeats");268 HiveLogger.Debug(this.ToString() + ": END Locked for Heartbeats"); 280 269 if (lastHeartbeats.ContainsKey(hbData.ClientId)) { 281 270 lastHeartbeats[hbData.ClientId] = DateTime.Now; … … 287 276 // check if client has a free core for a new job 288 277 // 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"); 290 279 if (hbData.FreeCores > 0 && scheduler.ExistsJobForClient(hbData)) { 291 280 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchJob)); … … 293 282 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage)); 294 283 } 295 HiveLogger. Info(this.ToString() + ": END Looked for Client Jobs");284 HiveLogger.Debug(this.ToString() + ": END Looked for Client Jobs"); 296 285 response.Success = true; 297 286 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED; 298 287 299 HiveLogger. Info(this.ToString() + ": BEGIN Processing Heartbeat Jobs");288 HiveLogger.Debug(this.ToString() + ": BEGIN Processing Heartbeat Jobs"); 300 289 processJobProcess(hbData, response); 301 HiveLogger. Info(this.ToString() + ": END Processed Heartbeat Jobs");290 HiveLogger.Debug(this.ToString() + ": END Processed Heartbeat Jobs"); 302 291 303 292 DaoLocator.ClientDao.Update(client); 304 293 305 294 //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); 307 296 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 } 319 298 320 299 /// <summary> -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/DefaultScheduler.cs
r3011 r3018 10 10 11 11 namespace HeuristicLab.Hive.Server.Core { 12 class DefaultScheduler: IScheduler { 13 12 internal class DefaultScheduler : IScheduler { 14 13 //private ISessionFactory factory; 15 14 … … 24 23 25 24 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 } 44 30 45 31 public HeuristicLab.Hive.Contracts.BusinessObjects.JobDto GetNextJobForClient(Guid clientId) { 46 /*ISession session = factory.GetSessionForCurrentThread(); 32 /// Critical section /// 33 jobLock.WaitOne(); 47 34 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); 59 36 LinkedList<JobDto> allOfflineJobsForClient = 60 37 new LinkedList<JobDto>(DaoLocator.JobDao.FindFittingJobsForClient(State.offline, client.NrOfFreeCores, 61 client.FreeMemory ));38 client.FreeMemory, client.Id)); 62 39 63 64 65 66 67 68 jobToCalculate.Client.State = State.calculating;69 70 71 72 73 74 75 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 /// 76 53 77 return jobToCalculate; 78 } 79 /*finally { 80 if (session != null) 81 session.EndSession(); 82 } 83 } */ 54 return jobToCalculate; 55 } 84 56 85 57 #endregion -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs
r3011 r3018 184 184 DaoLocator.JobDao.InsertWithAttachedJob(job); 185 185 DaoLocator.PluginInfoDao.InsertPluginDependenciesForJob(job.JobInfo); 186 //jobAdapter.UpdateSerializedJob(job);186 187 187 response.Success = true; 188 188 response.Obj = job.JobInfo;
Note: See TracChangeset
for help on using the changeset viewer.