Changeset 15262


Ignore:
Timestamp:
07/16/17 13:08:06 (2 months ago)
Author:
jkarder
Message:

#2784: merged r14901 and r15121 into stable

Location:
stable
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs

    r14186 r15262  
    6060      this.startButton = new System.Windows.Forms.Button();
    6161      this.stopButton = new System.Windows.Forms.Button();
    62       this.resetButton = new System.Windows.Forms.Button();
    6362      this.executionTimeLabel = new System.Windows.Forms.Label();
    6463      this.executionTimeTextBox = new System.Windows.Forms.TextBox();
     
    271270      this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
    272271      //
    273       // resetButton
    274       //
    275       this.resetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    276       this.resetButton.Enabled = false;
    277       this.resetButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Restart;
    278       this.resetButton.Location = new System.Drawing.Point(90, 536);
    279       this.resetButton.Name = "resetButton";
    280       this.resetButton.Size = new System.Drawing.Size(24, 24);
    281       this.resetButton.TabIndex = 8;
    282       this.toolTip.SetToolTip(this.resetButton, "Reset Experiment");
    283       this.resetButton.UseVisualStyleBackColor = true;
    284       this.resetButton.Click += new System.EventHandler(this.resetButton_Click);
    285       //
    286272      // executionTimeLabel
    287273      //
     
    486472      this.Controls.Add(this.resourceIdsLabel);
    487473      this.Controls.Add(this.stopButton);
    488       this.Controls.Add(this.resetButton);
    489474      this.Name = "RefreshableHiveJobView";
    490475      this.Size = new System.Drawing.Size(717, 560);
     
    505490    private System.Windows.Forms.Button startButton;
    506491    private System.Windows.Forms.Button stopButton;
    507     private System.Windows.Forms.Button resetButton;
    508492    private System.Windows.Forms.Label executionTimeLabel;
    509493    private System.Windows.Forms.TextBox executionTimeTextBox;
  • stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r14186 r15262  
    167167      pauseButton.Enabled = !Locked;
    168168      stopButton.Enabled = !Locked;
    169       resetButton.Enabled = !Locked;
    170169    }
    171170
     
    188187          this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    189188
    190           this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
     189          this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    191190          this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing;
    192191
     
    380379      }, TaskContinuationOptions.OnlyOnFaulted);
    381380    }
    382     private void resetButton_Click(object sender, EventArgs e) { }
    383381
    384382    private void PauseJobAsync(object job) {
     
    438436    private void SetEnabledStateOfExecutableButtons() {
    439437      if (Content == null) {
    440         startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
     438        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false;
    441439      } else {
    442440        startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    443441        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
    444         stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
    445         resetButton.Enabled = false;
     442        stopButton.Enabled = Content.IsControllable && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    446443      }
    447444    }
  • stable/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs

    r14186 r15262  
    7373
    7474    #region Child Control Events
    75     private void restartButton_Click(object sender, EventArgs e) {
     75    private void startButton_Click(object sender, EventArgs e) {
    7676      var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeTaskAsync);
    7777      task.ContinueWith((t) => {
     
    119119      base.SetEnabledStateOfControls();
    120120
    121       this.restartButton.Enabled = Content != null && Content.IsControllable && !Content.Task.Command.HasValue && (Content.Task.State == TaskState.Paused || Content.Task.State == TaskState.Failed || Content.Task.State == TaskState.Aborted);
     121      this.startButton.Enabled = Content != null && Content.IsControllable && !Content.Task.Command.HasValue && (Content.Task.State == TaskState.Paused);
    122122      this.pauseButton.Enabled = Content != null && Content.IsControllable && !Content.Task.Command.HasValue && Content.Task.State == TaskState.Calculating;
    123123      this.stopButton.Enabled = Content != null && Content.IsControllable && !Content.Task.Command.HasValue && (Content.Task.State == TaskState.Calculating || Content.Task.State == TaskState.Waiting || Content.Task.State == TaskState.Paused);
  • stable/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.designer.cs

    r14186 r15262  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.restartButton = new System.Windows.Forms.Button();
     47      this.startButton = new System.Windows.Forms.Button();
    4848      this.pauseButton = new System.Windows.Forms.Button();
    4949      this.stopButton = new System.Windows.Forms.Button();
     
    6060      // detailsTabPage
    6161      //
    62       this.detailsTabPage.Controls.Add(this.restartButton);
     62      this.detailsTabPage.Controls.Add(this.startButton);
    6363      this.detailsTabPage.Controls.Add(this.pauseButton);
    6464      this.detailsTabPage.Controls.Add(this.stopButton);
     
    6666      this.detailsTabPage.Controls.SetChildIndex(this.stopButton, 0);
    6767      this.detailsTabPage.Controls.SetChildIndex(this.pauseButton, 0);
    68       this.detailsTabPage.Controls.SetChildIndex(this.restartButton, 0);
     68      this.detailsTabPage.Controls.SetChildIndex(this.startButton, 0);
    6969      //
    7070      // tabControl
     
    7979      this.modifyItemButton.Text = "Show/Modify Optimizer";
    8080      //
    81       // restartButton
     81      // startButton
    8282      //
    83       this.restartButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    84       this.restartButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Restart;
    85       this.restartButton.Location = new System.Drawing.Point(3, 348);
    86       this.restartButton.Name = "restartButton";
    87       this.restartButton.Size = new System.Drawing.Size(24, 24);
    88       this.restartButton.TabIndex = 34;
    89       this.restartButton.UseVisualStyleBackColor = true;
    90       this.restartButton.Click += new System.EventHandler(this.restartButton_Click);
     83      this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     84      this.startButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play;
     85      this.startButton.Location = new System.Drawing.Point(3, 348);
     86      this.startButton.Name = "startButton";
     87      this.startButton.Size = new System.Drawing.Size(24, 24);
     88      this.startButton.TabIndex = 34;
     89      this.startButton.UseVisualStyleBackColor = true;
     90      this.startButton.Click += new System.EventHandler(this.startButton_Click);
    9191      //
    9292      // pauseButton
     
    139139      // OptimizerHiveTaskView
    140140      //
    141       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    142141      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    143142      this.Name = "OptimizerHiveTaskView";
     
    156155    #endregion
    157156
    158     private System.Windows.Forms.Button restartButton;
     157    private System.Windows.Forms.Button startButton;
    159158    private System.Windows.Forms.Button pauseButton;
    160159    private System.Windows.Forms.Button stopButton;
  • stable/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r14186 r15262  
    441441        if (refreshableJob.IsFinished()) {
    442442          refreshableJob.ExecutionState = Core.ExecutionState.Stopped;
    443         } else {
     443        } else if (refreshableJob.IsPaused()) {
     444          refreshableJob.ExecutionState = Core.ExecutionState.Paused;
     445        } else {
    444446          refreshableJob.ExecutionState = Core.ExecutionState.Started;
    445447        }
  • stable/HeuristicLab.Clients.Hive/3.3/HiveTasks/OptimizerHiveTask.cs

    r14186 r15262  
    316316    public override void AddChildHiveTask(HiveTask hiveTask) {
    317317      base.AddChildHiveTask(hiveTask);
    318       var optimizerHiveJob = (OptimizerHiveTask)hiveTask;
     318      var optimizerHiveTask = (OptimizerHiveTask)hiveTask;
    319319      syncTasksWithOptimizers = false;
    320       if (this.ItemTask != null && optimizerHiveJob.ItemTask != null) {
    321         // if task is in state Paused, it has to preserve its ResultCollection, which is cleared when a optimizer is added to an experiment
    322         OptimizerTask optimizerJobClone = null;
    323         if (optimizerHiveJob.Task.State == TaskState.Paused) {
    324           optimizerJobClone = (OptimizerTask)optimizerHiveJob.ItemTask.Clone();
    325         }
     320      if (this.ItemTask != null && optimizerHiveTask.ItemTask != null) {
     321        OptimizerTask optimizerTaskClone = (OptimizerTask)optimizerHiveTask.ItemTask.Clone();
    326322
    327323        if (this.ItemTask.Item is Optimization.Experiment) {
    328           if (!this.ItemTask.OptimizerAsExperiment.Optimizers.Contains(optimizerHiveJob.ItemTask.Item)) {
    329             UpdateOptimizerInExperiment(this.ItemTask.OptimizerAsExperiment, optimizerHiveJob.ItemTask);
     324          if (!this.ItemTask.OptimizerAsExperiment.Optimizers.Contains(optimizerHiveTask.ItemTask.Item)) {
     325            UpdateOptimizerInExperiment(this.ItemTask.OptimizerAsExperiment, optimizerHiveTask.ItemTask);
    330326          }
    331327        } else if (this.ItemTask.Item is Optimization.BatchRun) {
    332           UpdateOptimizerInBatchRun(this.ItemTask.OptimizerAsBatchRun, optimizerHiveJob.ItemTask);
    333         }
    334 
    335         if (optimizerHiveJob.Task.State == TaskState.Paused) {
    336           optimizerHiveJob.ItemTask = optimizerJobClone;
    337         }
     328          UpdateOptimizerInBatchRun(this.ItemTask.OptimizerAsBatchRun, optimizerHiveTask.ItemTask);
     329        }
     330
     331        optimizerHiveTask.syncTasksWithOptimizers = false;
     332        optimizerHiveTask.ItemTask = optimizerTaskClone;
     333        optimizerHiveTask.syncTasksWithOptimizers = true;
    338334      }
    339335      syncTasksWithOptimizers = true;
  • stable/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs

    r14186 r15262  
    304304        }
    305305        GC.Collect(); // force GC, because .NET is too lazy here (deserialization takes a lot of memory)
    306         if (AllJobsFinished()) {
    307           this.ExecutionState = Core.ExecutionState.Stopped;
     306        if (IsFinished()) {
     307          ExecutionState = ExecutionState.Stopped;
    308308          StopResultPolling();
     309        } else if (IsPaused()) {
     310          ExecutionState = ExecutionState.Paused;
     311          StopResultPolling();
     312        } else {
     313          ExecutionState = ExecutionState.Started;
    309314        }
    310315        UpdateTotalExecutionTime();
     
    330335      job.FinishedCount = jobs.Count(j => j.Task.State == TaskState.Finished);
    331336      OnJobStatisticsChanged();
    332     }
    333 
    334     public bool AllJobsFinished() {
    335       return this.GetAllHiveTasks().All(j => (j.Task.State == TaskState.Finished
    336                                                    || j.Task.State == TaskState.Aborted
    337                                                    || j.Task.State == TaskState.Failed)
    338                                                    && !j.IsDownloading);
    339337    }
    340338
     
    513511          this.RefreshAutomatically = false;
    514512          StopResultPolling();
     513        } else if (IsPaused()) {
     514          this.executionState = Core.ExecutionState.Paused;
     515          this.RefreshAutomatically = false;
     516          StopResultPolling();
    515517        } else {
    516518          this.RefreshAutomatically = true;
     
    527529      this.OnStateLogListChanged();
    528530
    529       if (this.ExecutionState != ExecutionState.Stopped) {
     531      if (this.ExecutionState != ExecutionState.Stopped && this.ExecutionState != ExecutionState.Paused) {
    530532        this.RefreshAutomatically = true;
    531533      }
     
    584586
    585587    public bool IsFinished() {
    586       return HiveTasks != null
    587         && HiveTasks.All(x => x.Task.DateFinished.HasValue && x.Task.DateCreated.HasValue);
     588      var tasks = GetAllHiveTasks();
     589      return tasks.All(x => x.Task.State == TaskState.Finished
     590                            || x.Task.State == TaskState.Aborted
     591                            || x.Task.State == TaskState.Failed);
     592    }
     593
     594    public bool IsPaused() {
     595      var tasks = GetAllHiveTasks().Where(x => !x.Task.IsParentTask);
     596      return tasks.All(x => x.Task.State != TaskState.Waiting
     597                            && x.Task.State != TaskState.Transferring
     598                            && x.Task.State != TaskState.Calculating)
     599             && tasks.Any(x => x.Task.State == TaskState.Paused);
    588600    }
    589601
  • stable/HeuristicLab.Services.Hive

  • stable/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r14186 r15262  
    263263          if (task.State == DA.TaskState.Calculating || task.State == DA.TaskState.Transferring) {
    264264            task.Command = DA.Command.Pause;
    265           }
    266           UpdateTaskState(pm, task, DT.TaskState.Paused, null, null, string.Empty);
     265          } else if (task.State != DA.TaskState.Paused
     266                     && task.State != DA.TaskState.Aborted
     267                     && task.State != DA.TaskState.Finished
     268                     && task.State != DA.TaskState.Failed) {
     269            UpdateTaskState(pm, task, DT.TaskState.Paused, null, null, string.Empty);
     270          }
    267271          pm.SubmitChanges();
    268272        });
     
    962966      var stateLogDao = pm.StateLogDao;
    963967      var taskStateEntity = taskState.ToEntity();
    964       if (task.Command == DA.Command.Pause && task.State == DA.TaskState.Paused
    965           || task.Command == DA.Command.Abort && task.State == DA.TaskState.Aborted
    966           || task.Command == DA.Command.Stop && task.State == DA.TaskState.Aborted) {
    967         task.Command = null;
    968       } else if (taskStateEntity == DA.TaskState.Paused && task.Command == null) {
     968
     969      if (task.State == DA.TaskState.Calculating && taskStateEntity == DA.TaskState.Paused && task.Command == null) {
    969970        // slave paused and uploaded the task (no user-command) -> set waiting.
    970971        taskStateEntity = DA.TaskState.Waiting;
    971972      }
     973
    972974      stateLogDao.Save(new DA.StateLog {
    973975        State = taskStateEntity,
     
    978980        Exception = exception
    979981      });
     982
    980983      task.State = taskStateEntity;
     984
     985      if (task.Command == DA.Command.Pause && task.State == DA.TaskState.Paused
     986          || task.Command == DA.Command.Abort && task.State == DA.TaskState.Aborted
     987          || task.Command == DA.Command.Stop && task.State == DA.TaskState.Aborted) {
     988        task.Command = null;
     989      }
    981990    }
    982991
Note: See TracChangeset for help on using the changeset viewer.