- Timestamp:
- 05/03/11 17:08:54 (13 years ago)
- 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 25 25 using System.Drawing; 26 26 using System.Linq; 27 using HeuristicLab.Clients.Hive.ExperimentManager;28 using HeuristicLab.Clients.Hive.Jobs;29 27 using HeuristicLab.Common; 30 28 using HeuristicLab.Core; 29 using HeuristicLab.Hive; 31 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 31 … … 35 34 public class RefreshableHiveExperiment : IHiveItem, IDeepCloneable, IContent, IProgressReporter { 36 35 private JobResultPoller jobResultPoller; 36 private JobDownloader<ItemJob> jobDownloader = new JobDownloader<ItemJob>(2, 2); 37 37 38 38 [Storable] … … 69 69 refreshAutomatically = value; 70 70 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(); 76 76 } 77 77 } … … 103 103 #endregion 104 104 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 // else124 // hiveExperiment.HiveJobs.Clear();125 // hiveExperiment.HiveJobs.Add(new OptimizerHiveJob(experiment));126 //}127 128 105 private void hiveExperiment_HiveJobsChanged(object sender, EventArgs e) { 129 106 if (jobResultPoller != null && jobResultPoller.IsPolling) { … … 141 118 public void StartResultPolling() { 142 119 if (jobResultPoller == null) { 143 jobResultPoller = new JobResultPoller(hiveExperiment. HiveJobs, /*ApplicationConstants.ResultPollingInterval*/new TimeSpan(0, 0, 5)); //TODO: find a better place for ApplicationConstants120 jobResultPoller = new JobResultPoller(hiveExperiment.Id, /*ApplicationConstants.ResultPollingInterval*/new TimeSpan(0, 0, 5)); //TODO: find a better place for ApplicationConstants 144 121 RegisterResultPollingEvents(); 145 122 } … … 172 149 private void jobResultPoller_JobResultReceived(object sender, EventArgs<IEnumerable<LightweightJob>> e) { 173 150 foreach (LightweightJob lightweightJob in e.Value) { 174 OptimizerHiveJob hj = GetHiveJobById(lightweightJob.Id);151 HiveJob hj = GetHiveJobById(lightweightJob.Id); 175 152 if (hj != null) { 176 153 DateTime lastJobDataUpdate = hj.Job.LastJobDataUpdate; … … 179 156 // lastJobDataUpdate equals DateTime.MinValue right after it was uploaded. When the first results are polled, this value is updated 180 157 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! 188 161 } 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 } 192 172 } 193 173 } 194 } 174 }); 195 175 } 196 176 } … … 205 185 } 206 186 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); 210 190 if (hj != null) 211 191 return hj; … … 226 206 || j.Job.State == JobState.Failed); 227 207 } 208 209 //public bool AllJobsFinishedAndDownloaded() { 210 // return this.AllJobsFinished() && hiveExperiment.GetAllHiveJobs().All(j => j.JobItem.; 211 //} 228 212 229 213 private void jobResultPoller_ExceptionOccured(object sender, EventArgs<Exception> e) { … … 261 245 hiveExperiment.IsProgressingChanged -= new EventHandler(hiveExperiment_IsProgressingChanged); 262 246 } 263 247 264 248 #region Events 265 249 public event EventHandler RefreshAutomaticallyChanged; … … 314 298 } 315 299 public void Store() { 316 hiveExperiment.Store() 300 hiveExperiment.Store(); 317 301 } 318 302 public string ItemDescription { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/Heartbeat.cs
r6004 r6110 31 31 32 32 public override string ToString() { 33 String val = "SlaveId: " + SlaveId + ", FreeCores: " + FreeCores;33 string val = string.Format("SlaveId: {0}, FreeCores: {1}", SlaveId, FreeCores); 34 34 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); 36 36 } 37 37 return val;
Note: See TracChangeset
for help on using the changeset viewer.