Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/26/10 18:17:16 (14 years ago)
Author:
cneumuel
Message:

migration from 3.2 to 3.3 completed. Hive Server and Client are now executable and as functional as they were in 3.2. (#1096)

Location:
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Engine/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Engine/3.3/HeuristicLab.Hive.Engine-3.3.csproj

    r4091 r4107  
    100100      <HintPath>..\..\..\..\..\..\..\..\..\Programme\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath>
    101101    </Reference>
     102    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    102103    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    103104      <HintPath>..\..\..\..\..\..\..\..\..\Programme\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Engine/3.3/HiveEngine.cs

    r4091 r4107  
    2828using System.Xml;
    2929using System.IO.Compression;
     30using System.Linq;
    3031using HeuristicLab.Common;
    3132using HeuristicLab.Hive.JobBase;
     
    3536using HeuristicLab.Hive.Contracts.BusinessObjects;
    3637using HeuristicLab.Tracing;
     38using HeuristicLab.Persistence.Default.Xml;
     39using System.Reflection;
    3740
    3841namespace HeuristicLab.Hive.Engine {
     
    4952    private object locker = new object();
    5053    private volatile bool abortRequested;
     54    private ThreadPriority priority;
    5155
    5256    public string HiveServerUrl { get; set; }
     
    5559
    5660    public HiveEngine() {
     61      // <debug>
     62      HiveServerUrl = "net.tcp://10.42.1.153:9000/ExecutionEngine/ExecutionEngineFacade";
     63      RessourceIds = "MyGroup";
     64      // </debug>
     65
    5766      job = new Job();
    5867      abortRequested = false;
     
    7382
    7483    public ThreadPriority Priority {
    75       get { return this.Priority; }
    76       set { this.Priority = value; }
     84      get { return this.priority; }
     85      set { this.priority = value; }
    7786    }
    7887
     
    148157            if (response.Success && response.Obj != null && response.StatusMessage != ApplicationConstants.RESPONSE_JOB_RESULT_NOT_YET_HERE) {
    149158              Logger.Debug("HiveEngine: Results-polling - Got result!");
    150               throw new NotImplementedException("TODO[chn]use persistency-3.3");
    151               //restoredJob = (Job)PersistenceManager.RestoreFromGZip(response.Obj.SerializedJobData);
     159              restoredJob = XmlParser.Deserialize<Job>(new MemoryStream(response.Obj.SerializedJobData));
    152160              Logger.Debug("HiveEngine: Results-polling - IsSnapshotResult: " + (restoredJob.Progress < 1.0));
    153161            }
     
    167175
    168176    private HeuristicLab.Hive.Contracts.BusinessObjects.SerializedJob CreateJobObj() {
    169       HeuristicLab.Hive.Contracts.BusinessObjects.JobDto jobObj =
    170         new HeuristicLab.Hive.Contracts.BusinessObjects.JobDto();
    171 
    172 
    173       throw new NotImplementedException("TODO[chn]use persistency-3.3");
    174 
    175       //MemoryStream memStream = new MemoryStream();
    176       //GZipStream stream = new GZipStream(memStream, CompressionMode.Compress, true);
    177       //XmlDocument document = PersistenceManager.CreateXmlDocument();
    178       //Dictionary<Guid, IStorable> dictionary = new Dictionary<Guid, IStorable>();
    179       //XmlNode rootNode = document.CreateElement("Root");
    180       //document.AppendChild(rootNode);
    181       //rootNode.AppendChild(PersistenceManager.Persist(job, document, dictionary));
    182       //document.Save(stream);
    183       //stream.Close();
    184 
    185       //HeuristicLab.Hive.Contracts.BusinessObjects.SerializedJob executableJobObj =
    186       //  new HeuristicLab.Hive.Contracts.BusinessObjects.SerializedJob();
    187       //executableJobObj.JobInfo = jobObj;
    188       //executableJobObj.SerializedJobData = memStream.ToArray();
    189 
    190       //List<IPluginDescription> plugins = new List<IPluginDescription>();
    191 
    192       //foreach (IStorable storeable in dictionary.Values) {
    193       //  IPluginDescription pluginInfo = ApplicationManager.Manager.GetDeclaringPlugin(storeable.GetType());
    194       //  if (!plugins.Contains(pluginInfo)) {
    195       //    plugins.Add(pluginInfo);
    196       //    foreach (var dependency in pluginInfo.Dependencies) {
    197       //      if (!plugins.Contains(dependency)) plugins.Add(dependency);
    198       //    }
    199       //  }
    200       //}
    201 
    202       //List<HivePluginInfoDto> pluginsNeeded =
    203       //  new List<HivePluginInfoDto>();
    204       //foreach (IPluginDescription uniquePlugin in plugins) {
    205       //  HivePluginInfoDto pluginInfo =
    206       //    new HivePluginInfoDto();
    207       //  pluginInfo.Name = uniquePlugin.Name;
    208       //  pluginInfo.Version = uniquePlugin.Version;
    209       //  pluginInfo.BuildDate = uniquePlugin.BuildDate;
    210       //  pluginsNeeded.Add(pluginInfo);
    211       //}
    212 
    213       //jobObj.CoresNeeded = 1;
    214       //jobObj.PluginsNeeded = pluginsNeeded;
    215       //jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline;
    216       //return executableJobObj;
     177      HeuristicLab.Hive.Contracts.BusinessObjects.JobDto jobObj = new HeuristicLab.Hive.Contracts.BusinessObjects.JobDto();
     178
     179      // create xml document with <Root> as root-node and the persisted job as child
     180      MemoryStream memStream = new MemoryStream();
     181      XmlGenerator.Serialize(job, memStream);
     182
     183      // convert memStream to byte-array
     184      HeuristicLab.Hive.Contracts.BusinessObjects.SerializedJob executableJobObj = new HeuristicLab.Hive.Contracts.BusinessObjects.SerializedJob();
     185      executableJobObj.JobInfo = jobObj;
     186      executableJobObj.SerializedJobData = memStream.ToArray();
     187
     188      // find out which which plugins are needed to recreate the type
     189      List<HivePluginInfoDto> pluginsNeeded = (
     190        from p in GetDeclaringPlugins(job.GetType())
     191        select new HivePluginInfoDto() {
     192          Name = p.Name,
     193          Version = p.Version,
     194          BuildDate = p.BuildDate,
     195        }).ToList();
     196
     197      jobObj.CoresNeeded = 1;
     198      jobObj.PluginsNeeded = pluginsNeeded;
     199      jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline;
     200      return executableJobObj;
     201    }
     202
     203    /// <summary>
     204    /// Returns a list of plugins in which the type itself and all members
     205    /// of the type are declared. Objectgraph is searched recursively.
     206    /// </summary>
     207    private IEnumerable<IPluginDescription> GetDeclaringPlugins(Type type) {
     208      HashSet<Type> types = new HashSet<Type>();
     209      FindTypes(type, types, "HeuristicLab.");
     210      IEnumerable<IPluginDescription> plugins = from t in types
     211                                                select ApplicationManager.Manager.GetDeclaringPlugin(t);
     212      return plugins;
     213    }
     214
     215    /// <summary>
     216    /// Recursively finds all types used in type which are in a namespace which starts with namespaceStart
     217    /// </summary>
     218    /// <param name="type">the type to be searched</param>
     219    /// <param name="types">found types will be stored there, needed in order to avoid duplicates</param>
     220    /// <param name="namespaceStart">only types from namespaces which start with this will be searched and added</param>
     221    private void FindTypes(Type type, HashSet<Type> types, string namespaceStart) {
     222
     223      // search is not performed on attributes
     224
     225      if (!types.Contains(type) && type.Namespace.StartsWith(namespaceStart)) {
     226        types.Add(type);
     227
     228        // interfaces
     229        foreach (Type t in type.GetInterfaces()) {
     230          FindTypes(t, types, namespaceStart);
     231        }
     232
     233        // events
     234        foreach (EventInfo info in type.GetEvents()) {
     235          FindTypes(info.EventHandlerType, types, namespaceStart);
     236          FindTypes(info.DeclaringType, types, namespaceStart);
     237        }
     238
     239        // properties
     240        foreach (PropertyInfo info in type.GetProperties()) {
     241          FindTypes(info.PropertyType, types, namespaceStart);
     242        }
     243
     244        // fields
     245        foreach (FieldInfo info in type.GetFields()) {
     246          FindTypes(info.FieldType, types, namespaceStart);
     247        }
     248
     249        // constructors : maybe constructors them out (?)
     250        foreach (ConstructorInfo info in type.GetConstructors()) {
     251          foreach (ParameterInfo paramInfo in info.GetParameters()) {
     252            FindTypes(paramInfo.ParameterType, types, namespaceStart);
     253          }
     254        }
     255
     256        // methods
     257        foreach (MethodInfo info in type.GetMethods()) {
     258          foreach (ParameterInfo paramInfo in info.GetParameters()) {
     259            FindTypes(paramInfo.ParameterType, types, namespaceStart);
     260          }
     261          FindTypes(info.ReturnType, types, namespaceStart);
     262        }
     263      }
    217264    }
    218265
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Engine/3.3/Job.cs

    r4091 r4107  
    2929using HeuristicLab.Data;
    3030using HeuristicLab.Common;
     31using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3132
    3233namespace HeuristicLab.Hive.Engine {
     
    3435  /// Represents a job that wraps an engine that should be executed in the hive.
    3536  /// </summary>
     37  [StorableClass]
    3638  public class Job : IJob {
     39    [Storable]
    3740    private IEngine engine;
    3841    public IEngine Engine {
     
    7982    public event EventHandler JobFailed;
    8083
     84    [Storable]
    8185    public long JobId {
    8286      get;
     
    8488    }
    8589
     90    [Storable]
    8691    private double progress;
    8792    public double Progress {
Note: See TracChangeset for help on using the changeset viewer.