- Timestamp:
- 05/10/11 17:58:59 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4
- Files:
-
- 4 added
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/ExperimentManagerClient.cs
r6111 r6178 274 274 List<IPluginDescription> plugins; 275 275 276 if (hiveJob. JobItem.ComputeInParallel &&277 (hiveJob. JobItem.Item is Optimization.Experiment || hiveJob.JobItem.Item is Optimization.BatchRun)) {276 if (hiveJob.ItemJob.ComputeInParallel && 277 (hiveJob.ItemJob.Item is Optimization.Experiment || hiveJob.ItemJob.Item is Optimization.BatchRun)) { 278 278 hiveJob.Job.IsParentJob = true; 279 279 hiveJob.Job.FinishWhenChildJobsFinished = true; 280 hiveJob. JobItem.CollectChildJobs = false; // don't collect child-jobs on slaves280 hiveJob.ItemJob.CollectChildJobs = false; // don't collect child-jobs on slaves 281 281 jobData = hiveJob.GetAsJobData(true, out plugins); 282 282 } else { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveJob.cs
r6168 r6178 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel; 24 25 using System.Drawing; 25 26 using System.Linq; … … 55 56 } 56 57 58 [Storable] 57 59 protected Job job; 58 60 public Job Job { … … 60 62 set { 61 63 if (job != value) { 64 DeregisterJobEvents(); 62 65 job = value; 66 RegisterJobEvents(); 67 itemJobDownloaded = false; 63 68 OnJobChanged(); 64 69 OnToStringChanged(); 65 70 OnItemImageChanged(); 66 71 } 72 67 73 } 68 74 } 69 75 70 76 [Storable] 71 protected ItemJob jobItem;72 public ItemJob JobItem{73 get { return jobItem; }77 protected ItemJob itemJob; 78 public ItemJob ItemJob { 79 get { return itemJob; } 74 80 internal set { 75 if ( jobItem!= null && syncJobsWithOptimizers) {81 if (itemJob != null && syncJobsWithOptimizers) { 76 82 this.childHiveJobs.Clear(); 77 83 } 78 if ( jobItem!= value) {79 Dergister JobItemsEvents();80 jobItem= value;81 Register JobItemEvents();84 if (itemJob != value) { 85 DergisterItemJobEvents(); 86 itemJob = value; 87 RegisterItemJobEvents(); 82 88 OnJobItemChanged(); 83 } 84 } 89 itemJobDownloaded = true; 90 } 91 } 92 } 93 94 // job downloaded since last status change 95 [Storable] 96 private bool itemJobDownloaded = false; 97 public bool ItemJobDownloaded { 98 get { return itemJobDownloaded; } 85 99 } 86 100 … … 106 120 } 107 121 108 public HiveJob(ItemJob jobItem, bool autoCreateChildHiveJobs)122 public HiveJob(ItemJob itemJob, bool autoCreateChildHiveJobs) 109 123 : this() { 110 124 this.syncJobsWithOptimizers = autoCreateChildHiveJobs; 111 this. JobItem = jobItem;125 this.ItemJob = itemJob; 112 126 this.syncJobsWithOptimizers = true; 113 127 } … … 117 131 this.Job = job; 118 132 try { 119 this. JobItem= PersistenceUtil.Deserialize<ItemJob>(jobData.Data);133 this.ItemJob = PersistenceUtil.Deserialize<ItemJob>(jobData.Data); 120 134 } 121 135 catch { 122 this. JobItem= null;136 this.ItemJob = null; 123 137 } 124 138 this.childHiveJobs = new ItemList<HiveJob>(); … … 130 144 : base(original, cloner) { 131 145 this.Job = cloner.Clone(original.job); 132 this. JobItem = cloner.Clone(original.JobItem);146 this.ItemJob = cloner.Clone(original.ItemJob); 133 147 this.childHiveJobs = cloner.Clone(original.childHiveJobs); 134 148 this.syncJobsWithOptimizers = original.syncJobsWithOptimizers; 149 this.itemJobDownloaded = original.itemJobDownloaded; 135 150 } 136 151 public override IDeepCloneable Clone(Cloner cloner) { … … 141 156 protected virtual void UpdateChildHiveJobs() { } 142 157 143 protected virtual void Register JobItemEvents() {144 if ( JobItem!= null) {145 JobItem.ComputeInParallelChanged += new EventHandler(JobItem_ComputeInParallelChanged);146 JobItem.ToStringChanged += new EventHandler(JobItem_ToStringChanged);147 } 148 } 149 protected virtual void Dergister JobItemsEvents() {150 if ( JobItem!= null) {151 JobItem.ComputeInParallelChanged -= new EventHandler(JobItem_ComputeInParallelChanged);152 JobItem.ToStringChanged -= new EventHandler(JobItem_ToStringChanged);158 protected virtual void RegisterItemJobEvents() { 159 if (ItemJob != null) { 160 ItemJob.ComputeInParallelChanged += new EventHandler(JobItem_ComputeInParallelChanged); 161 ItemJob.ToStringChanged += new EventHandler(JobItem_ToStringChanged); 162 } 163 } 164 protected virtual void DergisterItemJobEvents() { 165 if (ItemJob != null) { 166 ItemJob.ComputeInParallelChanged -= new EventHandler(JobItem_ComputeInParallelChanged); 167 ItemJob.ToStringChanged -= new EventHandler(JobItem_ToStringChanged); 153 168 } 154 169 } … … 168 183 this.OnToStringChanged(); 169 184 } 170 185 171 186 protected virtual void JobItem_ComputeInParallelChanged(object sender, EventArgs e) { 172 if ( JobItem!= null && syncJobsWithOptimizers) {187 if (ItemJob != null && syncJobsWithOptimizers) { 173 188 this.UpdateChildHiveJobs(); 174 189 } … … 180 195 181 196 public override string ToString() { 182 if ( jobItem!= null) {183 return jobItem.ToString();197 if (itemJob != null) { 198 return itemJob.ToString(); 184 199 } else { 185 200 return base.ToString(); … … 196 211 job.Command = lightweightJob.Command; 197 212 job.LastJobDataUpdate = lightweightJob.LastJobDataUpdate; 198 213 199 214 OnJobStateChanged(); 200 215 OnToStringChanged(); … … 210 225 /// </param> 211 226 public virtual JobData GetAsJobData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) { 212 plugins = null; 213 return null; 227 plugins = new List<IPluginDescription>(); 228 if (this.itemJob == null) 229 return null; 230 231 IEnumerable<Type> usedTypes; 232 byte[] jobByteArray = PersistenceUtil.Serialize(this.ItemJob, out usedTypes); 233 234 JobData jobData = new JobData() { 235 JobId = job.Id, 236 Data = jobByteArray 237 }; 238 239 PluginUtil.CollectDeclaringPlugins(plugins, usedTypes); 240 241 return jobData; 214 242 } 215 243 … … 239 267 if (handler != null) handler(this, EventArgs.Empty); 240 268 } 269 270 private void RegisterJobEvents() { 271 if (job != null) 272 job.PropertyChanged += new PropertyChangedEventHandler(job_PropertyChanged); 273 } 274 275 private void DeregisterJobEvents() { 276 if (job != null) 277 job.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(job_PropertyChanged); 278 } 279 280 private void job_PropertyChanged(object sender, PropertyChangedEventArgs e) { 281 if (e.PropertyName == "State") { 282 itemJobDownloaded = false; 283 } 284 } 241 285 #endregion 242 286 243 287 /// <summary> 244 288 /// Returns a list of HiveJobs including this and all its child-jobs recursively … … 326 370 } else { 327 371 ServiceLocator.Instance.CallHiveService(s => s.PauseJob(this.job.Id)); 328 } 372 } 329 373 } 330 374 … … 343 387 JobData jobData = new JobData(); 344 388 jobData.JobId = this.job.Id; 345 jobData.Data = PersistenceUtil.Serialize(this. jobItem);389 jobData.Data = PersistenceUtil.Serialize(this.itemJob); 346 390 service.UpdateJobData(this.Job, jobData); 347 391 service.RestartJob(this.job.Id); … … 350 394 }); 351 395 } 352 396 353 397 public ICollection<IItemTreeNodeAction<HiveJob>> Actions { 354 398 get { … … 364 408 public class HiveJob<T> : HiveJob where T : ItemJob { 365 409 366 public new T JobItem{367 get { return (T)base. JobItem; }368 internal set { base. JobItem= value; }410 public new T ItemJob { 411 get { return (T)base.ItemJob; } 412 internal set { base.ItemJob = value; } 369 413 } 370 414 371 415 #region Constructors and Cloning 372 416 public HiveJob() : base() { } 417 public HiveJob(T itemJob) : base(itemJob, true) { } 373 418 protected HiveJob(HiveJob original, Cloner cloner) 374 419 : base(original, cloner) { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveJobDownloader.cs
r6168 r6178 30 30 public class HiveJobDownloader { 31 31 private IEnumerable<Guid> jobIds; 32 private JobDownloader<ItemJob> jobDownloader;32 private ConcurrentJobDownloader<ItemJob> jobDownloader; 33 33 private IDictionary<Guid, HiveJob> results; 34 34 35 35 public bool IsFinished { 36 36 get { 37 //return tasks.TrueForAll(t => t.Status == TaskStatus.RanToCompletion ||38 // t.Status == TaskStatus.Faulted ||39 // t.Status == TaskStatus.Canceled);40 37 return results.Count == jobIds.Count(); 41 38 } … … 44 41 public int FinishedCount { 45 42 get { 46 //var faulted = tasks.Where(t => t.Status == TaskStatus.Faulted);47 //if (faulted.Count() > 0) {48 // abort = true;49 // throw faulted.First().Exception;50 //}51 //return tasks.Count(t => t.Status == TaskStatus.RanToCompletion ||52 // t.Status == TaskStatus.Faulted ||53 // t.Status == TaskStatus.Canceled);54 43 return results.Count; 55 44 } … … 58 47 public IDictionary<Guid, HiveJob> Results { 59 48 get { 60 //var results = new Dictionary<Guid, HiveJob>();61 //foreach (var t in tasks) {62 // if (t.Status == TaskStatus.Faulted) {63 // throw t.Exception;64 // }65 // if (t.Result != null)66 // results.Add(t.Result.Job.Id, t.Result);67 //}68 49 return results; 69 50 } … … 72 53 public HiveJobDownloader(IEnumerable<Guid> jobIds) { 73 54 this.jobIds = jobIds; 74 this.jobDownloader = new JobDownloader<ItemJob>(2, 2);55 this.jobDownloader = new ConcurrentJobDownloader<ItemJob>(2, 2); 75 56 this.results = new Dictionary<Guid, HiveJob>(); 76 57 } … … 81 62 (id, itemJob, exception) => { 82 63 if (exception != null) { 83 throw new JobDownloaderException("Downloading job failed", exception);64 throw new ConcurrentJobDownloaderException("Downloading job failed", exception); 84 65 } 85 66 Job job = ServiceLocator.Instance.CallHiveService(s => s.GetJob(id)); … … 95 76 } 96 77 }); 97 } 98 99 //tasks = new List<Task<HiveJob>>(); 100 //TaskScheduler.UnobservedTaskException += new EventHandler<UnobservedTaskExceptionEventArgs>(TaskScheduler_UnobservedTaskException); 101 //foreach (Guid jobId in jobIds) { 102 // tasks.Add(Task<JobData>.Factory.StartNew( 103 // (x) => DownloadJob(x), jobId) 104 // .ContinueWith((x) => DeserializeJob(x.Result))); 105 //} 78 } 106 79 } 107 108 //private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) {109 // e.SetObserved(); // avoid crash of process because task crashes. first exception found is handled in Results property110 //}111 112 //// use semaphore to ensure only few concurrenct connections and few SerializedJob objects in memory113 //private Semaphore downloadSemaphore = new Semaphore(2, 2);114 //private Semaphore deserializeSemaphore = new Semaphore(2, 2);115 //protected JobData DownloadJob(object jobId) {116 // downloadSemaphore.WaitOne();117 // deserializeSemaphore.WaitOne();118 // JobData result;119 // try {120 // if (abort) return null;121 // result = ServiceLocator.Instance.CallHiveService(s => s.GetJobData((Guid)jobId));122 // }123 // finally {124 // downloadSemaphore.Release();125 // }126 // return result;127 //}128 129 //protected HiveJob DeserializeJob(JobData jobData) {130 // try {131 // Job job = ServiceLocator.Instance.CallHiveService(s => s.GetJob(jobData.JobId));132 // if (abort || job == null || jobData == null) return null;133 134 // HiveJob hiveJob;135 // var itemJob = PersistenceUtil.Deserialize<ItemJob>(jobData.Data);136 // if (itemJob is OptimizerJob) {137 // hiveJob = new OptimizerHiveJob((OptimizerJob)itemJob);138 // } else {139 // hiveJob = new HiveJob(itemJob, true);140 // }141 // jobData.Data = null; // reduce memory consumption.142 // hiveJob.Job = job;143 // return hiveJob;144 // }145 // finally {146 // deserializeSemaphore.Release();147 // }148 //}149 80 } 150 81 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/OptimizerHiveJob.cs
r6111 r6178 37 37 public OptimizerHiveJob(IOptimizer optimizer) 38 38 : this() { 39 this. JobItem= new OptimizerJob(optimizer);39 this.ItemJob = new OptimizerJob(optimizer); 40 40 } 41 41 public OptimizerHiveJob(OptimizerJob optimizerJob) 42 42 : this() { 43 this. JobItem= optimizerJob;43 this.ItemJob = optimizerJob; 44 44 } 45 45 protected OptimizerHiveJob(OptimizerHiveJob original, Cloner cloner) … … 60 60 base.UpdateChildHiveJobs(); 61 61 if (Job != null && syncJobsWithOptimizers) { 62 if (! JobItem.ComputeInParallel) {62 if (!ItemJob.ComputeInParallel) { 63 63 this.childHiveJobs.Clear(); 64 64 } else { 65 if ( JobItem.Item is Optimization.Experiment) {66 Optimization.Experiment experiment = (Optimization.Experiment) JobItem.Item;65 if (ItemJob.Item is Optimization.Experiment) { 66 Optimization.Experiment experiment = (Optimization.Experiment)ItemJob.Item; 67 67 foreach (IOptimizer childOpt in experiment.Optimizers) { 68 68 this.childHiveJobs.Add(new OptimizerHiveJob(childOpt)); 69 69 } 70 } else if ( JobItem.Item is Optimization.BatchRun) {71 Optimization.BatchRun batchRun = JobItem.OptimizerAsBatchRun;70 } else if (ItemJob.Item is Optimization.BatchRun) { 71 Optimization.BatchRun batchRun = ItemJob.OptimizerAsBatchRun; 72 72 if (batchRun.Optimizer != null) { 73 73 while (this.childHiveJobs.Count < batchRun.Repetitions) { … … 83 83 } 84 84 85 protected override void Register JobItemEvents() {86 base.Register JobItemEvents();87 if ( JobItem!= null) {88 if ( JobItem.Item is Optimization.Experiment) {89 Optimization.Experiment experiment = JobItem.OptimizerAsExperiment;85 protected override void RegisterItemJobEvents() { 86 base.RegisterItemJobEvents(); 87 if (ItemJob != null) { 88 if (ItemJob.Item is Optimization.Experiment) { 89 Optimization.Experiment experiment = ItemJob.OptimizerAsExperiment; 90 90 experiment.Optimizers.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsAdded); 91 91 experiment.Optimizers.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsReplaced); 92 92 experiment.Optimizers.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsRemoved); 93 93 experiment.Optimizers.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_CollectionReset); 94 } else if ( JobItem.Item is Optimization.BatchRun) {95 Optimization.BatchRun batchRun = JobItem.OptimizerAsBatchRun;94 } else if (ItemJob.Item is Optimization.BatchRun) { 95 Optimization.BatchRun batchRun = ItemJob.OptimizerAsBatchRun; 96 96 batchRun.RepetitionsChanged += new EventHandler(batchRun_RepetitionsChanged); 97 97 batchRun.OptimizerChanged += new EventHandler(batchRun_OptimizerChanged); … … 99 99 } 100 100 } 101 protected override void Dergister JobItemsEvents() {102 base.Dergister JobItemsEvents();103 if ( JobItem!= null) {104 if ( JobItem.Item is Optimization.Experiment) {105 Optimization.Experiment experiment = JobItem.OptimizerAsExperiment;101 protected override void DergisterItemJobEvents() { 102 base.DergisterItemJobEvents(); 103 if (ItemJob != null) { 104 if (ItemJob.Item is Optimization.Experiment) { 105 Optimization.Experiment experiment = ItemJob.OptimizerAsExperiment; 106 106 experiment.Optimizers.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsAdded); 107 107 experiment.Optimizers.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsReplaced); 108 108 experiment.Optimizers.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsRemoved); 109 109 experiment.Optimizers.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_CollectionReset); 110 } else if ( JobItem.Item is Optimization.BatchRun) {111 Optimization.BatchRun batchRun = JobItem.OptimizerAsBatchRun;110 } else if (ItemJob.Item is Optimization.BatchRun) { 111 Optimization.BatchRun batchRun = ItemJob.OptimizerAsBatchRun; 112 112 batchRun.RepetitionsChanged -= new EventHandler(batchRun_RepetitionsChanged); 113 113 batchRun.OptimizerChanged -= new EventHandler(batchRun_OptimizerChanged); … … 129 129 130 130 private void Optimizers_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) { 131 if (syncJobsWithOptimizers && this. JobItem.ComputeInParallel) {131 if (syncJobsWithOptimizers && this.ItemJob.ComputeInParallel) { 132 132 foreach (var item in e.Items) { 133 133 if (GetChildByOptimizer(item.Value) == null && item.Value.Name != "Placeholder") { … … 138 138 } 139 139 private void Optimizers_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) { 140 if (syncJobsWithOptimizers && this. JobItem.ComputeInParallel) {140 if (syncJobsWithOptimizers && this.ItemJob.ComputeInParallel) { 141 141 foreach (var item in e.OldItems) { 142 142 this.childHiveJobs.Remove(this.GetChildByOptimizer(item.Value)); … … 150 150 } 151 151 private void Optimizers_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) { 152 if (syncJobsWithOptimizers && this. JobItem.ComputeInParallel) {152 if (syncJobsWithOptimizers && this.ItemJob.ComputeInParallel) { 153 153 foreach (var item in e.Items) { 154 154 this.childHiveJobs.Remove(this.GetChildByOptimizer(item.Value)); … … 157 157 } 158 158 private void Optimizers_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) { 159 if (syncJobsWithOptimizers && this. JobItem.ComputeInParallel) {159 if (syncJobsWithOptimizers && this.ItemJob.ComputeInParallel) { 160 160 foreach (var item in e.Items) { 161 161 this.childHiveJobs.Remove(this.GetChildByOptimizer(item.Value)); … … 174 174 syncJobsWithOptimizers = false; // don't sync with optimizers during this method 175 175 176 if (this. JobItem != null && this.JobItem.Item != null) {177 if (this. JobItem.Item is Optimization.Experiment) {178 UpdateOptimizerInExperiment(this. JobItem.OptimizerAsExperiment, optimizerJob);179 } else if (this. JobItem.Item is Optimization.BatchRun) {180 UpdateOptimizerInBatchRun(this. JobItem.OptimizerAsBatchRun, optimizerJob);176 if (this.ItemJob != null && this.ItemJob.Item != null) { 177 if (this.ItemJob.Item is Optimization.Experiment) { 178 UpdateOptimizerInExperiment(this.ItemJob.OptimizerAsExperiment, optimizerJob); 179 } else if (this.ItemJob.Item is Optimization.BatchRun) { 180 UpdateOptimizerInBatchRun(this.ItemJob.OptimizerAsBatchRun, optimizerJob); 181 181 } 182 182 } … … 185 185 if (!optimizerJob.ComputeInParallel) { 186 186 child.syncJobsWithOptimizers = false; 187 child. JobItem= optimizerJob;187 child.ItemJob = optimizerJob; 188 188 child.syncJobsWithOptimizers = true; 189 189 } … … 236 236 internal void SetIndexInParentOptimizerList(OptimizerHiveJob parentHiveJob) { 237 237 if (parentHiveJob != null) { 238 if (parentHiveJob. JobItem.Item is Optimization.Experiment) {239 this. JobItem.IndexInParentOptimizerList = parentHiveJob.JobItem.OptimizerAsExperiment.Optimizers.IndexOf(this.JobItem.Item);240 } else if (parentHiveJob. JobItem.Item is Optimization.BatchRun) {241 this. JobItem.IndexInParentOptimizerList = 0;238 if (parentHiveJob.ItemJob.Item is Optimization.Experiment) { 239 this.ItemJob.IndexInParentOptimizerList = parentHiveJob.ItemJob.OptimizerAsExperiment.Optimizers.IndexOf(this.ItemJob.Item); 240 } else if (parentHiveJob.ItemJob.Item is Optimization.BatchRun) { 241 this.ItemJob.IndexInParentOptimizerList = 0; 242 242 } else { 243 243 throw new NotSupportedException("Only Experiment and BatchRuns are supported"); … … 253 253 var optimizerHiveJob = (OptimizerHiveJob)hiveJob; 254 254 syncJobsWithOptimizers = false; 255 if (this. JobItem != null && optimizerHiveJob.JobItem!= null) {255 if (this.ItemJob != null && optimizerHiveJob.ItemJob != null) { 256 256 // if job is in state Paused, it has to preserve its ResultCollection, which is cleared when a optimizer is added to an experiment 257 257 OptimizerJob optimizerJobClone = null; 258 258 if (optimizerHiveJob.Job.State == JobState.Paused) { 259 optimizerJobClone = (OptimizerJob)optimizerHiveJob. JobItem.Clone();260 } 261 262 if (this. JobItem.Item is Optimization.Experiment) {263 if (!this. JobItem.OptimizerAsExperiment.Optimizers.Contains(optimizerHiveJob.JobItem.Item)) {264 UpdateOptimizerInExperiment(this. JobItem.OptimizerAsExperiment, optimizerHiveJob.JobItem);259 optimizerJobClone = (OptimizerJob)optimizerHiveJob.ItemJob.Clone(); 260 } 261 262 if (this.ItemJob.Item is Optimization.Experiment) { 263 if (!this.ItemJob.OptimizerAsExperiment.Optimizers.Contains(optimizerHiveJob.ItemJob.Item)) { 264 UpdateOptimizerInExperiment(this.ItemJob.OptimizerAsExperiment, optimizerHiveJob.ItemJob); 265 265 } 266 } else if (this. JobItem.Item is Optimization.BatchRun) {267 UpdateOptimizerInBatchRun(this. JobItem.OptimizerAsBatchRun, optimizerHiveJob.JobItem);266 } else if (this.ItemJob.Item is Optimization.BatchRun) { 267 UpdateOptimizerInBatchRun(this.ItemJob.OptimizerAsBatchRun, optimizerHiveJob.ItemJob); 268 268 } 269 269 270 270 if (optimizerHiveJob.Job.State == JobState.Paused) { 271 optimizerHiveJob. JobItem= optimizerJobClone;271 optimizerHiveJob.ItemJob = optimizerJobClone; 272 272 } 273 273 } … … 283 283 public override JobData GetAsJobData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) { 284 284 plugins = new List<IPluginDescription>(); 285 if (this. jobItem== null) // || this.jobItem.Optimizer == null285 if (this.itemJob == null) // || this.jobItem.Optimizer == null 286 286 return null; 287 287 288 288 IEnumerable<Type> usedTypes; 289 289 byte[] jobByteArray; 290 if (withoutChildOptimizers && this. JobItem.Item is Optimization.Experiment) {291 OptimizerJob clonedJob = (OptimizerJob)this. JobItem.Clone(); // use a cloned job, so that the childHiveJob don't get confused290 if (withoutChildOptimizers && this.ItemJob.Item is Optimization.Experiment) { 291 OptimizerJob clonedJob = (OptimizerJob)this.ItemJob.Clone(); // use a cloned job, so that the childHiveJob don't get confused 292 292 clonedJob.OptimizerAsExperiment.Optimizers.Clear(); 293 293 jobByteArray = PersistenceUtil.Serialize(clonedJob, out usedTypes); 294 } else if (withoutChildOptimizers && this. JobItem.Item is Optimization.BatchRun) {295 OptimizerJob clonedJob = (OptimizerJob)this. JobItem.Clone();294 } else if (withoutChildOptimizers && this.ItemJob.Item is Optimization.BatchRun) { 295 OptimizerJob clonedJob = (OptimizerJob)this.ItemJob.Clone(); 296 296 clonedJob.OptimizerAsBatchRun.Optimizer = null; 297 297 jobByteArray = PersistenceUtil.Serialize(clonedJob, out usedTypes); 298 } else if (this. JobItem.Item is IAlgorithm) {299 ((IAlgorithm)this. JobItem.Item).StoreAlgorithmInEachRun = false; // avoid storing the algorithm in runs to reduce size300 jobByteArray = PersistenceUtil.Serialize(this. JobItem, out usedTypes);298 } else if (this.ItemJob.Item is IAlgorithm) { 299 ((IAlgorithm)this.ItemJob.Item).StoreAlgorithmInEachRun = false; // avoid storing the algorithm in runs to reduce size 300 jobByteArray = PersistenceUtil.Serialize(this.ItemJob, out usedTypes); 301 301 } else { 302 jobByteArray = PersistenceUtil.Serialize(this. JobItem, out usedTypes);302 jobByteArray = PersistenceUtil.Serialize(this.ItemJob, out usedTypes); 303 303 } 304 304 … … 315 315 public OptimizerHiveJob GetChildByOptimizerJob(OptimizerJob optimizerJob) { 316 316 foreach (OptimizerHiveJob child in ChildHiveJobs) { 317 if (child. JobItem== optimizerJob)317 if (child.ItemJob == optimizerJob) 318 318 return child; 319 319 } … … 323 323 public HiveJob<OptimizerJob> GetChildByOptimizer(IOptimizer optimizer) { 324 324 foreach (OptimizerHiveJob child in ChildHiveJobs) { 325 if (child. JobItem.Item == optimizer)325 if (child.ItemJob.Item == optimizer) 326 326 return child; 327 327 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/RefreshableHiveExperiment.cs
r6168 r6178 34 34 public class RefreshableHiveExperiment : IHiveItem, IDeepCloneable, IContent, IProgressReporter { 35 35 private JobResultPoller jobResultPoller; 36 private JobDownloader<ItemJob> jobDownloader = newJobDownloader<ItemJob>(2, 2);36 private ConcurrentJobDownloader<ItemJob> jobDownloader = new ConcurrentJobDownloader<ItemJob>(2, 2); 37 37 private static object locker = new object(); 38 38 … … 83 83 } 84 84 85 [Storable] 86 private bool isControllable = true; 87 public bool IsControllable { 88 get { return isControllable; } 89 set { 90 if (value != isControllable) { 91 isControllable = value; 92 OnIsControllableChanged(); 93 } 94 } 95 } 96 85 97 #region Constructors and Cloning 86 98 public RefreshableHiveExperiment() { … … 99 111 this.RefreshAutomatically = original.RefreshAutomatically; 100 112 this.IncludeJobs = original.IncludeJobs; 113 this.IsControllable = original.IsControllable; 101 114 } 102 115 public IDeepCloneable Clone(Cloner cloner) { … … 163 176 jobDownloader.DownloadJob(hj.Job.Id, (id, itemJob, exception) => { 164 177 if (exception != null) { 165 throw new JobDownloaderException("Downloading job failed.", exception);178 throw new ConcurrentJobDownloaderException("Downloading job failed.", exception); 166 179 } 167 180 … … 171 184 // if the job is paused, download but don't integrate into parent optimizer (to avoid Prepare) 172 185 if (hj.Job.State == JobState.Paused) { 173 hj. JobItem= itemJob;186 hj.ItemJob = itemJob; 174 187 } else { 175 188 if (lightweightJob.ParentJobId.HasValue) { … … 177 190 parentHiveJob.IntegrateChild(itemJob, hj.Job.Id); 178 191 } else { 179 hj. JobItem= itemJob;192 hj.ItemJob = itemJob; 180 193 } 181 194 } … … 211 224 212 225 public bool AllJobsFinished() { 213 return hiveExperiment.GetAllHiveJobs().All(j => j.Job.State == JobState.Finished 214 || j.Job.State == JobState.Aborted 215 || j.Job.State == JobState.Failed); 226 return hiveExperiment.GetAllHiveJobs().All(j => (j.Job.State == JobState.Finished 227 || j.Job.State == JobState.Aborted 228 || j.Job.State == JobState.Failed) 229 && j.ItemJobDownloaded); 216 230 } 217 231 … … 299 313 if (handler != null) handler(sender, e); 300 314 } 315 316 public event EventHandler IsControllableChanged; 317 private void OnIsControllableChanged() { 318 var handler = IsControllableChanged; 319 if (handler != null) handler(this, EventArgs.Empty); 320 } 301 321 #endregion 302 322 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj
r6168 r6178 120 120 <Compile Include="Exceptions\JobResultPollingException.cs" /> 121 121 <Compile Include="Exceptions\OptimizerNotFoundException.cs" /> 122 <Compile Include="ExperimentManager\JobDownloader.cs" /> 122 <Compile Include="ExperimentManager\ConcurrentJobDownloader.cs" /> 123 <Compile Include="ExperimentManager\EngineHiveJob.cs" /> 123 124 <Compile Include="ExperimentManager\ExperimentManagerClient.cs" /> 124 125 <Compile Include="ExperimentManager\HiveJobDownloader.cs" /> 125 <Compile Include="ExperimentManager\ JobDownloaderException.cs" />126 <Compile Include="ExperimentManager\ConcurrentJobDownloaderException.cs" /> 126 127 <Compile Include="ExperimentManager\TreeView\IItemTree.cs" /> 127 128 <Compile Include="ExperimentManager\TreeView\IItemTreeAction.cs" /> … … 145 146 <None Include="Properties\AssemblyInfo.cs.frame" /> 146 147 <Compile Include="Exceptions\ServiceClientFactoryException.cs" /> 148 <Compile Include="ScopeExtensions.cs" /> 147 149 <Compile Include="ServiceClients\Appointment.cs" /> 148 150 <Compile Include="ServiceClients\HiveItemCollection.cs" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Jobs/EngineJob.cs
r6111 r6178 72 72 73 73 protected override void RegisterItemEvents() { 74 base.RegisterItemEvents(); 74 75 Item.Stopped += new EventHandler(engine_Stopped); 76 Item.Paused += new EventHandler(Item_Paused); 77 Item.Started += new EventHandler(Item_Started); 75 78 Item.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(engine_ExceptionOccurred); 79 Item.ExecutionStateChanged += new EventHandler(Item_ExecutionStateChanged); 80 Item.ExecutionTimeChanged += new EventHandler(Item_ExecutionTimeChanged); 76 81 } 77 82 78 83 protected override void DeregisterItemEvents() { 79 84 Item.Stopped -= new EventHandler(engine_Stopped); 85 Item.Paused -= new EventHandler(Item_Paused); 86 Item.Started -= new EventHandler(Item_Started); 80 87 Item.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(engine_ExceptionOccurred); 88 Item.ExecutionStateChanged -= new EventHandler(Item_ExecutionStateChanged); 89 Item.ExecutionTimeChanged -= new EventHandler(Item_ExecutionTimeChanged); 90 base.DeregisterItemEvents(); 81 91 } 82 92 … … 87 97 private void engine_Stopped(object sender, EventArgs e) { 88 98 OnJobStopped(); 99 } 100 101 private void Item_Paused(object sender, EventArgs e) { 102 OnJobPaused(); 103 } 104 105 private void Item_ExecutionTimeChanged(object sender, EventArgs e) { 106 OnExecutionTimeChanged(); 107 } 108 109 private void Item_ExecutionStateChanged(object sender, EventArgs e) { 110 OnExecutionStateChanged(); 111 } 112 113 private void Item_Started(object sender, EventArgs e) { 114 OnJobStarted(); 89 115 } 90 116
Note: See TracChangeset
for help on using the changeset viewer.