- Timestamp:
- 04/12/11 13:43:05 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources
- Property svn:ignore
-
old new 4 4 PrecompiledWeb 5 5 CreateEventLogSources 6 WindowsFormsTestProject
-
- Property svn:ignore
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4
- Property svn:ignore
-
old new 2 2 obj 3 3 HeuristicLab.HiveEngine-3.4.csproj.vs10x 4 HeuristicLabHiveEnginePlugin.cs
-
- Property svn:ignore
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs
r6000 r6006 25 25 26 26 [Storable] 27 public string Resource Ids { get; set; }27 public string ResourceNames { get; set; } 28 28 29 29 [Storable] … … 46 46 } 47 47 48 [Storable] 49 private bool useLocalPlugins; 50 public bool UseLocalPlugins { 51 get { return useLocalPlugins; } 52 set { useLocalPlugins = value; } 53 } 54 55 [Storable] 56 private ItemCollection<HiveExperiment> hiveExperiments; 57 public ItemCollection<HiveExperiment> HiveExperiments { 58 get { return hiveExperiments; } 59 set { hiveExperiments = value; } 60 } 61 48 62 private List<Plugin> onlinePlugins; 49 63 public List<Plugin> OnlinePlugins { … … 60 74 #region constructors and cloning 61 75 public HiveEngine() { 62 ResourceIds = "HEAL"; 76 ResourceNames = "HEAL"; 77 HiveExperiments = new ItemCollection<HiveExperiment>(); 78 Priority = 0; 63 79 } 64 80 … … 67 83 protected HiveEngine(HiveEngine original, Cloner cloner) 68 84 : base(original, cloner) { 69 this.Resource Ids = original.ResourceIds;85 this.ResourceNames = original.ResourceNames; 70 86 this.currentOperator = cloner.Clone(original.currentOperator); 71 87 this.priority = original.priority; 72 88 this.executionTimeOnHive = original.executionTimeOnHive; 89 this.useLocalPlugins = original.useLocalPlugins; 73 90 } 74 91 public override IDeepCloneable Clone(Cloner cloner) { … … 123 140 124 141 IScope[] scopes = ExecuteOnHive(jobs, parentScopeClone, cancellationToken); 125 //IScope[] scopes = ExecuteLocally(jobs, parentScopeClone, cancellationToken);126 142 127 143 for (int i = 0; i < coll.Count; i++) { … … 186 202 } 187 203 188 private IScope[] ExecuteLocally(EngineJob[] jobs, IScope parentScopeClone, CancellationToken cancellationToken) { 189 IScope[] scopes = new Scope[jobs.Length]; 190 191 for (int i = 0; i < jobs.Length; i++) { 192 var job = (EngineJob)jobs[i].Clone(); 193 job.Start(); 194 while (job.ExecutionState != ExecutionState.Stopped) { 195 Thread.Sleep(100); 196 } 197 scopes[i] = ((IAtomicOperation)job.InitialOperation).Scope; 198 } 199 200 return scopes; 201 } 204 // testfunction: 205 //private IScope[] ExecuteLocally(EngineJob[] jobs, IScope parentScopeClone, CancellationToken cancellationToken) { 206 // IScope[] scopes = new Scope[jobs.Length]; 207 // for (int i = 0; i < jobs.Length; i++) { 208 // var job = (EngineJob)jobs[i].Clone(); 209 // job.Start(); 210 // while (job.ExecutionState != ExecutionState.Stopped) { 211 // Thread.Sleep(100); 212 // } 213 // scopes[i] = ((IAtomicOperation)job.InitialOperation).Scope; 214 // } 215 // return scopes; 216 //} 202 217 203 218 /// <summary> … … 211 226 object locker = new object(); 212 227 IDictionary<Guid, int> jobIndices = new Dictionary<Guid, int>(); 228 var hiveExperiment = new HiveExperiment();; 213 229 214 230 try { … … 218 234 int finishedCount = 0; 219 235 int uploadCount = 0; 236 237 // create hive experiment 238 hiveExperiment.Name = "HiveEngine Run " + hiveExperiments.Count; 239 hiveExperiment.UseLocalPlugins = this.UseLocalPlugins; 240 hiveExperiment.ResourceNames = this.ResourceNames; 241 hiveExperiment.RefreshAutomatically = false; 242 hiveExperiment.Id = ServiceLocator.Instance.CallHiveService(s => s.AddHiveExperiment(hiveExperiment)); 243 hiveExperiments.Add(hiveExperiment); 220 244 221 245 // create upload-tasks … … 230 254 231 255 uploadTasks.Add(Task.Factory.StartNew<Job>((keyValuePairObj) => { 232 return UploadJob(keyValuePairObj, parentScopeClone, cancellationToken, GetResourceIds() );256 return UploadJob(keyValuePairObj, parentScopeClone, cancellationToken, GetResourceIds(), hiveExperiment.Id); 233 257 }, new KeyValuePair<int, EngineJob>(i, job), cancellationToken)); 234 258 } … … 313 337 314 338 LogMessage(string.Format("All jobs finished (TotalExecutionTime: {0}).", executionTimes.Sum())); 315 Delete Jobs(jobIndices);339 DeleteHiveExperiment(hiveExperiment.Id); 316 340 317 341 return scopes; … … 319 343 catch (OperationCanceledException e) { 320 344 lock (locker) { 321 if (jobIndices != null) Delete Jobs(jobIndices);345 if (jobIndices != null) DeleteHiveExperiment(hiveExperiment.Id); 322 346 } 323 347 throw e; … … 325 349 catch (Exception e) { 326 350 lock (locker) { 327 if (jobIndices != null) Delete Jobs(jobIndices);351 if (jobIndices != null) DeleteHiveExperiment(hiveExperiment.Id); 328 352 } 329 353 LogException(e); … … 332 356 } 333 357 334 private void DeleteJobs(IDictionary<Guid, int> jobIndices) { 335 if (jobIndices.Count > 0) { 336 TryAndRepeat(() => { 337 LogMessage(string.Format("Deleting {0} jobs on hive.", jobIndices.Count)); 338 ServiceLocator.Instance.CallHiveService(service => { 339 foreach (Guid jobId in jobIndices.Keys) { 340 service.DeleteJob(jobId); 341 } 342 jobIndices.Clear(); 343 }); 344 }, 5, string.Format("Could not delete {0} jobs", jobIndices.Count)); 345 } 358 private void DeleteHiveExperiment(Guid hiveExperimentId) { 359 TryAndRepeat(() => { 360 ServiceLocator.Instance.CallHiveService(s => s.DeleteHiveExperiment(hiveExperimentId)); 361 }, 5, string.Format("Could not delete jobs")); 346 362 } 347 363 348 364 private static object locker = new object(); 349 private Job UploadJob(object keyValuePairObj, IScope parentScopeClone, CancellationToken cancellationToken, List<Guid> resourceIds ) {365 private Job UploadJob(object keyValuePairObj, IScope parentScopeClone, CancellationToken cancellationToken, List<Guid> resourceIds, Guid hiveExperimentId) { 350 366 var keyValuePair = (KeyValuePair<int, EngineJob>)keyValuePairObj; 351 367 Job job = new Job(); … … 370 386 job.PluginsNeededIds = ServiceLocator.Instance.CallHiveService(s => PluginUtil.GetPluginDependencies(s, this.OnlinePlugins, this.AlreadyUploadedPlugins, neededPlugins, false)); 371 387 job.Priority = priority; 388 job.HiveExperimentId = hiveExperimentId; 372 389 373 390 try { … … 396 413 private List<Guid> GetResourceIds() { 397 414 return ServiceLocator.Instance.CallHiveService(service => { 398 var resourceNames = Resource Ids.Split(';');415 var resourceNames = ResourceNames.Split(';'); 399 416 var resourceIds = new List<Guid>(); 400 417 foreach (var resourceName in resourceNames) {
Note: See TracChangeset
for help on using the changeset viewer.