Changeset 1500
- Timestamp:
- 04/03/09 12:47:47 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/Client.cs
r1498 r1500 41 41 public int Memory { get; set; } 42 42 [DataMember] 43 public int FreeMemory { get; set; } 44 [DataMember] 43 45 public DateTime Login { get; set; } 44 46 [DataMember] -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs
r1490 r1500 216 216 217 217 ResponseHB response = new ResponseHB(); 218 response.ActionRequest = new List<MessageContainer>(); 219 220 ClientInfo client = clientAdapter.GetById(hbData.ClientId); 218 221 219 222 // check if the client is logged in 220 response.ActionRequest = new List<MessageContainer>(); 221 if (clientAdapter.GetById(hbData.ClientId).State == State.offline || 222 clientAdapter.GetById(hbData.ClientId).State == State.nullState) { 223 if (client.State == State.offline || client.State == State.nullState) { 223 224 response.Success = false; 224 225 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN; … … 226 227 return response; 227 228 } 229 230 client.NrOfFreeCores = hbData.FreeCores; 231 client.FreeMemory = hbData.FreeMemory; 228 232 229 233 // save timestamp of this heartbeat … … 245 249 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage)); 246 250 247 if (hbData.JobProgress != null) { 248 List<Job> jobsOfClient = new List<Job>(jobAdapter.GetActiveJobsOf(clientAdapter.GetById(hbData.ClientId))); 249 if (jobsOfClient == null || jobsOfClient.Count == 0) { 250 response.Success = false; 251 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; 252 return response; 253 } 254 255 foreach (KeyValuePair<Guid, double> jobProgress in hbData.JobProgress) { 256 Job curJob = jobAdapter.GetById(jobProgress.Key); 257 if (curJob.Client == null || curJob.Client.Id != hbData.ClientId) { 258 response.Success = false; 259 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; 260 } else if (curJob.State == State.finished) { 261 // another client has finished this job allready 262 // the client can abort it 263 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id)); 264 } else { 265 // save job progress 266 curJob.Percentage = jobProgress.Value; 267 jobAdapter.Update(curJob); 268 } 269 } 270 } 251 processJobProcess(hbData, jobAdapter, clientAdapter, response); 252 clientAdapter.Update(client); 253 271 254 tx.Commit(); 272 255 return response; … … 280 263 if (session != null) 281 264 session.EndSession(); 265 } 266 } 267 268 /// <summary> 269 /// Process the Job progress sent by a client 270 /// </summary> 271 /// <param name="hbData"></param> 272 /// <param name="jobAdapter"></param> 273 /// <param name="clientAdapter"></param> 274 /// <param name="response"></param> 275 private void processJobProcess(HeartBeatData hbData, IJobAdapter jobAdapter, IClientAdapter clientAdapter, ResponseHB response) { 276 if (hbData.JobProgress != null) { 277 List<Job> jobsOfClient = new List<Job>(jobAdapter.GetActiveJobsOf(clientAdapter.GetById(hbData.ClientId))); 278 if (jobsOfClient == null || jobsOfClient.Count == 0) { 279 response.Success = false; 280 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; 281 return; 282 } 283 284 foreach (KeyValuePair<Guid, double> jobProgress in hbData.JobProgress) { 285 Job curJob = jobAdapter.GetById(jobProgress.Key); 286 if (curJob.Client == null || curJob.Client.Id != hbData.ClientId) { 287 response.Success = false; 288 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; 289 } else if (curJob.State == State.finished) { 290 // another client has finished this job allready 291 // the client can abort it 292 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id)); 293 } else { 294 // save job progress 295 curJob.Percentage = jobProgress.Value; 296 jobAdapter.Update(curJob); 297 } 298 } 282 299 } 283 300 } -
trunk/sources/HeuristicLab.Hive.Server.Scheduler/DefaultScheduler.cs
r1468 r1500 30 30 session.GetDataAdapter<Job, IJobAdapter>(); 31 31 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); 34 34 } 35 35 finally { … … 52 52 jobLock.WaitOne(); 53 53 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 )); 55 56 56 Job job 2Calculate = null;57 if (allOfflineJobs != null && allOfflineJobs.Count > 0) {58 job 2Calculate = allOfflineJobs.First.Value;59 job 2Calculate.State = State.calculating;60 job 2Calculate.Client = clientAdapter.GetById(clientId);61 job 2Calculate.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; 62 63 63 job 2Calculate.DateCalculated = DateTime.Now;64 jobAdapter.Update(job 2Calculate);64 jobToCalculate.DateCalculated = DateTime.Now; 65 jobAdapter.Update(jobToCalculate); 65 66 } 66 67 jobLock.ReleaseMutex(); 67 68 /// End Critical section /// 68 69 69 return job 2Calculate;70 return jobToCalculate; 70 71 } 71 72 finally {
Note: See TracChangeset
for help on using the changeset viewer.