Changeset 4423 for branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/JobManager.cs
- Timestamp:
- 09/17/10 10:26:55 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/JobManager.cs
r4368 r4423 50 50 lifecycleManager = ServiceLocator.GetLifecycleManager(); 51 51 52 lifecycleManager. RegisterStartup(new EventHandler(lifecycleManager_OnStartup));53 lifecycleManager. RegisterShutdown(new EventHandler(lifecycleManager_OnShutdown));52 lifecycleManager.Started += new EventHandler(lifecycleManager_Started); 53 lifecycleManager.Stopped += new EventHandler(lifecycleManager_Stopped); 54 54 } 55 55 … … 59 59 List<JobDto> allJobs = new List<JobDto>(DaoLocator.JobDao.FindAll()); 60 60 foreach (JobDto curJob in allJobs) { 61 if (curJob.State != JobState.Calculating && curJob.State != JobState.Finished) { 61 if (curJob.State != JobState.Calculating && 62 curJob.State != JobState.Finished && 63 curJob.State != JobState.Aborted && 64 curJob.State != JobState.Failed && 65 curJob.State != JobState.WaitForChildJobs) { 62 66 DaoLocator.JobDao.SetJobOffline(curJob); 63 67 } … … 65 69 } 66 70 67 private void lifecycleManager_ OnStartup(object sender, EventArgs e) {71 private void lifecycleManager_Started(object sender, EventArgs e) { 68 72 Logger.Info("Startup Event Fired, Checking DB for consistency"); 69 73 CheckForDeadJobs(); … … 71 75 } 72 76 73 private void lifecycleManager_ OnShutdown(object sender, EventArgs e) {77 private void lifecycleManager_Stopped(object sender, EventArgs e) { 74 78 Logger.Info("Startup Event Fired, Checking DB for consistency"); 75 79 CheckForDeadJobs(); … … 155 159 156 160 if (job != null && job.JobInfo != null) { 157 if (job.JobInfo.State != JobState.Offline) { 158 response.StatusMessage = ResponseStatus.AddNewJob_JobStateMustBeOffline; 161 // only Offline and WaitForChildJobs are allowed 162 if (job.JobInfo.State != JobState.Offline && job.JobInfo.State != JobState.WaitForChildJobs) { 163 response.StatusMessage = ResponseStatus.AddNewJob_InvalidJobState; 159 164 return response; 160 165 } … … 228 233 response.Obj.JobInfo = job; 229 234 230 response.Obj.SerializedJobData = DaoLocator.JobDao.GetBinaryJobFile(jobId); 235 if (job != null) { 236 response.Obj.SerializedJobData = DaoLocator.JobDao.GetBinaryJobFile(jobId); 237 } else { 238 response.StatusMessage = ResponseStatus.GetLastSerializedResult_JobDoesNotExist; 239 } 231 240 232 241 return response; … … 285 294 //response.Success = true; 286 295 response.StatusMessage = ResponseStatus.AbortJob_AbortAlreadyRequested; 287 return response; // no commit needed288 }289 if (job.State != JobState.Calculating && job.State != JobState.SnapshotRequested && job.State != JobState.SnapshotSent) {290 //response.Success = false;291 response.StatusMessage = ResponseStatus.AbortJob_JobIsNotBeeingCalculated;292 296 return response; // no commit needed 293 297 } … … 315 319 DateFinished = job.DateFinished, 316 320 Exception = job.Exception, 317 Percentage = job.Percentage321 ExecutionTime = job.ExecutionTime 318 322 }); 319 323 } … … 352 356 DateFinished = job.DateFinished, 353 357 Exception = job.Exception, 354 Percentage = job.Percentage,355 ParentJobId = job.ParentJob != null ? new Nullable<Guid>(job.ParentJob.Id) : null358 ExecutionTime = job.ExecutionTime, 359 ParentJobId = job.ParentJobId 356 360 }); 357 361 } 358 362 } 359 363 360 364 response.Obj = jobResultList; 361 365 return response; … … 365 369 JobDto parentJob = DaoLocator.JobDao.FindById(parentJobId); 366 370 367 serializedJob.JobInfo.ParentJob = parentJob;371 serializedJob.JobInfo.ParentJobId = parentJob.Id; 368 372 serializedJob.JobInfo.UserId = parentJob.UserId; 369 373 serializedJob.JobInfo.AssignedResourceIds = parentJob.AssignedResourceIds; … … 376 380 377 381 jobDto.State = serializedJob.JobInfo.State; 378 jobDto.Percentage = serializedJob.JobInfo.Percentage; 379 382 jobDto.ExecutionTime = serializedJob.JobInfo.ExecutionTime; 380 383 381 384 DaoLocator.JobDao.SetBinaryJobFile(serializedJob.JobInfo.Id, serializedJob.SerializedJobData); … … 390 393 } 391 394 395 396 public ResponseObject<HiveExperimentDtoList> GetHiveExperiments() { 397 ResponseObject<HiveExperimentDtoList> response = new ResponseObject<HiveExperimentDtoList>(); 398 IEnumerable<HiveExperimentDto> hiveExperiments = DaoLocator.HiveExperimentDao.FindAllByUserId(ServiceLocator.GetAuthorizationManager().UserId); 399 response.Obj = new HiveExperimentDtoList(hiveExperiments); 400 response.StatusMessage = ResponseStatus.Ok; 401 return response; 402 } 403 404 public ResponseObject<HiveExperimentDto> UpdateHiveExperiment(HiveExperimentDto hiveExperimentDto) { 405 ResponseObject<HiveExperimentDto> response = new ResponseObject<HiveExperimentDto>(); 406 if (hiveExperimentDto.Id == Guid.Empty) { 407 response.Obj = DaoLocator.HiveExperimentDao.Insert(hiveExperimentDto); 408 } else { 409 DaoLocator.HiveExperimentDao.Update(hiveExperimentDto); 410 response.Obj = hiveExperimentDto; 411 } 412 response.StatusMessage = ResponseStatus.Ok; 413 return response; 414 } 415 416 public Response DeleteHiveExperiment(Guid hiveExperimentId) { 417 Response response = new Response(); 418 try { 419 DaoLocator.HiveExperimentDao.Delete(hiveExperimentId); 420 } 421 catch (Exception) { 422 response.StatusMessage = ResponseStatus.DeleteHiveExperiment_Failed; 423 } 424 return response; 425 } 426 427 public Response DeleteChildJobs(Guid jobId) { 428 Response response = new Response(); 429 try { 430 IEnumerable<JobDto> childs = DaoLocator.JobDao.FindJobsByParentId(jobId, true); 431 foreach (JobDto childJob in childs) { 432 DaoLocator.JobDao.Delete(childJob.Id); 433 } 434 } 435 catch (Exception) { 436 response.StatusMessage = ResponseStatus.DeleteChildJobs_Failed; 437 } 438 return response; 439 } 440 392 441 #endregion 393 442 … … 420 469 421 470 422 423 424 471 } 425 472 }
Note: See TracChangeset
for help on using the changeset viewer.