Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14901


Ignore:
Timestamp:
05/02/17 09:41:39 (8 years ago)
Author:
jkarder
Message:

#2784: fixed pausing of hive tasks

Location:
trunk/sources
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs

    r14185 r14901  
    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;
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r14185 r14901  
    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    }
  • trunk/sources/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs

    r14185 r14901  
    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 || Content.Task.State == TaskState.Failed || Content.Task.State == TaskState.Aborted);
    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);
  • trunk/sources/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.designer.cs

    r14185 r14901  
    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;
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r14185 r14901  
    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        }
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs

    r14185 r14901  
    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
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r14185 r14901  
    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.Aborted
     266                     && task.State != DA.TaskState.Finished
     267                     && task.State != DA.TaskState.Failed) {
     268            UpdateTaskState(pm, task, DT.TaskState.Paused, null, null, string.Empty);
     269          }
    267270          pm.SubmitChanges();
    268271        });
     
    962965      var stateLogDao = pm.StateLogDao;
    963966      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) {
     967
     968      if (taskStateEntity == DA.TaskState.Paused && task.Command == null) {
    969969        // slave paused and uploaded the task (no user-command) -> set waiting.
    970970        taskStateEntity = DA.TaskState.Waiting;
    971971      }
     972
    972973      stateLogDao.Save(new DA.StateLog {
    973974        State = taskStateEntity,
     
    978979        Exception = exception
    979980      });
     981
    980982      task.State = taskStateEntity;
     983
     984      if (task.Command == DA.Command.Pause && task.State == DA.TaskState.Paused
     985          || task.Command == DA.Command.Abort && task.State == DA.TaskState.Aborted
     986          || task.Command == DA.Command.Stop && task.State == DA.TaskState.Aborted) {
     987        task.Command = null;
     988      }
    981989    }
    982990
Note: See TracChangeset for help on using the changeset viewer.