Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7417


Ignore:
Timestamp:
01/26/12 22:01:38 (13 years ago)
Author:
ascheibe
Message:

#1744 added an option so that the parent task can also wait on the slave for the child tasks to finish

Location:
branches/HiveHiveEngine
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveHiveEngine/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.Designer.cs

    r7287 r7417  
    3939      this.executionTimeTextBox = new System.Windows.Forms.TextBox();
    4040      this.isPrivilegedCheckBox = new System.Windows.Forms.CheckBox();
     41      this.pauseOnWaitCheckbox = new System.Windows.Forms.CheckBox();
    4142      this.tabControl.SuspendLayout();
    4243      this.jobsTabPage.SuspendLayout();
     
    6061      this.resourceIdsTextBox.Location = new System.Drawing.Point(189, 52);
    6162      this.resourceIdsTextBox.Name = "resourceIdsTextBox";
    62       this.resourceIdsTextBox.Size = new System.Drawing.Size(428, 20);
     63      this.resourceIdsTextBox.Size = new System.Drawing.Size(415, 20);
    6364      this.resourceIdsTextBox.TabIndex = 4;
    6465      this.resourceIdsTextBox.Text = "HEAL";
     
    100101      this.executionTimeOnHiveTextBox.Name = "executionTimeOnHiveTextBox";
    101102      this.executionTimeOnHiveTextBox.ReadOnly = true;
    102       this.executionTimeOnHiveTextBox.Size = new System.Drawing.Size(577, 20);
     103      this.executionTimeOnHiveTextBox.Size = new System.Drawing.Size(475, 20);
    103104      this.executionTimeOnHiveTextBox.TabIndex = 8;
    104105      //
     
    135136      this.hiveExperimentListView.Name = "hiveExperimentListView";
    136137      this.hiveExperimentListView.ReadOnly = false;
     138      this.hiveExperimentListView.ShowDetails = true;
    137139      this.hiveExperimentListView.Size = new System.Drawing.Size(686, 428);
    138140      this.hiveExperimentListView.TabIndex = 0;
     
    184186      this.isPrivilegedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    185187      this.isPrivilegedCheckBox.AutoSize = true;
    186       this.isPrivilegedCheckBox.Location = new System.Drawing.Point(623, 54);
     188      this.isPrivilegedCheckBox.Location = new System.Drawing.Point(610, 54);
    187189      this.isPrivilegedCheckBox.Name = "isPrivilegedCheckBox";
    188190      this.isPrivilegedCheckBox.Size = new System.Drawing.Size(80, 17);
     
    192194      this.isPrivilegedCheckBox.Validated += new System.EventHandler(this.isPrivilegedCheckBox_Validated);
    193195      //
     196      // pauseOnWaitCheckbox
     197      //
     198      this.pauseOnWaitCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     199      this.pauseOnWaitCheckbox.AutoSize = true;
     200      this.pauseOnWaitCheckbox.Location = new System.Drawing.Point(610, 28);
     201      this.pauseOnWaitCheckbox.Name = "pauseOnWaitCheckbox";
     202      this.pauseOnWaitCheckbox.Size = new System.Drawing.Size(93, 17);
     203      this.pauseOnWaitCheckbox.TabIndex = 14;
     204      this.pauseOnWaitCheckbox.Text = "Pause on wait";
     205      this.pauseOnWaitCheckbox.UseVisualStyleBackColor = true;
     206      this.pauseOnWaitCheckbox.Validated += new System.EventHandler(this.pauseOnWaitCheckbox_Validated);
     207      //
    194208      // HiveEngineView
    195209      //
    196210      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    197211      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     212      this.Controls.Add(this.pauseOnWaitCheckbox);
    198213      this.Controls.Add(this.isPrivilegedCheckBox);
    199214      this.Controls.Add(this.executionTimeTextBox);
     
    232247    private RefreshableHiveJobListView hiveExperimentListView;
    233248    private System.Windows.Forms.CheckBox isPrivilegedCheckBox;
     249    private System.Windows.Forms.CheckBox pauseOnWaitCheckbox;
    234250  }
    235251}
  • branches/HiveHiveEngine/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.cs

    r7287 r7417  
    7474        executionTimeOnHiveTextBox.Text = string.Empty;
    7575        isPrivilegedCheckBox.Checked = false;
     76        pauseOnWaitCheckbox.Checked = true;
    7677        hiveExperimentListView.Content = null;
    7778        logView.Content = null;
     
    8384        hiveExperimentListView.Content = Content.Jobs;
    8485        logView.Content = Content.Log;
     86        pauseOnWaitCheckbox.Checked = Content.PauseWhileCalculatingChilds;
    8587      }
    8688    }
     
    112114      Content.IsPrivileged = isPrivilegedCheckBox.Checked;
    113115    }
     116
     117    private void pauseOnWaitCheckbox_Validated(object sender, EventArgs e) {
     118      Content.PauseWhileCalculatingChilds = pauseOnWaitCheckbox.Checked;
     119    }
    114120    #endregion
    115121  }
  • branches/HiveHiveEngine/HeuristicLab.HiveEngine/3.3/HiveEngine.cs

    r7320 r7417  
    4747
    4848    [Storable]
     49    public bool PauseWhileCalculatingChilds { get; set; }
     50
     51    [Storable]
    4952    private IOperator currentOperator;
    5053
     
    131134      username = cl.ClientCredentials.UserName.UserName;
    132135      password = cl.ClientCredentials.UserName.Password;
     136      PauseWhileCalculatingChilds = true;
    133137    }
    134138
     
    157161      this.nrOfSentRuns = original.nrOfSentRuns;
    158162      this.ParentTaskId = original.ParentTaskId;
     163      this.PauseWhileCalculatingChilds = original.PauseWhileCalculatingChilds;
    159164      // do not clone jobs - otherwise they would be sent with every task
    160165    }
     
    200205        cancellationToken.ThrowIfCancellationRequested();
    201206
    202         if (continueCollection != null && lastJobGuid != Guid.Empty) {
     207        if (continueCollection != null && lastJobGuid != Guid.Empty && PauseWhileCalculatingChilds) {
    203208          EngineTask[] eTasks = RetrieveResultsFromHive(lastJobGuid);
    204209          RestoreStateFromExecutedHiveTasks(eTasks, continueCollection);
     
    224229
    225230              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              }
    229238            }
    230239            catch {
     
    304313
    305314    /// <summary>
    306     /// This method blocks until all jobs are finished
    307315    /// TODO: Cancelation needs to be refined; all tasks currently stay in Semaphore.WaitOne after cancelation
    308316    /// </summary>
    309317    /// <param name="tasks"></param>
    310     private void ExecuteOnHive(RefreshableJob refreshableJob, EngineTask[] tasks, IScope parentScopeClone, CancellationToken cancellationToken) {
     318    private EngineTask[] ExecuteOnHive(RefreshableJob refreshableJob, EngineTask[] tasks, IScope parentScopeClone, CancellationToken cancellationToken) {
    311319      log.LogMessage(string.Format("Executing {0} operations on the hive.", tasks.Length));
    312320      IScope[] scopes = new Scope[tasks.Length];
     
    319327          var engineHiveTask = new EngineHiveTask(tasks[i], parentScopeClone);
    320328          engineHiveTask.Task.Priority = this.Priority;
    321           if (ParentTaskId != Guid.Empty) {
     329          if (ParentTaskId != Guid.Empty && PauseWhileCalculatingChilds) {
    322330            engineHiveTask.Task.ParentTaskId = ParentTaskId;
    323331          }
     
    325333
    326334          // 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             random.Reset(random.Next());
     335          //IRandom random = FindRandomParameter(tasks[i].InitialOperation as IExecutionContext);
     336          //if (random != null)
     337          //random.Reset(random.Next());
    330338        }
    331339        HiveClient.StartJob((e) => { log.LogException(e); }, refreshableJob, cancellationToken);
     
    338346        handle.WaitOne();
    339347        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        }
    340377      }
    341378      catch (OperationCanceledException e) {
Note: See TracChangeset for help on using the changeset viewer.