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

#2784: fixed pausing of hive tasks

Location:
trunk/sources/HeuristicLab.Clients.Hive/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.