Changeset 6721 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs
- Timestamp:
- 09/08/11 13:41:25 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs
r6546 r6721 29 29 using HeuristicLab.Common; 30 30 using HeuristicLab.Core; 31 using TS = System.Threading.Tasks; 31 32 32 33 … … 148 149 /// <param name="container">The container, containing the message</param> 149 150 private void DetermineAction(MessageContainer container) { 150 clientCom.LogMessage(string.Format("Message: {0} for job: {1} ", container.Message.ToString(), container. JobId));151 clientCom.LogMessage(string.Format("Message: {0} for job: {1} ", container.Message.ToString(), container.TaskId)); 151 152 152 153 if (container is ExecutorMessageContainer<Guid>) { … … 156 157 switch (container.Message) { 157 158 case MessageContainer.MessageType.CalculateJob: 158 CalculateJobAsync(container. JobId);159 CalculateJobAsync(container.TaskId); 159 160 break; 160 161 case MessageContainer.MessageType.AbortJob: 161 AbortJobAsync(container. JobId);162 AbortJobAsync(container.TaskId); 162 163 break; 163 164 case MessageContainer.MessageType.StopJob: 164 StopJobAsync(container. JobId);165 StopJobAsync(container.TaskId); 165 166 break; 166 167 case MessageContainer.MessageType.PauseJob: 167 PauseJobAsync(container. JobId);168 PauseJobAsync(container.TaskId); 168 169 break; 169 170 case MessageContainer.MessageType.StopAll: … … 195 196 196 197 private void CalculateJobAsync(Guid jobId) { 197 T ask.Factory.StartNew(HandleCalculateJob, jobId)198 TS.Task.Factory.StartNew(HandleCalculateJob, jobId) 198 199 .ContinueWith((t) => { 199 200 SlaveStatusInfo.IncrementExceptionOccured(); … … 203 204 204 205 private void StopJobAsync(Guid jobId) { 205 T ask.Factory.StartNew(HandleStopJob, jobId)206 TS.Task.Factory.StartNew(HandleStopJob, jobId) 206 207 .ContinueWith((t) => { 207 208 SlaveStatusInfo.IncrementExceptionOccured(); … … 211 212 212 213 private void PauseJobAsync(Guid jobId) { 213 T ask.Factory.StartNew(HandlePauseJob, jobId)214 TS.Task.Factory.StartNew(HandlePauseJob, jobId) 214 215 .ContinueWith((t) => { 215 216 SlaveStatusInfo.IncrementExceptionOccured(); … … 219 220 220 221 private void AbortJobAsync(Guid jobId) { 221 T ask.Factory.StartNew(HandleAbortJob, jobId)222 TS.Task.Factory.StartNew(HandleAbortJob, jobId) 222 223 .ContinueWith((t) => { 223 224 SlaveStatusInfo.IncrementExceptionOccured(); … … 228 229 private void HandleCalculateJob(object jobIdObj) { 229 230 Guid jobId = (Guid)jobIdObj; 230 Jobjob = null;231 Task job = null; 231 232 int usedCores = 0; 232 233 try { … … 236 237 if (ConfigManager.GetFreeMemory() < job.MemoryNeeded) throw new OutOfMemoryException(); 237 238 SlaveStatusInfo.IncrementUsedCores(job.CoresNeeded); usedCores = job.CoresNeeded; 238 JobData jobData = wcfService.GetJobData(jobId);239 TaskData jobData = wcfService.GetJobData(jobId); 239 240 if (jobData == null) throw new JobDataNotFoundException(jobId); 240 job = wcfService.UpdateJobState(jobId, JobState.Calculating, null);241 job = wcfService.UpdateJobState(jobId, TaskState.Calculating, null); 241 242 if (job == null) throw new JobNotFoundException(jobId); 242 243 jobManager.StartJobAsync(job, jobData); … … 255 256 } 256 257 catch (OutOfCoresException) { 257 wcfService.UpdateJobState(jobId, JobState.Waiting, "No more cores available");258 wcfService.UpdateJobState(jobId, TaskState.Waiting, "No more cores available"); 258 259 throw; 259 260 } 260 261 catch (OutOfMemoryException) { 261 wcfService.UpdateJobState(jobId, JobState.Waiting, "No more memory available");262 wcfService.UpdateJobState(jobId, TaskState.Waiting, "No more memory available"); 262 263 throw; 263 264 } 264 265 catch (Exception e) { 265 266 SlaveStatusInfo.DecrementUsedCores(usedCores); 266 wcfService.UpdateJobState(jobId, JobState.Waiting, e.ToString()); // unknown internal error - report and set waiting again267 wcfService.UpdateJobState(jobId, TaskState.Waiting, e.ToString()); // unknown internal error - report and set waiting again 267 268 throw; 268 269 } … … 272 273 Guid jobId = (Guid)jobIdObj; 273 274 try { 274 Jobjob = wcfService.GetJob(jobId);275 Task job = wcfService.GetJob(jobId); 275 276 if (job == null) throw new JobNotFoundException(jobId); 276 277 jobManager.StopJobAsync(jobId); … … 290 291 Guid jobId = (Guid)jobIdObj; 291 292 try { 292 Jobjob = wcfService.GetJob(jobId);293 Task job = wcfService.GetJob(jobId); 293 294 if (job == null) throw new JobNotFoundException(jobId); 294 295 jobManager.PauseJobAsync(jobId); … … 318 319 private void RegisterJobManagerEvents() { 319 320 this.jobManager.JobStarted += new EventHandler<EventArgs<SlaveJob>>(jobManager_JobStarted); 320 this.jobManager.JobPaused += new EventHandler<EventArgs<SlaveJob, JobData>>(jobManager_JobPaused);321 this.jobManager.JobStopped += new EventHandler<EventArgs<SlaveJob, JobData>>(jobManager_JobStopped);322 this.jobManager.JobFailed += new EventHandler<EventArgs<Tuple<SlaveJob, JobData, Exception>>>(jobManager_JobFailed);321 this.jobManager.JobPaused += new EventHandler<EventArgs<SlaveJob, TaskData>>(jobManager_JobPaused); 322 this.jobManager.JobStopped += new EventHandler<EventArgs<SlaveJob, TaskData>>(jobManager_JobStopped); 323 this.jobManager.JobFailed += new EventHandler<EventArgs<Tuple<SlaveJob, TaskData, Exception>>>(jobManager_JobFailed); 323 324 this.jobManager.ExceptionOccured += new EventHandler<EventArgs<SlaveJob, Exception>>(jobManager_ExceptionOccured); 324 325 this.jobManager.JobAborted += new EventHandler<EventArgs<SlaveJob>>(jobManager_JobAborted); … … 329 330 } 330 331 331 private void jobManager_JobPaused(object sender, EventArgs<SlaveJob, JobData> e) {332 private void jobManager_JobPaused(object sender, EventArgs<SlaveJob, TaskData> e) { 332 333 try { 333 334 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 334 335 heartbeatManager.AwakeHeartBeatThread(); 335 Jobjob = wcfService.GetJob(e.Value.JobId);336 Task job = wcfService.GetJob(e.Value.JobId); 336 337 if (job == null) throw new JobNotFoundException(e.Value.JobId); 337 338 job.ExecutionTime = e.Value.ExecutionTime; 338 JobData jobData = e.Value.GetJobData();339 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, JobState.Paused);339 TaskData jobData = e.Value.GetJobData(); 340 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, TaskState.Paused); 340 341 } 341 342 catch (JobNotFoundException ex) { … … 347 348 } 348 349 349 private void jobManager_JobStopped(object sender, EventArgs<SlaveJob, JobData> e) {350 private void jobManager_JobStopped(object sender, EventArgs<SlaveJob, TaskData> e) { 350 351 try { 351 352 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 352 353 heartbeatManager.AwakeHeartBeatThread(); 353 Jobjob = wcfService.GetJob(e.Value.JobId);354 Task job = wcfService.GetJob(e.Value.JobId); 354 355 if (job == null) throw new JobNotFoundException(e.Value.JobId); 355 356 job.ExecutionTime = e.Value.ExecutionTime; 356 JobData jobData = e.Value.GetJobData();357 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, JobState.Finished);357 TaskData jobData = e.Value.GetJobData(); 358 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, TaskState.Finished); 358 359 } 359 360 catch (JobNotFoundException ex) { … … 365 366 } 366 367 367 private void jobManager_JobFailed(object sender, EventArgs<Tuple<SlaveJob, JobData, Exception>> e) {368 private void jobManager_JobFailed(object sender, EventArgs<Tuple<SlaveJob, TaskData, Exception>> e) { 368 369 try { 369 370 SlaveStatusInfo.DecrementUsedCores(e.Value.Item1.CoresNeeded); 370 371 heartbeatManager.AwakeHeartBeatThread(); 371 372 SlaveJob slaveJob = e.Value.Item1; 372 JobData jobData = e.Value.Item2;373 TaskData jobData = e.Value.Item2; 373 374 Exception exception = e.Value.Item3; 374 375 375 Jobjob = wcfService.GetJob(slaveJob.JobId);376 Task job = wcfService.GetJob(slaveJob.JobId); 376 377 if (job == null) throw new JobNotFoundException(slaveJob.JobId); 377 378 job.ExecutionTime = slaveJob.ExecutionTime; 378 379 if (jobData != null) { 379 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, JobState.Failed, exception.ToString());380 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, TaskState.Failed, exception.ToString()); 380 381 } else { 381 wcfService.UpdateJobState(job.Id, JobState.Failed, exception.ToString());382 wcfService.UpdateJobState(job.Id, TaskState.Failed, exception.ToString()); 382 383 } 383 384 clientCom.LogMessage(exception.Message); … … 398 399 heartbeatManager.AwakeHeartBeatThread(); 399 400 clientCom.LogMessage(string.Format("Exception occured for job {0}: {1}", e.Value.JobId, e.Value2.ToString())); 400 wcfService.UpdateJobState(e.Value.JobId, JobState.Waiting, e.Value2.ToString());401 wcfService.UpdateJobState(e.Value.JobId, TaskState.Waiting, e.Value2.ToString()); 401 402 } 402 403
Note: See TracChangeset
for help on using the changeset viewer.