Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/04/19 14:45:47 (5 years ago)
Author:
mkommend
Message:

#2845: Merged 16430 into stable.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Hive

  • stable/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r17059 r17062  
    167167        RefreshDisabledParentProjects();
    168168        RefreshDisabledParentResources();
    169       }
    170       catch {
     169      } catch {
    171170        jobs = null;
    172171        projects = null;
    173172        resources = null;
    174173        throw;
    175       }
    176       finally {
     174      } finally {
    177175        OnRefreshed();
    178176      }
     
    215213
    216214    public void RefreshAsync(Action<Exception> exceptionCallback) {
    217       var call = new Func<Exception>(delegate() {
     215      var call = new Func<Exception>(delegate () {
    218216        try {
    219217          Refresh();
    220         }
    221         catch (Exception ex) {
     218        } catch (Exception ex) {
    222219          return ex;
    223220        }
    224221        return null;
    225222      });
    226       call.BeginInvoke(delegate(IAsyncResult result) {
     223      call.BeginInvoke(delegate (IAsyncResult result) {
    227224        Exception ex = call.EndInvoke(result);
    228225        if (ex != null) exceptionCallback(ex);
     
    244241      resourceAncestors.Keys.ToList().ForEach(k => resourceDescendants.Add(k, new HashSet<Guid>()));
    245242      foreach (var ra in resourceAncestors) {
    246         foreach(var ancestor in ra.Value) {
     243        foreach (var ancestor in ra.Value) {
    247244          resourceDescendants[ancestor].Add(ra.Key);
    248245        }
     
    263260      // build project descendant list
    264261      projectAncestors.Keys.ToList().ForEach(k => projectDescendants.Add(k, new HashSet<Guid>()));
    265       foreach(var pa in projectAncestors) {
    266         foreach(var ancestor in pa.Value) {
     262      foreach (var pa in projectAncestors) {
     263        foreach (var ancestor in pa.Value) {
    267264          projectDescendants[ancestor].Add(pa.Key);
    268265        }
     
    362359    }
    363360    public static void StoreAsync(Action<Exception> exceptionCallback, IHiveItem item, CancellationToken cancellationToken) {
    364       var call = new Func<Exception>(delegate() {
     361      var call = new Func<Exception>(delegate () {
    365362        try {
    366363          Store(item, cancellationToken);
    367         }
    368         catch (Exception ex) {
     364        } catch (Exception ex) {
    369365          return ex;
    370366        }
    371367        return null;
    372368      });
    373       call.BeginInvoke(delegate(IAsyncResult result) {
     369      call.BeginInvoke(delegate (IAsyncResult result) {
    374370        Exception ex = call.EndInvoke(result);
    375371        if (ex != null) exceptionCallback(ex);
     
    460456    public static void UpdateJob(Action<Exception> exceptionCallback, RefreshableJob refreshableJob, CancellationToken cancellationToken) {
    461457      refreshableJob.IsProgressing = true;
    462       refreshableJob.Progress.Status = "Saving Job...";
     458      refreshableJob.Progress.Message = "Saving Job...";
    463459      HiveClient.StoreAsync(
    464460        new Action<Exception>((Exception ex) => {
     
    473469
    474470      try {
    475         refreshableJob.Progress.Start("Saving Job...");
     471        refreshableJob.Progress.Start("Saving Job...", ProgressMode.Indeterminate);
    476472        HiveClient.StoreAsync(new Action<Exception>((Exception ex) => {
    477473          throw new Exception("Update failed.", ex);
     
    492488      try {
    493489        refreshableJob.IsProgressing = true;
    494         refreshableJob.Progress.Start("Connecting to server...");
     490        refreshableJob.Progress.Start("Connecting to server...", ProgressMode.Indeterminate);
    495491
    496492        foreach (OptimizerHiveTask hiveJob in refreshableJob.HiveTasks.OfType<OptimizerHiveTask>()) {
     
    499495
    500496        // upload Job
    501         refreshableJob.Progress.Status = "Uploading Job...";
     497        refreshableJob.Progress.Message = "Uploading Job...";
    502498        refreshableJob.Job.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddJob(refreshableJob.Job, refreshableJob.Job.ResourceIds));
    503499        refreshableJob.Job = HiveServiceLocator.Instance.CallHiveService((s) => s.GetJob(refreshableJob.Job.Id)); // update owner and permissions
     
    509505
    510506        // upload plugins
    511         refreshableJob.Progress.Status = "Uploading plugins...";
     507        refreshableJob.Progress.Message = "Uploading plugins...";
    512508        this.OnlinePlugins = HiveServiceLocator.Instance.CallHiveService((s) => s.GetPlugins());
    513509        this.AlreadyUploadedPlugins = new List<Plugin>();
     
    517513
    518514        // upload tasks
    519         refreshableJob.Progress.Status = "Uploading tasks...";
     515        refreshableJob.Progress.Message = "Uploading tasks...";
     516        refreshableJob.Progress.ProgressMode = ProgressMode.Determinate;
     517        refreshableJob.Progress.ProgressValue = 0;
    520518
    521519        var tasks = new List<TS.Task>();
     
    528526        }
    529527        TS.Task.WaitAll(tasks.ToArray());
    530       }
    531       finally {
     528      } finally {
    532529        refreshableJob.Job.Modified = false;
    533530        refreshableJob.IsProgressing = false;
     
    615612        lock (jobCountLocker) {
    616613          progress.ProgressValue = (double)taskCount[0] / totalJobCount;
    617           progress.Status = string.Format("Uploaded task ({0} of {1})", taskCount[0], totalJobCount);
     614          progress.Message = string.Format("Uploaded task ({0} of {1})", taskCount[0], totalJobCount);
    618615        }
    619616
     
    646643
    647644        // fetch all task objects to create the full tree of tree of HiveTask objects
    648         refreshableJob.Progress.Start("Downloading list of tasks...");
     645        refreshableJob.Progress.Start("Downloading list of tasks...", ProgressMode.Indeterminate);
    649646        allTasks = HiveServiceLocator.Instance.CallHiveService(s => s.GetLightweightJobTasksWithoutStateLog(hiveExperiment.Id));
    650647        totalJobCount = allTasks.Count();
    651648
    652         refreshableJob.Progress.Status = "Downloading tasks...";
     649        refreshableJob.Progress.Message = "Downloading tasks...";
     650        refreshableJob.Progress.ProgressMode = ProgressMode.Determinate;
     651        refreshableJob.Progress.ProgressValue = 0.0;
    653652        downloader = new TaskDownloader(allTasks.Select(x => x.Id));
    654653        downloader.StartAsync();
     
    656655        while (!downloader.IsFinished) {
    657656          refreshableJob.Progress.ProgressValue = downloader.FinishedCount / (double)totalJobCount;
    658           refreshableJob.Progress.Status = string.Format("Downloading/deserializing tasks... ({0}/{1} finished)", downloader.FinishedCount, totalJobCount);
     657          refreshableJob.Progress.Message = string.Format("Downloading/deserializing tasks... ({0}/{1} finished)", downloader.FinishedCount, totalJobCount);
    659658          Thread.Sleep(500);
    660659
     
    666665        var parents = allHiveTasks.Values.Where(x => !x.Task.ParentTaskId.HasValue);
    667666
    668         refreshableJob.Progress.Status = "Downloading/deserializing complete. Displaying tasks...";
     667        refreshableJob.Progress.Message = "Downloading/deserializing complete. Displaying tasks...";
     668        refreshableJob.Progress.ProgressMode = ProgressMode.Indeterminate;
     669
    669670        // build child-task tree
    670671        foreach (HiveTask hiveTask in parents) {
     
    677678        } else if (refreshableJob.IsPaused()) {
    678679          refreshableJob.ExecutionState = Core.ExecutionState.Paused;
    679         } else { 
     680        } else {
    680681          refreshableJob.ExecutionState = Core.ExecutionState.Started;
    681682        }
    682683        refreshableJob.OnLoaded();
    683       }
    684       finally {
     684      } finally {
    685685        refreshableJob.IsProgressing = false;
    686686        refreshableJob.Progress.Finish();
     
    719719      try {
    720720        return PersistenceUtil.Deserialize<ItemTask>(taskData.Data);
    721       }
    722       catch {
     721      } catch {
    723722        return null;
    724723      }
     
    731730    public static void TryAndRepeat(Action action, int repetitions, string errorMessage, ILog log = null) {
    732731      while (true) {
    733         try { action(); return; }
    734         catch (Exception e) {
     732        try { action(); return; } catch (Exception e) {
    735733          if (repetitions == 0) throw new HiveException(errorMessage, e);
    736734          if (log != null) log.LogMessage(string.Format("{0}: {1} - will try again!", errorMessage, e.ToString()));
Note: See TracChangeset for help on using the changeset viewer.