- Timestamp:
- 06/18/09 17:43:23 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Grid.HiveBridge/3.2/HiveGridServerWrapper.cs
r2058 r2064 65 65 ResponseObject<JobResult> response = executionEngineFacade.GetLastResult(guid, false); 66 66 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(); 69 79 } else return null; 70 80 } … … 73 83 HeuristicLab.Hive.Contracts.BusinessObjects.Job jobObj = new HeuristicLab.Hive.Contracts.BusinessObjects.Job(); 74 84 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) { 75 111 // unzip and restore to determine the list of required plugins (NB: inefficient!) 76 MemoryStream memStream = new MemoryStream( );112 MemoryStream memStream = new MemoryStream(serializedEngine); 77 113 GZipStream stream = new GZipStream(memStream, CompressionMode.Decompress, true); 78 114 XmlDocument document = new XmlDocument(); … … 80 116 81 117 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); 84 120 stream.Close(); 85 121 … … 97 133 } 98 134 99 List<HivePluginInfo> pluginsNeeded =100 new List<HivePluginInfo>();101 135 foreach (PluginInfo uniquePlugin in plugins) { 102 136 HivePluginInfo pluginInfo = … … 105 139 pluginInfo.Version = uniquePlugin.Version.ToString(); 106 140 pluginInfo.BuildDate = uniquePlugin.BuildDate; 107 pluginsNeeded.Add(pluginInfo);141 requiredPlugins.Add(pluginInfo); 108 142 } 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; 115 144 } 116 145 }
Note: See TracChangeset
for help on using the changeset viewer.