Changeset 1730 for trunk/sources
- Timestamp:
- 05/02/09 22:43:01 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngine.cs
r1726 r1730 32 32 using System.IO; 33 33 using System.Xml; 34 using System.IO.Compression; 34 35 35 36 namespace HeuristicLab.Hive.Engine { … … 76 77 IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(HiveServerUrl); 77 78 78 DiscoveryService dService = new DiscoveryService(); 79 PluginInfo depInfo = dService.GetDeclaringPlugin(typeof(HiveEngine)); 80 List<PluginInfo> dependentPlugins = PluginManager.Manager.GetDependentPluginsRec(depInfo); 81 dependentPlugins.Add(depInfo); 82 79 var jobObj = CreateJobObj(); 80 81 ResponseObject<Contracts.BusinessObjects.Job> res = executionEngineFacade.AddJob(jobObj); 82 jobId = res.Obj.Id; 83 } 84 85 private HeuristicLab.Hive.Contracts.BusinessObjects.Job CreateJobObj() { 83 86 HeuristicLab.Hive.Contracts.BusinessObjects.Job jobObj = new HeuristicLab.Hive.Contracts.BusinessObjects.Job(); 84 jobObj.SerializedJob = PersistenceManager.SaveToGZip(job); 85 jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline; 87 88 MemoryStream memStream = new MemoryStream(); 89 GZipStream stream = new GZipStream(memStream, CompressionMode.Compress, true); 90 XmlDocument document = PersistenceManager.CreateXmlDocument(); 91 Dictionary<Guid, IStorable> dictionary = new Dictionary<Guid, IStorable>(); 92 XmlNode rootNode = document.CreateElement("Root"); 93 document.AppendChild(rootNode); 94 rootNode.AppendChild(PersistenceManager.Persist(job, document, dictionary)); 95 document.Save(stream); 96 stream.Close(); 97 jobObj.SerializedJob = memStream.ToArray(); 98 99 DiscoveryService service = new DiscoveryService(); 100 List<PluginInfo> plugins = new List<PluginInfo>(); 101 102 foreach (IStorable storeable in dictionary.Values) { 103 PluginInfo pluginInfo = service.GetDeclaringPlugin(storeable.GetType()); 104 if (!plugins.Contains(pluginInfo)) plugins.Add(pluginInfo); 105 } 86 106 87 107 List<HivePluginInfo> pluginsNeeded = 88 108 new List<HivePluginInfo>(); 89 90 foreach (PluginInfo info in dependentPlugins) { 109 foreach (PluginInfo uniquePlugin in plugins) { 91 110 HivePluginInfo pluginInfo = 92 111 new HivePluginInfo(); 93 pluginInfo.Name = info.Name;94 pluginInfo.Version = info.Version.ToString();95 pluginInfo.BuildDate = info.BuildDate;112 pluginInfo.Name = uniquePlugin.Name; 113 pluginInfo.Version = uniquePlugin.Version.ToString(); 114 pluginInfo.BuildDate = uniquePlugin.BuildDate; 96 115 pluginsNeeded.Add(pluginInfo); 97 116 } 98 117 99 118 jobObj.PluginsNeeded = pluginsNeeded; 100 ResponseObject<Contracts.BusinessObjects.Job> res = executionEngineFacade.AddJob(jobObj);101 jobId = res.Obj.Id;119 jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline; 120 return jobObj; 102 121 } 103 122 -
trunk/sources/HeuristicLab.PluginInfrastructure/PluginManager.cs
r1715 r1730 263 263 } 264 264 265 266 /// <summary>267 /// Calculates a set of plugins that directly or transitively depend on the plugin given in the argument.268 /// </summary>269 /// <param name="pluginInfo">The plugin the other depend on.</param>270 /// <returns>a list of plugins that are directly of transitively dependent.</returns>271 public List<PluginInfo> GetDependentPluginsRec(PluginInfo pluginInfo) {272 List<PluginInfo> mergedList = new List<PluginInfo>();273 //Bugfix the hell out of this...274 //Bugfixed the hell out of this...275 foreach (PluginInfo info in pluginInfo.Dependencies) {276 if (!mergedList.Contains(info)) {277 mergedList.Add(info);278 AddDependenciesRecursive(info, mergedList);279 }280 }281 return mergedList;282 }283 284 private void AddDependenciesRecursive(PluginInfo info, List<PluginInfo> mergedList) {285 //if we've already processed this element => STOP IT!286 if(!mergedList.Contains(info)) {287 mergedList.Add(info);288 return;289 }290 foreach (PluginInfo depinfo in info.Dependencies)291 AddDependenciesRecursive(depinfo, mergedList);292 }293 294 265 /// <summary> 295 266 /// Unloads all plugins.
Note: See TracChangeset
for help on using the changeset viewer.