Changeset 2064


Ignore:
Timestamp:
06/18/09 17:43:23 (12 years ago)
Author:
gkronber
Message:

Fixed a few bugs in bridge from grid to hive. #642 (Hive backend for CEDMA)

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/GridExecuter.cs

    r2058 r2064  
    7171            if (algorithm != null) {
    7272              AtomicOperation op = new AtomicOperation(algorithm.Engine.OperatorGraph.InitialOperator, algorithm.Engine.GlobalScope);
    73               AsyncGridResult asyncResult = jobManager.BeginExecuteEngine(new ProcessingEngine(algorithm.Engine.GlobalScope, op));
     73              ProcessingEngine procEngine = new ProcessingEngine(algorithm.Engine.GlobalScope, op);
     74              procEngine.OperatorGraph.AddOperator(algorithm.Engine.OperatorGraph.InitialOperator);
     75              procEngine.OperatorGraph.InitialOperator = algorithm.Engine.OperatorGraph.InitialOperator;
     76              AsyncGridResult asyncResult = jobManager.BeginExecuteEngine(procEngine);
    7477              asyncResults.Add(asyncResult.WaitHandle, asyncResult);
    7578              lock (activeAlgorithms) {
  • trunk/sources/HeuristicLab.Grid.HiveBridge/3.2/HeuristicLab.Grid.HiveBridge-3.2.csproj

    r2059 r2064  
    6969    <Compile Include="HiveGridServerWrapper.cs" />
    7070    <Compile Include="HeuristicLabGridHiveBridgePlugin.cs" />
     71    <Compile Include="Properties\AssemblyInfo.cs" />
    7172    <Compile Include="ServiceLocator.cs" />
    7273  </ItemGroup>
     
    8788      <Project>{134F93D7-E7C8-4ECD-9923-7F63259A60D8}</Project>
    8889      <Name>HeuristicLab.Hive.Contracts-3.2</Name>
     90    </ProjectReference>
     91    <ProjectReference Include="..\..\HeuristicLab.Hive.Engine\3.2\HeuristicLab.Hive.Engine-3.2.csproj">
     92      <Project>{C8FEDAC1-0326-4293-B585-F0FEDDEDFC11}</Project>
     93      <Name>HeuristicLab.Hive.Engine-3.2</Name>
    8994    </ProjectReference>
    9095    <ProjectReference Include="..\..\HeuristicLab.Hive.JobBase\3.2\HeuristicLab.Hive.JobBase-3.2.csproj">
  • trunk/sources/HeuristicLab.Grid.HiveBridge/3.2/HeuristicLabGridHiveBridgePlugin.cs

    r2058 r2064  
    3232  [Dependency(Dependency = "HeuristicLab.Hive.Contracts-3.2")]
    3333  [Dependency(Dependency = "HeuristicLab.Hive.JobBase-3.2")]
     34  [Dependency(Dependency = "HeuristicLab.Hive.Engine-3.2")]
    3435  public class HeuristicLabGridPlugin : PluginBase {
    3536  }
  • trunk/sources/HeuristicLab.Grid.HiveBridge/3.2/HiveGridServerWrapper.cs

    r2058 r2064  
    6565      ResponseObject<JobResult> response = executionEngineFacade.GetLastResult(guid, false);
    6666      if (response.Success && response.Obj != null) {
    67         Job restoredJob = (Job)PersistenceManager.RestoreFromGZip(response.Obj.Result);
    68         return restoredJob.SerializedJob;
     67        HeuristicLab.Hive.Engine.Job restoredJob = (HeuristicLab.Hive.Engine.Job)PersistenceManager.RestoreFromGZip(response.Obj.Result);
     68        // Serialize the engine
     69        MemoryStream memStream = new MemoryStream();
     70        GZipStream stream = new GZipStream(memStream, CompressionMode.Compress, true);
     71        XmlDocument document = PersistenceManager.CreateXmlDocument();
     72        Dictionary<Guid, IStorable> dictionary = new Dictionary<Guid, IStorable>();
     73        XmlNode rootNode = document.CreateElement("Root");
     74        document.AppendChild(rootNode);
     75        rootNode.AppendChild(PersistenceManager.Persist(restoredJob.Engine, document, dictionary));
     76        document.Save(stream);
     77        stream.Close();
     78        return memStream.ToArray();
    6979      } else return null;
    7080    }
     
    7383      HeuristicLab.Hive.Contracts.BusinessObjects.Job jobObj = new HeuristicLab.Hive.Contracts.BusinessObjects.Job();
    7484
     85      List<HivePluginInfo> requiredPlugins = new List<HivePluginInfo>();
     86      IEngine engine = RestoreEngine(serializedEngine, requiredPlugins);
     87
     88      HeuristicLab.Hive.Engine.Job job = new HeuristicLab.Hive.Engine.Job();
     89      job.Engine.OperatorGraph.AddOperator(engine.OperatorGraph.InitialOperator);
     90      job.Engine.OperatorGraph.InitialOperator = engine.OperatorGraph.InitialOperator;
     91
     92      // Serialize the job
     93      MemoryStream memStream = new MemoryStream();
     94      GZipStream stream = new GZipStream(memStream, CompressionMode.Compress, true);
     95      XmlDocument document = PersistenceManager.CreateXmlDocument();
     96      Dictionary<Guid, IStorable> dictionary = new Dictionary<Guid, IStorable>();
     97      XmlNode rootNode = document.CreateElement("Root");
     98      document.AppendChild(rootNode);
     99      rootNode.AppendChild(PersistenceManager.Persist(job, document, dictionary));
     100      document.Save(stream);
     101      stream.Close();
     102
     103      jobObj.SerializedJob = memStream.ToArray();
     104      jobObj.CoresNeeded = 1;
     105      jobObj.PluginsNeeded = requiredPlugins;
     106      jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline;
     107      return jobObj;
     108    }
     109
     110    private IEngine RestoreEngine(byte[] serializedEngine, List<HivePluginInfo> requiredPlugins) {
    75111      // unzip and restore to determine the list of required plugins (NB: inefficient!)
    76       MemoryStream memStream = new MemoryStream();
     112      MemoryStream memStream = new MemoryStream(serializedEngine);
    77113      GZipStream stream = new GZipStream(memStream, CompressionMode.Decompress, true);
    78114      XmlDocument document = new XmlDocument();
     
    80116
    81117      Dictionary<Guid, IStorable> dictionary = new Dictionary<Guid, IStorable>();
    82       XmlNode rootNode = document.ChildNodes[0].ChildNodes[0];
    83       PersistenceManager.Restore(rootNode, dictionary);
     118      XmlNode rootNode = document.ChildNodes[1].ChildNodes[0];
     119      IEngine engine = (IEngine)PersistenceManager.Restore(rootNode, dictionary);
    84120      stream.Close();
    85121
     
    97133      }
    98134
    99       List<HivePluginInfo> pluginsNeeded =
    100         new List<HivePluginInfo>();
    101135      foreach (PluginInfo uniquePlugin in plugins) {
    102136        HivePluginInfo pluginInfo =
     
    105139        pluginInfo.Version = uniquePlugin.Version.ToString();
    106140        pluginInfo.BuildDate = uniquePlugin.BuildDate;
    107         pluginsNeeded.Add(pluginInfo);
     141        requiredPlugins.Add(pluginInfo);
    108142      }
    109 
    110       jobObj.SerializedJob = serializedEngine;
    111       jobObj.CoresNeeded = 1;
    112       jobObj.PluginsNeeded = pluginsNeeded;
    113       jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline;
    114       return jobObj;
     143      return engine;
    115144    }
    116145  }
Note: See TracChangeset for help on using the changeset viewer.