Changeset 5404 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveJobClient.cs
- Timestamp:
- 02/01/11 15:51:11 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveJobClient.cs
r5402 r5404 32 32 using HeuristicLab.PluginInfrastructure; 33 33 using HeuristicLab.Services.Hive.Common.DataTransfer; 34 using HeuristicLab.PluginInfrastructure.Manager; 34 35 35 36 namespace HeuristicLab.Clients.Hive { … … 425 426 /// if true the Child-Optimizers will not be serialized (if the job contains an Experiment) 426 427 /// </param> 427 public JobData GetAsJobData(bool withoutChildOptimizers) { 428 public JobData GetAsJobData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) { 429 plugins = new List<IPluginDescription>(); 428 430 if (this.optimizerJob == null || this.optimizerJob.Optimizer == null) 429 431 return null; 430 432 433 IEnumerable<Type> usedTypes; 431 434 byte[] jobByteArray; 432 435 if (withoutChildOptimizers && this.OptimizerJob.Optimizer is Optimization.Experiment) { 433 436 OptimizerJob clonedJob = (OptimizerJob)this.OptimizerJob.Clone(); // use a cloned job, so that the childHiveJob don't get confused 434 437 clonedJob.OptimizerAsExperiment.Optimizers.Clear(); 435 jobByteArray = PersistenceUtil.Serialize(clonedJob );438 jobByteArray = PersistenceUtil.Serialize(clonedJob, out usedTypes); 436 439 } else if (withoutChildOptimizers && this.OptimizerJob.Optimizer is Optimization.BatchRun) { 437 440 OptimizerJob clonedJob = (OptimizerJob)this.OptimizerJob.Clone(); 438 441 clonedJob.OptimizerAsBatchRun.Optimizer = null; 439 jobByteArray = PersistenceUtil.Serialize(clonedJob );442 jobByteArray = PersistenceUtil.Serialize(clonedJob, out usedTypes); 440 443 } else if (this.OptimizerJob.Optimizer is IAlgorithm) { 441 444 ((IAlgorithm)this.OptimizerJob.Optimizer).StoreAlgorithmInEachRun = false; // avoid storing the algorithm in runs to reduce size 442 jobByteArray = PersistenceUtil.Serialize(this.OptimizerJob );445 jobByteArray = PersistenceUtil.Serialize(this.OptimizerJob, out usedTypes); 443 446 } else { 444 jobByteArray = PersistenceUtil.Serialize(this.OptimizerJob );447 jobByteArray = PersistenceUtil.Serialize(this.OptimizerJob, out usedTypes); 445 448 } 446 449 … … 450 453 }; 451 454 455 CollectDeclaringPlugins(plugins, usedTypes); 456 452 457 return jobData; 458 } 459 460 private void CollectDeclaringPlugins(List<IPluginDescription> plugins, IEnumerable<Type> usedTypes) { 461 foreach (Type type in usedTypes) { 462 var plugin = ApplicationManager.Manager.GetDeclaringPlugin(type); 463 if (plugin != null && !plugins.Contains(plugin)) { 464 plugins.Add(plugin); 465 CollectPluginDependencies(plugins, plugin); 466 } 467 } 468 } 469 470 private void CollectPluginDependencies(List<IPluginDescription> plugins, IPluginDescription plugin) { 471 if (plugin == null) return; 472 foreach (var dependency in plugin.Dependencies) { 473 if (!plugins.Contains(dependency)) { 474 plugins.Add(dependency); 475 CollectPluginDependencies(plugins, dependency); 476 } 477 } 453 478 } 454 479
Note: See TracChangeset
for help on using the changeset viewer.