Changeset 5136
- Timestamp:
- 12/20/10 19:05:33 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HeuristicLab.HiveEngine-3.3.csproj
r5134 r5136 9 9 <OutputType>Library</OutputType> 10 10 <AppDesignerFolder>Properties</AppDesignerFolder> 11 <RootNamespace>HeuristicLab.Hive ParallelEngine</RootNamespace>12 <AssemblyName>HeuristicLab.Hive ParallelEngine-3.3</AssemblyName>11 <RootNamespace>HeuristicLab.HiveEngine</RootNamespace> 12 <AssemblyName>HeuristicLab.HiveEngine-3.3</AssemblyName> 13 13 <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> 14 14 <FileAlignment>512</FileAlignment> … … 33 33 </PropertyGroup> 34 34 <ItemGroup> 35 <Reference Include="HeuristicLab.Clients.Common-3.3"> 36 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Clients.Common-3.3.dll</HintPath> 37 </Reference> 38 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 39 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Collections-3.3.dll</HintPath> 40 </Reference> 35 41 <Reference Include="HeuristicLab.Common-3.3"> 36 42 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath> 43 </Reference> 44 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 45 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common.Resources-3.3.dll</HintPath> 37 46 </Reference> 38 47 <Reference Include="HeuristicLab.Core-3.3"> … … 45 54 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 46 55 </Reference> 56 <Reference Include="HeuristicLab.SequentialEngine-3.3"> 57 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.SequentialEngine-3.3.dll</HintPath> 58 </Reference> 47 59 <Reference Include="System" /> 48 60 <Reference Include="System.Core" /> 61 <Reference Include="System.Drawing" /> 49 62 <Reference Include="System.Xml.Linq" /> 50 63 <Reference Include="System.Data.DataSetExtensions" /> … … 53 66 </ItemGroup> 54 67 <ItemGroup> 68 <Compile Include="ScopeMergeException.cs" /> 55 69 <None Include="Properties\AssemblyInfo.cs.frame" /> 56 70 <None Include="HeuristicLabHiveEnginePlugin.cs.frame" /> 57 71 <Compile Include="HeuristicLabHiveEnginePlugin.cs" /> 58 72 <Compile Include="HiveEngine.cs" /> 73 <Compile Include="OperationJob.cs" /> 59 74 <Compile Include="Properties\AssemblyInfo.cs" /> 75 </ItemGroup> 76 <ItemGroup> 77 <ProjectReference Include="..\..\HeuristicLab.DataAccess\3.3\HeuristicLab.DataAccess-3.3.csproj"> 78 <Project>{9076697B-C151-46CD-95BC-1D059492B478}</Project> 79 <Name>HeuristicLab.DataAccess-3.3</Name> 80 </ProjectReference> 81 <ProjectReference Include="..\..\HeuristicLab.Hive.Contracts\3.3\HeuristicLab.Hive.Contracts-3.3.csproj"> 82 <Project>{134F93D7-E7C8-4ECD-9923-7F63259A60D8}</Project> 83 <Name>HeuristicLab.Hive.Contracts-3.3</Name> 84 </ProjectReference> 85 <ProjectReference Include="..\..\HeuristicLab.Hive.ExperimentManager\3.3\HeuristicLab.Hive.ExperimentManager-3.3.csproj"> 86 <Project>{A84C0A25-13D0-40A6-924F-53556D9691DC}</Project> 87 <Name>HeuristicLab.Hive.ExperimentManager-3.3</Name> 88 </ProjectReference> 89 <ProjectReference Include="..\..\HeuristicLab.Hive.JobBase\3.3\HeuristicLab.Hive.JobBase-3.3.csproj"> 90 <Project>{21187322-52DD-4243-80A4-A85F0263E63B}</Project> 91 <Name>HeuristicLab.Hive.JobBase-3.3</Name> 92 </ProjectReference> 60 93 </ItemGroup> 61 94 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HeuristicLabHiveEnginePlugin.cs.frame
r5134 r5136 5 5 using HeuristicLab.PluginInfrastructure; 6 6 7 namespace H iveParallelEngine {7 namespace HeuristicLab.HiveEngine { 8 8 /// <summary> 9 /// Plugin class for HeuristicLab.Hive ParallelEngine plugin.9 /// Plugin class for HeuristicLab.HiveEngine plugin. 10 10 /// </summary> 11 [Plugin("HeuristicLab.SequentialEngine", "3.3.2.$WCREV$")] 12 [PluginFile("HeuristicLab.SequentialEngine-3.3.dll", PluginFileType.Assembly)] 11 [Plugin("HeuristicLab.HiveEngine", "3.3.2.$WCREV$")] 12 [PluginFile("HeuristicLab.HiveEngine-3.3.dll", PluginFileType.Assembly)] 13 [PluginDependency("HeuristicLab.Clients.Common", "3.3")] 14 [PluginDependency("HeuristicLab.Collections", "3.3")] 13 15 [PluginDependency("HeuristicLab.Common", "3.3")] 16 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 14 17 [PluginDependency("HeuristicLab.Core", "3.3")] 18 [PluginDependency("HeuristicLab.DataAccess", "3.3")] 19 [PluginDependency("HeuristicLab.Hive.Contracts", "3.3")] 20 [PluginDependency("HeuristicLab.Hive.ExperimentManager", "3.3")] 21 [PluginDependency("HeuristicLab.Hive.JobBase", "3.3")] 15 22 [PluginDependency("HeuristicLab.Persistence", "3.3")] 16 class HeuristicLabHiveParallelEnginePlugin { 23 [PluginDependency("HeuristicLab.SequentialEngine", "3.3")] 24 public class HeuristicLabHiveEnginePlugin : PluginBase { 17 25 } 18 26 } -
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HiveEngine.cs
r5134 r5136 6 6 using HeuristicLab.Core; 7 7 using HeuristicLab.Common; 8 using HeuristicLab.Hive.Contracts.Interfaces; 9 using HeuristicLab.Clients.Common; 10 using HeuristicLab.Hive.ExperimentManager; 11 using HeuristicLab.Hive.Contracts.BusinessObjects; 12 using HeuristicLab.PluginInfrastructure; 13 using HeuristicLab.Hive.Contracts.ResponseObjects; 14 using System.Threading; 8 15 9 namespace HeuristicLab.Hive ParallelEngine {16 namespace HeuristicLab.HiveEngine { 10 17 /// <summary> 11 18 /// Represents an engine that executes operations which can be executed in parallel on the hive … … 20 27 [StorableConstructor] 21 28 protected HiveEngine(bool deserializing) : base(deserializing) { } 22 protected HiveEngine(HiveEngine original, Cloner cloner) : base(original, cloner) { 29 protected HiveEngine(HiveEngine original, Cloner cloner) 30 : base(original, cloner) { 23 31 } 24 32 public override IDeepCloneable Clone(Cloner cloner) { … … 32 40 OperationCollection coll = next as OperationCollection; 33 41 34 if (coll.Parallel) { 35 36 } else { 37 while (coll != null) { 42 while (coll != null) { 43 if (coll.Parallel) { 44 IScope scope = ((IAtomicOperation)coll.Where(x => x is IAtomicOperation).First()).Scope; 45 IEnumerable<IOperation> finishedOperations = ExecuteOnHive(coll.Select(op => new OperationJob(op))); 46 foreach (IOperation op in finishedOperations) { 47 ReIntegrateScope(scope, op); 48 } 49 } else { 38 50 for (int i = coll.Count - 1; i >= 0; i--) 39 51 ExecutionStack.Push(coll[i]); 40 next = ExecutionStack.Count > 0 ? ExecutionStack.Pop() : null;41 coll = next as OperationCollection;42 52 } 53 next = ExecutionStack.Count > 0 ? ExecutionStack.Pop() : null; 54 coll = next as OperationCollection; 43 55 } 44 56 … … 61 73 } 62 74 75 private static void ReIntegrateScope(IScope scope, IOperation operation) { 76 if (operation is IAtomicOperation) { 77 MergeScopes(scope, ((IAtomicOperation)operation).Scope); 78 } else if (operation is OperationCollection) { 79 foreach (IOperation op in (OperationCollection)operation) { 80 ReIntegrateScope(scope, op); 81 } 82 } 83 } 84 85 private static void MergeScopes(IScope target, IScope source) { 86 foreach (IVariable variable in source.Variables) { 87 if (target.Variables.ContainsKey(variable.Name)) { 88 if (target.Variables[variable.Name] != source.Variables[variable.Name]) { 89 // problem: ResultCollection are not equal altough they contain the same values. 90 // - either implement ResultCollection.Equals, or consider ResultCollection as special case here 91 //throw new ScopeMergeException(string.Format("Variable {0} already exists in target scope and has a different value ({1}, {2}).", variable.Name, target.Variables[variable.Name].Value, variable.Value)); 92 } 93 } else { 94 target.Variables.Add(variable); 95 } 96 } 97 98 //this is not useful on the parentscope of the initial scope 99 //foreach (IScope subScope in source.SubScopes) { 100 // target.SubScopes.Add(subScope); 101 //} 102 103 if (target.Parent != null && source.Parent != null) 104 MergeScopes(target.Parent, source.Parent); 105 } 106 107 108 private IEnumerable<IOperation> TestExecuteOnHive(IEnumerable<OperationJob> operationJobs) { 109 //var clonedJobs = operationJobs.Select(x => (OperationJob)x.Clone()).ToArray(); 110 var results = new List<IOperation>(); 111 112 foreach (var job in operationJobs) { 113 job.Start(); 114 while (job.ExecutionState != Core.ExecutionState.Stopped) { 115 Thread.Sleep(100); 116 } 117 results.Add(job.Operation); 118 } 119 return results; 120 } 121 122 private IEnumerable<IOperation> ExecuteOnHive(IEnumerable<OperationJob> operationJobs) { 123 IEnumerable<Guid> jobIds; 124 JobResultList results; 125 126 127 using (Disposable<IClientFacade> service = ServiceLocator.Instance.StreamedClientFacadePool.GetService()) { 128 List<JobDto> jobs = new List<JobDto>(); 129 foreach (OperationJob operationJob in operationJobs) { 130 var groups = new string[] { "HEAL" }; 131 SerializedJob serializedJob = new SerializedJob(); 132 serializedJob.SerializedJobData = SerializedJob.Serialize(operationJob); 133 serializedJob.JobInfo = new JobDto(); 134 serializedJob.JobInfo.State = JobState.Offline; 135 serializedJob.JobInfo.CoresNeeded = 1; 136 serializedJob.JobInfo.PluginsNeeded = ApplicationManager.Manager.Plugins.Select(x => new HivePluginInfoDto { Name = x.Name, Version = x.Version }).ToList(); 137 ResponseObject<JobDto> response = service.Obj.AddJobWithGroupStrings(serializedJob, groups); 138 jobs.Add(response.Obj); 139 } 140 jobIds = jobs.Select(x => x.Id); 141 results = service.Obj.GetJobResults(jobIds).Obj; 142 } 143 144 while (!results.All( 145 x => x.State == JobState.Finished || 146 x.State == JobState.Failed || 147 x.State == JobState.Aborted)) { 148 Thread.Sleep(5000); 149 using (Disposable<IClientFacade> service = ServiceLocator.Instance.StreamedClientFacadePool.GetService()) { 150 results = service.Obj.GetJobResults(jobIds).Obj; 151 } 152 } 153 154 // all finished 155 List<OperationJob> finishedJobs = new List<OperationJob>(); 156 using (Disposable<IClientFacade> service = ServiceLocator.Instance.StreamedClientFacadePool.GetService()) { 157 foreach (Guid jobId in jobIds) { 158 SerializedJob serializedJob = service.Obj.GetLastSerializedResult(jobId).Obj; 159 OperationJob operationJob = SerializedJob.Deserialize<OperationJob>(serializedJob.SerializedJobData); 160 finishedJobs.Add(operationJob); 161 } 162 } 163 164 // delete jobs 165 // TODO 166 167 return finishedJobs.Select(x => x.Operation); 168 } 169 63 170 public override void Pause() { 64 171 base.Pause();
Note: See TracChangeset
for help on using the changeset viewer.