- Timestamp:
- 07/26/10 18:17:16 (14 years ago)
- 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 100 100 <HintPath>..\..\..\..\..\..\..\..\..\Programme\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath> 101 101 </Reference> 102 <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 102 103 <Reference Include="HeuristicLab.PluginInfrastructure-3.3"> 103 104 <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 28 28 using System.Xml; 29 29 using System.IO.Compression; 30 using System.Linq; 30 31 using HeuristicLab.Common; 31 32 using HeuristicLab.Hive.JobBase; … … 35 36 using HeuristicLab.Hive.Contracts.BusinessObjects; 36 37 using HeuristicLab.Tracing; 38 using HeuristicLab.Persistence.Default.Xml; 39 using System.Reflection; 37 40 38 41 namespace HeuristicLab.Hive.Engine { … … 49 52 private object locker = new object(); 50 53 private volatile bool abortRequested; 54 private ThreadPriority priority; 51 55 52 56 public string HiveServerUrl { get; set; } … … 55 59 56 60 public HiveEngine() { 61 // <debug> 62 HiveServerUrl = "net.tcp://10.42.1.153:9000/ExecutionEngine/ExecutionEngineFacade"; 63 RessourceIds = "MyGroup"; 64 // </debug> 65 57 66 job = new Job(); 58 67 abortRequested = false; … … 73 82 74 83 public ThreadPriority Priority { 75 get { return this. Priority; }76 set { this. Priority = value; }84 get { return this.priority; } 85 set { this.priority = value; } 77 86 } 78 87 … … 148 157 if (response.Success && response.Obj != null && response.StatusMessage != ApplicationConstants.RESPONSE_JOB_RESULT_NOT_YET_HERE) { 149 158 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)); 152 160 Logger.Debug("HiveEngine: Results-polling - IsSnapshotResult: " + (restoredJob.Progress < 1.0)); 153 161 } … … 167 175 168 176 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 } 217 264 } 218 265 -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Engine/3.3/Job.cs
r4091 r4107 29 29 using HeuristicLab.Data; 30 30 using HeuristicLab.Common; 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 32 32 33 namespace HeuristicLab.Hive.Engine { … … 34 35 /// Represents a job that wraps an engine that should be executed in the hive. 35 36 /// </summary> 37 [StorableClass] 36 38 public class Job : IJob { 39 [Storable] 37 40 private IEngine engine; 38 41 public IEngine Engine { … … 79 82 public event EventHandler JobFailed; 80 83 84 [Storable] 81 85 public long JobId { 82 86 get; … … 84 88 } 85 89 90 [Storable] 86 91 private double progress; 87 92 public double Progress {
Note: See TracChangeset
for help on using the changeset viewer.