- Timestamp:
- 01/26/12 22:01:38 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveHiveEngine/HeuristicLab.HiveEngine/3.3/HiveEngine.cs
r7320 r7417 47 47 48 48 [Storable] 49 public bool PauseWhileCalculatingChilds { get; set; } 50 51 [Storable] 49 52 private IOperator currentOperator; 50 53 … … 131 134 username = cl.ClientCredentials.UserName.UserName; 132 135 password = cl.ClientCredentials.UserName.Password; 136 PauseWhileCalculatingChilds = true; 133 137 } 134 138 … … 157 161 this.nrOfSentRuns = original.nrOfSentRuns; 158 162 this.ParentTaskId = original.ParentTaskId; 163 this.PauseWhileCalculatingChilds = original.PauseWhileCalculatingChilds; 159 164 // do not clone jobs - otherwise they would be sent with every task 160 165 } … … 200 205 cancellationToken.ThrowIfCancellationRequested(); 201 206 202 if (continueCollection != null && lastJobGuid != Guid.Empty ) {207 if (continueCollection != null && lastJobGuid != Guid.Empty && PauseWhileCalculatingChilds) { 203 208 EngineTask[] eTasks = RetrieveResultsFromHive(lastJobGuid); 204 209 RestoreStateFromExecutedHiveTasks(eTasks, continueCollection); … … 224 229 225 230 var experiment = CreateJob(); 226 ExecuteOnHive(experiment, tasks, parentScopeClone, new CancellationToken()); 227 continueCollection = coll; 228 Pause(); 231 var engineTasks = ExecuteOnHive(experiment, tasks, parentScopeClone, new CancellationToken()); 232 if (PauseWhileCalculatingChilds) { 233 continueCollection = coll; 234 Pause(); 235 } else { 236 RestoreStateFromExecutedHiveTasks(engineTasks, coll); 237 } 229 238 } 230 239 catch { … … 304 313 305 314 /// <summary> 306 /// This method blocks until all jobs are finished307 315 /// TODO: Cancelation needs to be refined; all tasks currently stay in Semaphore.WaitOne after cancelation 308 316 /// </summary> 309 317 /// <param name="tasks"></param> 310 private voidExecuteOnHive(RefreshableJob refreshableJob, EngineTask[] tasks, IScope parentScopeClone, CancellationToken cancellationToken) {318 private EngineTask[] ExecuteOnHive(RefreshableJob refreshableJob, EngineTask[] tasks, IScope parentScopeClone, CancellationToken cancellationToken) { 311 319 log.LogMessage(string.Format("Executing {0} operations on the hive.", tasks.Length)); 312 320 IScope[] scopes = new Scope[tasks.Length]; … … 319 327 var engineHiveTask = new EngineHiveTask(tasks[i], parentScopeClone); 320 328 engineHiveTask.Task.Priority = this.Priority; 321 if (ParentTaskId != Guid.Empty ) {329 if (ParentTaskId != Guid.Empty && PauseWhileCalculatingChilds) { 322 330 engineHiveTask.Task.ParentTaskId = ParentTaskId; 323 331 } … … 325 333 326 334 // shuffle random variable to avoid the same random sequence in each operation; todo: does not yet work (it cannot find the random variable) 327 IRandom random = FindRandomParameter(tasks[i].InitialOperation as IExecutionContext);328 if (random != null)329 335 //IRandom random = FindRandomParameter(tasks[i].InitialOperation as IExecutionContext); 336 //if (random != null) 337 //random.Reset(random.Next()); 330 338 } 331 339 HiveClient.StartJob((e) => { log.LogException(e); }, refreshableJob, cancellationToken); … … 338 346 handle.WaitOne(); 339 347 refreshableJob.Progress.Finished -= new EventHandler(Progress_Finished); 348 349 if (!PauseWhileCalculatingChilds) { 350 351 while (!refreshableJob.AllJobsFinished()) { 352 Thread.Sleep(1000); 353 } 354 355 List<HiveTask> allHiveTasks = refreshableJob.HiveTasks.ToList(); 356 allHiveTasks.ForEach(x => this.ExecutionTimeOnHive += x.Task.ExecutionTime); 357 358 var failedJobs = allHiveTasks.Where(x => x.Task.State != TaskState.Finished); 359 if (failedJobs.Count() > 0) { 360 throw new HiveEngineException("Task (" + failedJobs.First().Task.Id + ") failed: " + failedJobs.First().Task.StateLog.Last().Exception); 361 } 362 363 List<EngineTask> engineTasks = new List<EngineTask>(); 364 365 foreach (var hTask in allHiveTasks) { 366 EngineTask ehTask = (EngineTask)hTask.ItemTask; 367 engineTasks.Add(ehTask); 368 } 369 370 jobs.Clear(); 371 DeleteHiveExperiment(refreshableJob.Id); 372 373 return engineTasks.ToArray(); 374 } else { 375 return null; 376 } 340 377 } 341 378 catch (OperationCanceledException e) {
Note: See TracChangeset
for help on using the changeset viewer.