- Timestamp:
- 07/08/15 15:32:12 (9 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources
-
branches/HiveStatistics/sources/HeuristicLab.Clients.Hive/3.3/HiveTasks/EngineHiveTask.cs
r12012 r12689 47 47 48 48 public override TaskData GetAsTaskData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) { 49 plugins = new List<IPluginDescription>();50 if (this.itemTask == null)49 if (ItemTask == null) { 50 plugins = new List<IPluginDescription>(); 51 51 return null; 52 } 52 53 53 54 TaskData jobData = new TaskData(); … … 60 61 jobData.Data = PersistenceUtil.Serialize(ItemTask, out usedTypes); 61 62 62 PluginUtil.CollectDeclaringPlugins(plugins, usedTypes);63 plugins = PluginUtil.GetPluginsForTask(usedTypes, ItemTask); 63 64 return jobData; 64 65 } -
branches/HiveStatistics/sources/HeuristicLab.Clients.Hive/3.3/HiveTasks/HiveTask.cs
r12012 r12689 295 295 /// </param> 296 296 public virtual TaskData GetAsTaskData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) { 297 plugins = new List<IPluginDescription>();298 if (this.itemTask == null)297 if (ItemTask == null) { 298 plugins = new List<IPluginDescription>(); 299 299 return null; 300 } 300 301 301 302 IEnumerable<Type> usedTypes; 302 byte[] taskByteArray = PersistenceUtil.Serialize( this.ItemTask, out usedTypes);303 byte[] taskByteArray = PersistenceUtil.Serialize(ItemTask, out usedTypes); 303 304 TaskData taskData = new TaskData() { TaskId = task.Id, Data = taskByteArray }; 304 PluginUtil.CollectDeclaringPlugins(plugins, usedTypes);305 plugins = PluginUtil.GetPluginsForTask(usedTypes, ItemTask); 305 306 return taskData; 306 307 } -
branches/HiveStatistics/sources/HeuristicLab.Clients.Hive/3.3/HiveTasks/OptimizerHiveTask.cs
r12041 r12689 347 347 /// </param> 348 348 public override TaskData GetAsTaskData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) { 349 plugins = new List<IPluginDescription>();350 if (this.itemTask == null) // || this.jobItem.Optimizer == null349 if (ItemTask == null) { 350 plugins = new List<IPluginDescription>(); 351 351 return null; 352 } 352 353 353 354 IEnumerable<Type> usedTypes; 354 355 byte[] jobByteArray; 355 if (withoutChildOptimizers && this.ItemTask.Item is Optimization.Experiment) {356 OptimizerTask clonedJob = (OptimizerTask) this.ItemTask.Clone(); // use a cloned task, so that the childHiveJob don't get confused356 if (withoutChildOptimizers && ItemTask.Item is Optimization.Experiment) { 357 OptimizerTask clonedJob = (OptimizerTask)ItemTask.Clone(); // use a cloned task, so that the childHiveJob don't get confused 357 358 clonedJob.OptimizerAsExperiment.Optimizers.Clear(); 358 359 jobByteArray = PersistenceUtil.Serialize(clonedJob, out usedTypes); 359 } else if (withoutChildOptimizers && this.ItemTask.Item is Optimization.BatchRun) {360 OptimizerTask clonedJob = (OptimizerTask) this.ItemTask.Clone();360 } else if (withoutChildOptimizers && ItemTask.Item is Optimization.BatchRun) { 361 OptimizerTask clonedJob = (OptimizerTask)ItemTask.Clone(); 361 362 clonedJob.OptimizerAsBatchRun.Optimizer = null; 362 363 jobByteArray = PersistenceUtil.Serialize(clonedJob, out usedTypes); 363 } else if ( this.ItemTask.Item is IAlgorithm) {364 ((IAlgorithm) this.ItemTask.Item).StoreAlgorithmInEachRun = false; // avoid storing the algorithm in runs to reduce size365 jobByteArray = PersistenceUtil.Serialize( this.ItemTask, out usedTypes);364 } else if (ItemTask.Item is IAlgorithm) { 365 ((IAlgorithm)ItemTask.Item).StoreAlgorithmInEachRun = false; // avoid storing the algorithm in runs to reduce size 366 jobByteArray = PersistenceUtil.Serialize(ItemTask, out usedTypes); 366 367 } else { 367 jobByteArray = PersistenceUtil.Serialize( this.ItemTask, out usedTypes);368 jobByteArray = PersistenceUtil.Serialize(ItemTask, out usedTypes); 368 369 } 369 370 370 371 TaskData jobData = new TaskData() { TaskId = task.Id, Data = jobByteArray }; 371 PluginUtil.CollectDeclaringPlugins(plugins, usedTypes);372 plugins = PluginUtil.GetPluginsForTask(usedTypes, ItemTask); 372 373 return jobData; 373 374 } -
branches/HiveStatistics/sources/HeuristicLab.Clients.Hive/3.3/Util/PluginUtil.cs
r12012 r12689 26 26 using System.Security.Cryptography; 27 27 using System.ServiceModel; 28 using HeuristicLab.Core; 28 29 using HeuristicLab.PluginInfrastructure; 29 30 … … 39 40 /// <param name="neededPlugins">List of plugins which need to be uploaded</param> 40 41 /// <returns></returns> 41 public static List<Guid> GetPluginDependencies(IHiveService service, List<Plugin> onlinePlugins, List<Plugin> alreadyUploadedPlugins, IEnumerable<IPluginDescription> neededPlugins) { 42 public static List<Guid> GetPluginDependencies(IHiveService service, List<Plugin> onlinePlugins, List<Plugin> alreadyUploadedPlugins, 43 IEnumerable<IPluginDescription> neededPlugins) { 42 44 var pluginIds = new List<Guid>(); 43 45 Dictionary<IPluginDescription, byte[]> checksumsNeededPlugins = CalcChecksumsForPlugins(neededPlugins); … … 61 63 alreadyUploadedPlugins.Add(p); 62 64 pluginIds.Add(p.Id); 63 } 64 catch (FaultException<PluginAlreadyExistsFault> fault) { 65 } catch (FaultException<PluginAlreadyExistsFault> fault) { 65 66 onlinePlugins.Add(service.GetPlugin(fault.Detail.Id)); 66 67 } … … 79 80 } 80 81 81 public static Plugin CreatePlugin(IPluginDescription plugin) {82 return new Plugin() { Name = plugin.Name, Version = plugin.Version };83 }84 85 82 public static List<PluginData> CreatePluginDatas(IPluginDescription plugin) { 86 83 List<PluginData> pluginDatas = new List<PluginData>(); … … 96 93 } 97 94 98 public static void CollectDeclaringPlugins(List<IPluginDescription> plugins, IEnumerable<Type> usedTypes) { 95 public static List<IPluginDescription> GetPluginsForTask(IEnumerable<Type> usedTypes, object task) { 96 if (usedTypes.Any(x => typeof(IProgrammableItem).IsAssignableFrom(x))) { 97 //when a programmable item is used all plugins that are currently loaded need to be sent to Hive 98 return ApplicationManager.Manager.Plugins.ToList(); 99 } else { 100 return CollectDeclaringPlugins(usedTypes); 101 } 102 } 103 104 private static List<IPluginDescription> CollectDeclaringPlugins(IEnumerable<Type> usedTypes) { 105 List<IPluginDescription> plugins = new List<IPluginDescription>(); 99 106 foreach (Type type in usedTypes) { 100 107 var plugin = ApplicationManager.Manager.GetDeclaringPlugin(type); … … 104 111 } 105 112 } 113 return plugins; 106 114 } 107 115 108 p ublicstatic void CollectPluginDependencies(List<IPluginDescription> plugins, IPluginDescription plugin) {116 private static void CollectPluginDependencies(List<IPluginDescription> plugins, IPluginDescription plugin) { 109 117 if (plugin == null) return; 110 118 foreach (var dependency in plugin.Dependencies) {
Note: See TracChangeset
for help on using the changeset viewer.