Changeset 2082 for trunk/sources/HeuristicLab.Hive.Server.Core/3.2
- Timestamp:
- 06/23/09 11:35:41 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Hive.Server.Core/3.2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs
r2022 r2082 371 371 /// <returns></returns> 372 372 public ResponseJob SendJob(Guid clientId) { 373 ResponseJob response = new ResponseJob(); 374 375 Job job2Calculate = scheduler.GetNextJobForClient(clientId); 376 if (job2Calculate != null) { 377 response.Job = job2Calculate; 378 response.Success = true; 379 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED; 380 lock (newAssignedJobs) { 381 newAssignedJobs.Add(job2Calculate.Id, ApplicationConstants.JOB_TIME_TO_LIVE); 382 } 383 } else { 384 response.Success = false; 385 response.Job = null; 386 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT; 387 } 388 return response; 373 ISession session = factory.GetSessionForCurrentThread(); 374 ITransaction tx = null; 375 376 try { 377 IJobAdapter jobAdapter = 378 session.GetDataAdapter<Job, IJobAdapter>(); 379 380 tx = session.BeginTransaction(); 381 382 ResponseJob response = new ResponseJob(); 383 384 Job job2Calculate = scheduler.GetNextJobForClient(clientId); 385 if (job2Calculate != null) { 386 ComputableJob computableJob = 387 jobAdapter.GetComputableJob(job2Calculate.Id); 388 389 response.Job = computableJob; 390 response.Success = true; 391 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED; 392 lock (newAssignedJobs) { 393 newAssignedJobs.Add(job2Calculate.Id, ApplicationConstants.JOB_TIME_TO_LIVE); 394 } 395 } else { 396 response.Success = false; 397 response.Job = null; 398 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT; 399 } 400 401 return response; 402 } 403 catch (Exception ex) { 404 if (tx != null) 405 tx.Rollback(); 406 throw ex; 407 } 408 finally { 409 if (session != null) 410 session.EndSession(); 411 } 389 412 } 390 413 … … 412 435 clientAdapter.GetById(clientId); 413 436 414 Job job = 415 jobAdapter.GetById(jobId); 437 ComputableJob job = 438 new ComputableJob(); 439 440 if (job != null) { 441 job.JobInfo = 442 jobAdapter.GetById(jobId); 443 } 416 444 417 if (job == null ) {445 if (job == null && job.JobInfo != null) { 418 446 response.Success = false; 419 447 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID; … … 421 449 return response; 422 450 } 423 if (job. State == State.abort) {451 if (job.JobInfo.State == State.abort) { 424 452 response.Success = false; 425 453 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_WAS_ABORTED; 426 454 } 427 if (job. Client == null) {455 if (job.JobInfo.Client == null) { 428 456 response.Success = false; 429 457 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; … … 431 459 return response; 432 460 } 433 if (job. Client.Id != clientId) {461 if (job.JobInfo.Client.Id != clientId) { 434 462 response.Success = false; 435 463 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB; … … 437 465 return response; 438 466 } 439 if (job. State == State.finished) {467 if (job.JobInfo.State == State.finished) { 440 468 response.Success = true; 441 469 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED; … … 443 471 return response; 444 472 } 445 if (job.State == State.requestSnapshotSent) { 446 job.State = State.calculating; 447 } 448 if (job.State != State.calculating && job.State != State.pending) { 473 if (job.JobInfo.State == State.requestSnapshotSent) { 474 job.JobInfo.State = State.calculating; 475 } 476 if (job.JobInfo.State != State.calculating && 477 job.JobInfo.State != State.pending) { 449 478 response.Success = false; 450 479 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_JOB_STATE; … … 453 482 } 454 483 job.SerializedJob = result; 455 job. Percentage = percentage;484 job.JobInfo.Percentage = percentage; 456 485 457 486 if (finished) { 458 job.State = State.finished; 459 jobAdapter.Update(job); 460 } 461 List<JobResult> jobResults = new List<JobResult>(jobResultAdapter.GetResultsOf(job)); 487 job.JobInfo.State = State.finished; 488 job.SerializedJob = result; 489 } 490 491 jobAdapter.UpdateComputableJob(job); 492 493 List<JobResult> jobResults = new List<JobResult>( 494 jobResultAdapter.GetResultsOf(job.JobInfo)); 462 495 foreach (JobResult currentResult in jobResults) 463 496 jobResultAdapter.Delete(currentResult); … … 466 499 new JobResult(); 467 500 jobResult.ClientId = client.Id; 468 jobResult.JobId = job. Id;501 jobResult.JobId = job.JobInfo.Id; 469 502 jobResult.Result = result; 470 503 jobResult.Percentage = percentage; … … 473 506 474 507 jobResultAdapter.Update(jobResult); 475 jobAdapter.Update(job );508 jobAdapter.Update(job.JobInfo); 476 509 477 510 response.Success = true; -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ExecutionEngineFacade.cs
r1530 r2082 36 36 #region IExecutionEngineFacade Members 37 37 38 public ResponseObject<Job> AddJob( Job job) {38 public ResponseObject<Job> AddJob(ComputableJob job) { 39 39 return jobManager.AddNewJob(job); 40 40 } -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs
r2005 r2082 73 73 public void ResetJobsDependingOnResults(Job job) { 74 74 ISession session = factory.GetSessionForCurrentThread(); 75 ITransaction tx = null; 75 76 76 77 try { … … 78 79 session.GetDataAdapter<Job, IJobAdapter>(); 79 80 80 JobResult lastJobResult = GetLastJobResult(job); 81 if (lastJobResult != null) { 82 job.Percentage = lastJobResult.Percentage; 83 job.SerializedJob = lastJobResult.Result; 84 } else { 85 job.Percentage = 0; 86 } 87 88 job.Client = null; 89 job.State = State.offline; 90 91 jobAdapter.Update(job); 81 tx = session.BeginTransaction(); 82 83 if (job != null) { 84 ComputableJob computableJob = 85 new ComputableJob(); 86 computableJob.JobInfo = 87 job; 88 89 JobResult lastJobResult = GetLastJobResult(job); 90 if (lastJobResult != null) { 91 computableJob.JobInfo.Percentage = lastJobResult.Percentage; 92 computableJob.SerializedJob = lastJobResult.Result; 93 94 jobAdapter.UpdateComputableJob(computableJob); 95 } else { 96 computableJob.JobInfo.Percentage = 0; 97 } 98 99 computableJob.JobInfo.Client = null; 100 computableJob.JobInfo.State = State.offline; 101 102 jobAdapter.Update(computableJob.JobInfo); 103 } 104 105 tx.Commit(); 106 } 107 catch (Exception ex) { 108 if (tx != null) 109 tx.Rollback(); 110 throw ex; 92 111 } 93 112 finally { … … 185 204 /// <param name="job"></param> 186 205 /// <returns></returns> 187 public ResponseObject<Job> AddNewJob( Job job) {206 public ResponseObject<Job> AddNewJob(ComputableJob job) { 188 207 ISession session = factory.GetSessionForCurrentThread(); 189 208 … … 194 213 ResponseObject<Job> response = new ResponseObject<Job>(); 195 214 196 if (job != null ) {197 if (job. State != State.offline) {215 if (job != null && job.JobInfo != null) { 216 if (job.JobInfo.State != State.offline) { 198 217 response.Success = false; 199 218 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOBSTATE_MUST_BE_OFFLINE; 200 219 return response; 201 220 } 202 if (job. Id != Guid.Empty) {221 if (job.JobInfo.Id != Guid.Empty) { 203 222 response.Success = false; 204 223 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ID_MUST_NOT_BE_SET; … … 211 230 } 212 231 213 job. DateCreated = DateTime.Now;214 jobAdapter.Update (job);232 job.JobInfo.DateCreated = DateTime.Now; 233 jobAdapter.UpdateComputableJob(job); 215 234 response.Success = true; 216 response.Obj = job ;235 response.Obj = job.JobInfo; 217 236 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_ADDED; 218 237 } else { -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs
r2067 r2082 99 99 } 100 100 101 public ResponseObject<Job> AddNewJob( Job job) {102 secMan.Authorize("AddJob", sessionID, job. Id);101 public ResponseObject<Job> AddNewJob(ComputableJob job) { 102 secMan.Authorize("AddJob", sessionID, job.JobInfo.Id); 103 103 return jobManager.AddNewJob(job); 104 104 }
Note: See TracChangeset
for help on using the changeset viewer.