Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/02/09 22:43:01 (15 years ago)
Author:
gkronber
Message:

Implemented calculation of list of necessary plugins for a job in the HiveEngine #545 (Engine which can be executed in the Hive).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngine.cs

    r1726 r1730  
    3232using System.IO;
    3333using System.Xml;
     34using System.IO.Compression;
    3435
    3536namespace HeuristicLab.Hive.Engine {
     
    7677      IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(HiveServerUrl);
    7778
    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() {
    8386      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      }
    86106
    87107      List<HivePluginInfo> pluginsNeeded =
    88108        new List<HivePluginInfo>();
    89 
    90       foreach (PluginInfo info in dependentPlugins) {
     109      foreach (PluginInfo uniquePlugin in plugins) {
    91110        HivePluginInfo pluginInfo =
    92111          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;
    96115        pluginsNeeded.Add(pluginInfo);
    97116      }
    98117
    99118      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;
    102121    }
    103122
Note: See TracChangeset for help on using the changeset viewer.