Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/03/11 17:08:54 (13 years ago)
Author:
cneumuel
Message:

#1233

  • renamed engines to executors
  • changed locking in StartJobInAppDomain
  • avoid destruction of proxy object after 5 minutes for Slave.Core
  • added JobStarted event and fixed ExecutionStateChanged and ExecutionTimeChanged
  • slaves which are moved to another slavegroup will pause their jobs now, if they must not calculate them
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4
Files:
2 edited

Legend:

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

    r6033 r6110  
    2525using System.Drawing;
    2626using System.Linq;
    27 using HeuristicLab.Clients.Hive.ExperimentManager;
    28 using HeuristicLab.Clients.Hive.Jobs;
    2927using HeuristicLab.Common;
    3028using HeuristicLab.Core;
     29using HeuristicLab.Hive;
    3130using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3231
     
    3534  public class RefreshableHiveExperiment : IHiveItem, IDeepCloneable, IContent, IProgressReporter {
    3635    private JobResultPoller jobResultPoller;
     36    private JobDownloader<ItemJob> jobDownloader = new JobDownloader<ItemJob>(2, 2);
    3737
    3838    [Storable]
     
    6969          refreshAutomatically = value;
    7070          OnRefreshAutomaticallyChanged();
    71           if (RefreshAutomatically) {
    72             StartResultPolling();
    73           } else {
    74             StopResultPolling();
    75           }
     71        }
     72        if (RefreshAutomatically && hiveExperiment.HiveJobs != null && hiveExperiment.HiveJobs.Count > 0 && (jobResultPoller == null || !jobResultPoller.IsPolling)) {
     73          StartResultPolling();
     74        } else {
     75          StopResultPolling();
    7676        }
    7777      }
     
    103103    #endregion
    104104
    105     //public Experiment GetExperiment(int idx) {
    106     //  if (hiveExperiment.HiveJobs != null) {
    107     //    var hj = hiveExperiment.HiveJobs.ElementAtOrDefault(idx);
    108     //    if (hj != null)
    109     //      return ((OptimizerHiveJob)hj).JobItem.OptimizerAsExperiment;
    110     //  }
    111     //  return null;
    112     //}
    113 
    114     //public void AddExperiment(Experiment experiment) {
    115     //  if (hiveExperiment.HiveJobs == null)
    116     //    hiveExperiment.HiveJobs = new ItemCollection<HiveJob>();
    117     //  hiveExperiment.HiveJobs.Add(new OptimizerHiveJob(experiment));
    118     //}
    119 
    120     //public void SetExperiment(Experiment experiment) {
    121     //  if (hiveExperiment.HiveJobs == null)
    122     //    hiveExperiment.HiveJobs = new ItemCollection<HiveJob>();
    123     //  else
    124     //    hiveExperiment.HiveJobs.Clear();
    125     //  hiveExperiment.HiveJobs.Add(new OptimizerHiveJob(experiment));
    126     //}
    127 
    128105    private void hiveExperiment_HiveJobsChanged(object sender, EventArgs e) {
    129106      if (jobResultPoller != null && jobResultPoller.IsPolling) {
     
    141118    public void StartResultPolling() {
    142119      if (jobResultPoller == null) {
    143         jobResultPoller = new JobResultPoller(hiveExperiment.HiveJobs, /*ApplicationConstants.ResultPollingInterval*/new TimeSpan(0, 0, 5)); //TODO: find a better place for ApplicationConstants
     120        jobResultPoller = new JobResultPoller(hiveExperiment.Id, /*ApplicationConstants.ResultPollingInterval*/new TimeSpan(0, 0, 5)); //TODO: find a better place for ApplicationConstants
    144121        RegisterResultPollingEvents();
    145122      }
     
    172149    private void jobResultPoller_JobResultReceived(object sender, EventArgs<IEnumerable<LightweightJob>> e) {
    173150      foreach (LightweightJob lightweightJob in e.Value) {
    174         OptimizerHiveJob hj = GetHiveJobById(lightweightJob.Id);
     151        HiveJob hj = GetHiveJobById(lightweightJob.Id);
    175152        if (hj != null) {
    176153          DateTime lastJobDataUpdate = hj.Job.LastJobDataUpdate;
     
    179156          // lastJobDataUpdate equals DateTime.MinValue right after it was uploaded. When the first results are polled, this value is updated
    180157          if (lastJobDataUpdate != DateTime.MinValue && lastJobDataUpdate < hj.Job.LastJobDataUpdate) {
    181             OptimizerJob optimizerJob = ExperimentManagerClient.LoadOptimizerJob(hj.Job.Id);
    182             if (optimizerJob == null) {
    183               // something bad happened to this job. bad job, BAAAD job!
    184             } else {
    185               // if the job is paused, download but don't integrate into parent optimizer (to avoid Prepare)
    186               if (hj.Job.State == JobState.Paused) {
    187                 hj.JobItem = optimizerJob;
     158            jobDownloader.DownloadJob(hj.Job.Id, (itemJob) => {
     159              if (itemJob == null) {
     160                // something bad happened to this job. bad job, BAAAD job!
    188161              } else {
    189                 if (lightweightJob.ParentJobId.HasValue) {
    190                   OptimizerHiveJob parentHiveJob = GetHiveJobById(lightweightJob.ParentJobId.Value);
    191                   parentHiveJob.UpdateChildOptimizer(optimizerJob, hj.Job.Id);
     162                // if the job is paused, download but don't integrate into parent optimizer (to avoid Prepare)
     163                if (hj.Job.State == JobState.Paused) {
     164                  hj.JobItem = itemJob;
     165                } else {
     166                  if (lightweightJob.ParentJobId.HasValue) {
     167                    HiveJob parentHiveJob = GetHiveJobById(lightweightJob.ParentJobId.Value);
     168                    parentHiveJob.IntegrateChild(itemJob, hj.Job.Id);
     169                  } else {
     170                    hj.JobItem = itemJob;
     171                  }
    192172                }
    193173              }
    194             }
     174            });
    195175          }
    196176        }
     
    205185    }
    206186
    207     public OptimizerHiveJob GetHiveJobById(Guid jobId) {
    208       foreach (OptimizerHiveJob job in hiveExperiment.HiveJobs) {
    209         var hj = job.GetHiveJobByJobId(jobId) as OptimizerHiveJob;
     187    public HiveJob GetHiveJobById(Guid jobId) {
     188      foreach (HiveJob job in hiveExperiment.HiveJobs) {
     189        var hj = job.GetHiveJobByJobId(jobId);
    210190        if (hj != null)
    211191          return hj;
     
    226206                                            || j.Job.State == JobState.Failed);
    227207    }
     208
     209    //public bool AllJobsFinishedAndDownloaded() {
     210    //  return this.AllJobsFinished() && hiveExperiment.GetAllHiveJobs().All(j => j.JobItem.;
     211    //}
    228212
    229213    private void jobResultPoller_ExceptionOccured(object sender, EventArgs<Exception> e) {
     
    261245      hiveExperiment.IsProgressingChanged -= new EventHandler(hiveExperiment_IsProgressingChanged);
    262246    }
    263    
     247
    264248    #region Events
    265249    public event EventHandler RefreshAutomaticallyChanged;
     
    314298    }
    315299    public void Store() {
    316       hiveExperiment.Store() ;
     300      hiveExperiment.Store();
    317301    }
    318302    public string ItemDescription {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/Heartbeat.cs

    r6004 r6110  
    3131
    3232    public override string ToString() {
    33       String val = "SlaveId: " + SlaveId + ", FreeCores: " + FreeCores;
     33      string val = string.Format("SlaveId: {0}, FreeCores: {1}", SlaveId, FreeCores);
    3434      foreach (KeyValuePair<Guid, TimeSpan> kvp in JobProgress) {
    35         val += Environment.NewLine + "Id" + kvp.Key + " ExecutionTime " + kvp.Value;
     35        val += Environment.NewLine + string.Format("Id: {0}, ExecutionTime {1}", kvp.Key, kvp.Value);
    3636      }
    3737      return val;
Note: See TracChangeset for help on using the changeset viewer.