Changeset 5179 for branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.ExperimentManager/3.3/HiveExperiment.cs
- Timestamp:
- 12/29/10 00:52:06 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.ExperimentManager/3.3/HiveExperiment.cs
r5171 r5179 534 534 IsProgressing = true; 535 535 int totalJobCount = 0; 536 int jobCount = 0;537 536 JobResultList allResults; 538 IDictionary<Guid, SerializedJob> allSerializedJobs = new Dictionary<Guid, SerializedJob>(); 537 539 538 progress.Status = "Connecting to Server..."; 540 using (Disposable<IClientFacade> service = ServiceLocator.Instance.StreamedClientFacadePool.GetService()) { 541 // fetch all JobDto objects to create the full tree of tree of HiveJob objects 539 using (Disposable<IClientFacade> service = ServiceLocator.Instance.ClientFacadePool.GetService()) { 542 540 progress.Status = "Downloading list of jobs..."; 543 541 allResults = service.Obj.GetChildJobResults(rootJobId.Value, true, true).Obj; 544 542 totalJobCount = allResults.Count; 545 546 // download them first 547 foreach (JobResult jobResult in allResults) { 548 jobCount++; 549 progress.Status = string.Format("Downloading {0} of {1} jobs...", jobCount, totalJobCount); 550 allSerializedJobs.Add(jobResult.Id, service.Obj.GetLastSerializedResult(jobResult.Id).Obj); 551 progress.ProgressValue = (double)jobCount / totalJobCount; 552 } 553 } 554 555 jobCount = 1; 556 progress.Status = string.Format("Deserializing {0} of {1} jobs... ({2} kb)", jobCount, totalJobCount, allSerializedJobs[this.rootJobId.Value].SerializedJobData.Count() / 1024); 557 this.HiveJob = new HiveJob(allSerializedJobs[this.rootJobId.Value], false); 558 allSerializedJobs.Remove(this.rootJobId.Value); // reduce memory footprint 559 progress.ProgressValue = (double)jobCount / totalJobCount; 543 } 544 545 HiveJobDownloader downloader = new HiveJobDownloader(allResults.Select(x => x.Id)); 546 downloader.StartAsync(); 547 548 while (!downloader.IsFinished) { 549 progress.ProgressValue = downloader.FinishedCount / (double)totalJobCount; 550 progress.Status = string.Format("Downloading/deserializing jobs... ({0}/{1} finished)", downloader.FinishedCount, totalJobCount); 551 Thread.Sleep(500); 552 } 553 IDictionary<Guid, HiveJob> allHiveJobs = downloader.Results; 554 555 this.HiveJob = allHiveJobs[this.rootJobId.Value]; 560 556 561 557 if (this.HiveJob.JobDto.DateFinished.HasValue) { … … 571 567 } 572 568 573 // build child-job tree 574 LoadChildResults(this.HiveJob, allResults, allSerializedJobs, progress, totalJobCount, ref jobCount); 569 BuildHiveJobTree(this.HiveJob, allResults, allHiveJobs); 575 570 StartResultPolling(); 576 571 } … … 583 578 } 584 579 585 private void LoadChildResults(HiveJob parentHiveJob, JobResultList allResults, IDictionary<Guid, SerializedJob> allSerializedJobs, IProgress progress, int totalJobCount, ref int jobCount) {580 private void BuildHiveJobTree(HiveJob parentHiveJob, JobResultList allResults, IDictionary<Guid, HiveJob> allHiveJobs) { 586 581 IEnumerable<JobResult> childResults = from result in allResults 587 582 where result.ParentJobId.HasValue && result.ParentJobId.Value == parentHiveJob.JobDto.Id … … 589 584 select result; 590 585 foreach (JobResult jobResult in childResults) { 591 jobCount++; 592 progress.Status = string.Format("Deserializing {0} of {1} jobs ({2} kb)...", jobCount, totalJobCount, allSerializedJobs[jobResult.Id].SerializedJobData.Count() / 1024); 593 OptimizerJob optimizerJob = null; 594 try { 595 optimizerJob = SerializedJob.Deserialize<OptimizerJob>(allSerializedJobs[jobResult.Id].SerializedJobData); 596 } 597 catch { 598 optimizerJob = null; 599 } 600 progress.ProgressValue = (double)jobCount / totalJobCount; 601 HiveJob childHiveJob = new HiveJob(optimizerJob, false); 586 HiveJob childHiveJob = allHiveJobs[jobResult.Id]; 602 587 parentHiveJob.AddChildHiveJob(childHiveJob); 603 childHiveJob.JobDto = allSerializedJobs[jobResult.Id].JobInfo; 604 allSerializedJobs.Remove(jobResult.Id); // reduce memory footprint 605 if (jobCount % 10 == 0) GC.Collect(); // this is needed or otherwise HL takes over the system when the number of jobs is high 606 LoadChildResults(childHiveJob, allResults, allSerializedJobs, progress, totalJobCount, ref jobCount); 588 BuildHiveJobTree(childHiveJob, allResults, allHiveJobs); 607 589 } 608 590 }
Note: See TracChangeset
for help on using the changeset viewer.