Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/15/11 12:02:12 (13 years ago)
Author:
cneumuel
Message:

#1233

  • small fixes for HiveEngine
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/RefreshableHiveExperiment.cs

    r6178 r6198  
    9595    }
    9696
     97    [Storable]
     98    private ILog log;
     99    public ILog Log {
     100      get { return log; }
     101      set { log = value; }
     102    }
     103   
     104
    97105    #region Constructors and Cloning
    98106    public RefreshableHiveExperiment() {
     
    100108      this.refreshAutomatically = true;
    101109      this.HiveExperiment = new HiveExperiment();
     110      this.log = new Log();
    102111    }
    103112    public RefreshableHiveExperiment(HiveExperiment hiveExperiment) {
     
    105114      this.refreshAutomatically = true;
    106115      this.HiveExperiment = hiveExperiment;
     116      this.log = new Log();
    107117    }
    108118    protected RefreshableHiveExperiment(RefreshableHiveExperiment original, Cloner cloner) {
     
    112122      this.IncludeJobs = original.IncludeJobs;
    113123      this.IsControllable = original.IsControllable;
     124      this.Log = cloner.Clone(original.Log);
    114125    }
    115126    public IDeepCloneable Clone(Cloner cloner) {
     
    167178    private void jobResultPoller_JobResultReceived(object sender, EventArgs<IEnumerable<LightweightJob>> e) {
    168179      foreach (LightweightJob lightweightJob in e.Value) {
    169         HiveJob hj = GetHiveJobById(lightweightJob.Id);
    170         if (hj != null) {
    171           DateTime lastJobDataUpdate = hj.Job.LastJobDataUpdate;
    172           hj.UpdateFromLightweightJob(lightweightJob);
    173 
     180        HiveJob hiveJob = GetHiveJobById(lightweightJob.Id);
     181        if (hiveJob != null) {
    174182          // lastJobDataUpdate equals DateTime.MinValue right after it was uploaded. When the first results are polled, this value is updated
    175           if (lastJobDataUpdate != DateTime.MinValue && lastJobDataUpdate < hj.Job.LastJobDataUpdate) {
    176             jobDownloader.DownloadJob(hj.Job.Id, (id, itemJob, exception) => {
     183          if (hiveJob.Job.State == JobState.Offline && lightweightJob.State != JobState.Finished && lightweightJob.State != JobState.Failed && lightweightJob.State != JobState.Aborted) {
     184            hiveJob.Job.LastJobDataUpdate = lightweightJob.LastJobDataUpdate;
     185          }
     186
     187          hiveJob.UpdateFromLightweightJob(lightweightJob);
     188
     189          if (!hiveJob.IsFinishedJobDownloaded && !hiveJob.IsDownloading && hiveJob.Job.LastJobDataUpdate < lightweightJob.LastJobDataUpdate) {
     190            log.LogMessage(string.Format("Downloading job {0}", lightweightJob.Id));
     191            hiveJob.IsDownloading = true;
     192            jobDownloader.DownloadJob(hiveJob.Job, (localJob, itemJob, exception) => {
     193              log.LogMessage(string.Format("Finished downloading job {0}", localJob.Id));
     194              HiveJob localHiveJob = GetHiveJobById(localJob.Id);
     195
    177196              if (exception != null) {
     197                log.LogException(exception);
     198                localHiveJob.IsDownloading = false;
    178199                throw new ConcurrentJobDownloaderException("Downloading job failed.", exception);
    179200              }
     
    183204              } else {
    184205                // if the job is paused, download but don't integrate into parent optimizer (to avoid Prepare)
    185                 if (hj.Job.State == JobState.Paused) {
    186                   hj.ItemJob = itemJob;
     206
     207
     208                if (localJob.State == JobState.Paused) {
     209                  localHiveJob.ItemJob = itemJob;
    187210                } else {
    188                   if (lightweightJob.ParentJobId.HasValue) {
    189                     HiveJob parentHiveJob = GetHiveJobById(lightweightJob.ParentJobId.Value);
    190                     parentHiveJob.IntegrateChild(itemJob, hj.Job.Id);
     211                  if (localJob.ParentJobId.HasValue) {
     212                    HiveJob parentHiveJob = GetHiveJobById(localJob.ParentJobId.Value);
     213                    parentHiveJob.IntegrateChild(itemJob, localJob.Id);
    191214                  } else {
    192                     hj.ItemJob = itemJob;
     215                    localHiveJob.ItemJob = itemJob;
    193216                  }
    194217                }
     218                localHiveJob.IsDownloading = false;
     219                localHiveJob.Job.LastJobDataUpdate = localJob.LastJobDataUpdate;
    195220              }
    196221            });
     
    227252                                                   || j.Job.State == JobState.Aborted
    228253                                                   || j.Job.State == JobState.Failed)
    229                                                    && j.ItemJobDownloaded);
     254                                                   && j.IsFinishedJobDownloaded);
    230255    }
    231256
Note: See TracChangeset for help on using the changeset viewer.