- Timestamp:
- 05/16/11 00:18:48 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4
- Files:
-
- 1 added
- 1 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/ConcurrentJobDownloader.cs
r6198 r6200 21 21 22 22 public void DownloadJob(Job job, Action<Job, T, Exception> onFinishedAction) { 23 Task<JobData>.Factory.StartNew((x) => DownloadJob(x), job.Id) 24 .ContinueWith((x) => DeserializeJob(x.Result)) 25 .ContinueWith((x) => OnJobFinished(job, x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously); 23 Task<T> task = Task<JobData>.Factory.StartNew((x) => DownloadJob(x), job.Id) 24 .ContinueWith((x) => DeserializeJob(x.Result)); 25 task.ContinueWith((x) => OnJobFinished(job, x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion); 26 task.ContinueWith((x) => OnJobFailed(job, x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted); 26 27 } 27 28 28 29 private void OnJobFinished(Job job, Task<T> task, Action<Job, T, Exception> onFinishedAction) { 29 onFinishedAction(job, task.Result, task.Exception); 30 onFinishedAction(job, task.Result, null); 31 } 32 private void OnJobFailed(Job job, Task<T> task, Action<Job, T, Exception> onFinishedAction) { 33 onFinishedAction(job, task.Result, task.Exception.Flatten()); 30 34 } 31 35 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/ExperimentManagerClient.cs
r6178 r6200 239 239 } 240 240 } 241 241 242 242 /// <summary> 243 243 /// Uploads the local configuration file as plugin … … 286 286 } 287 287 288 hiveJob.Job.PluginsNeededIds = PluginUtil.GetPluginDependencies(service, this.onlinePlugins, this.alreadyUploadedPlugins, plugins, useLocalPlugins); 288 TryAndRepeat(() => { 289 hiveJob.Job.PluginsNeededIds = PluginUtil.GetPluginDependencies(service, this.onlinePlugins, this.alreadyUploadedPlugins, plugins, useLocalPlugins); 290 }, -1, "Failed to upload plugins"); 289 291 hiveJob.Job.PluginsNeededIds.Add(configPluginId); 290 292 hiveJob.Job.HiveExperimentId = hiveExperimentId; … … 293 295 progress.ProgressValue = (double)jobCount / totalJobCount; 294 296 295 if (parentHiveJob != null) { 296 hiveJob.Job.Id = service.AddChildJob(parentHiveJob.Job.Id, hiveJob.Job, jobData); 297 } else { 298 hiveJob.Job.Id = service.AddJob(hiveJob.Job, jobData, groups.ToList()); 299 } 297 298 TryAndRepeat(() => { 299 if (parentHiveJob != null) { 300 hiveJob.Job.Id = service.AddChildJob(parentHiveJob.Job.Id, hiveJob.Job, jobData); 301 } else { 302 hiveJob.Job.Id = service.AddJob(hiveJob.Job, jobData, groups.ToList()); 303 } 304 }, -1, "Failed to add job"); 300 305 301 306 foreach (HiveJob child in hiveJob.ChildHiveJobs) { … … 382 387 } 383 388 } 389 390 /// <summary> 391 /// Executes the action. If it throws an exception it is repeated until repetition-count is reached. 392 /// If repetitions is -1, it is repeated infinitely. 393 /// </summary> 394 public static void TryAndRepeat(Action action, int repetitions, string errorMessage) { 395 try { action(); } 396 catch (Exception e) { 397 repetitions--; 398 if (repetitions == 0) 399 throw new HiveException(errorMessage, e); 400 TryAndRepeat(action, repetitions, errorMessage); 401 } 402 } 384 403 } 385 404 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveJob.cs
r6198 r6200 86 86 itemJob = value; 87 87 RegisterItemJobEvents(); 88 On JobItemChanged();88 OnItemJobChanged(); 89 89 IsFinishedJobDownloaded = true; 90 90 } … … 166 166 protected virtual void RegisterItemJobEvents() { 167 167 if (ItemJob != null) { 168 ItemJob.ComputeInParallelChanged += new EventHandler( JobItem_ComputeInParallelChanged);169 ItemJob.ToStringChanged += new EventHandler( JobItem_ToStringChanged);168 ItemJob.ComputeInParallelChanged += new EventHandler(ItemJob_ComputeInParallelChanged); 169 ItemJob.ToStringChanged += new EventHandler(ItemJob_ToStringChanged); 170 170 } 171 171 } 172 172 protected virtual void DergisterItemJobEvents() { 173 173 if (ItemJob != null) { 174 ItemJob.ComputeInParallelChanged -= new EventHandler( JobItem_ComputeInParallelChanged);175 ItemJob.ToStringChanged -= new EventHandler( JobItem_ToStringChanged);174 ItemJob.ComputeInParallelChanged -= new EventHandler(ItemJob_ComputeInParallelChanged); 175 ItemJob.ToStringChanged -= new EventHandler(ItemJob_ToStringChanged); 176 176 } 177 177 } … … 188 188 } 189 189 190 protected virtual void JobItem_ToStringChanged(object sender, EventArgs e) {190 protected virtual void ItemJob_ToStringChanged(object sender, EventArgs e) { 191 191 this.OnToStringChanged(); 192 192 } 193 193 194 protected virtual void JobItem_ComputeInParallelChanged(object sender, EventArgs e) {194 protected virtual void ItemJob_ComputeInParallelChanged(object sender, EventArgs e) { 195 195 if (ItemJob != null && syncJobsWithOptimizers) { 196 196 this.UpdateChildHiveJobs(); … … 203 203 204 204 public override string ToString() { 205 if (itemJob != null ) {205 if (itemJob != null && itemJob.Item != null) { 206 206 return itemJob.ToString(); 207 207 } else { 208 return base.ToString();208 return Job.Id.ToString(); 209 209 } 210 210 } … … 262 262 } 263 263 264 public event EventHandler JobItemChanged;265 private void On JobItemChanged() {266 JobItem_ComputeInParallelChanged(this, EventArgs.Empty);267 var handler = JobItemChanged;264 public event EventHandler ItemJobChanged; 265 private void OnItemJobChanged() { 266 ItemJob_ComputeInParallelChanged(this, EventArgs.Empty); 267 var handler = ItemJobChanged; 268 268 if (handler != null) handler(this, EventArgs.Empty); 269 269 } … … 410 410 public virtual void IntegrateChild(ItemJob job, Guid childJobId) { } 411 411 412 /// <summary> 413 /// Delete ItemJob 414 /// </summary> 415 public void ClearData() { 416 this.ItemJob.Item = null; 417 } 412 418 } 413 419 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/RefreshableHiveExperiment.cs
r6199 r6200 28 28 using HeuristicLab.Core; 29 29 using HeuristicLab.Hive; 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;31 30 32 31 namespace HeuristicLab.Clients.Hive { 33 [StorableClass]34 32 public class RefreshableHiveExperiment : IHiveItem, IDeepCloneable, IContent, IProgressReporter { 35 33 private JobResultPoller jobResultPoller; … … 37 35 private static object locker = new object(); 38 36 39 [Storable]40 37 private HiveExperiment hiveExperiment; 41 38 public HiveExperiment HiveExperiment { … … 55 52 56 53 /** include jobs when refreshing **/ 57 [Storable]58 54 private bool includeJobs; 59 55 public bool IncludeJobs { … … 62 58 } 63 59 64 [Storable]65 60 private bool refreshAutomatically; 66 61 public bool RefreshAutomatically { … … 83 78 } 84 79 85 [Storable]86 80 private bool isControllable = true; 87 81 public bool IsControllable { … … 95 89 } 96 90 97 [Storable]98 91 private ILog log; 99 92 public ILog Log { … … 120 113 cloner.RegisterClonedObject(original, this); 121 114 this.HiveExperiment = original.HiveExperiment; 122 this.RefreshAutomatically = original.RefreshAutomatically;123 115 this.IncludeJobs = original.IncludeJobs; 124 116 this.IsControllable = original.IsControllable; 125 117 this.Log = cloner.Clone(original.Log); 118 this.RefreshAutomatically = false; // do not start results polling automatically 126 119 } 127 120 public IDeepCloneable Clone(Cloner cloner) { … … 196 189 197 190 if (exception != null) { 198 var ex = new ConcurrentJobDownloaderException("Downloading job failed .", exception);191 var ex = new ConcurrentJobDownloaderException("Downloading job failed", exception); 199 192 LogException(ex); 200 193 localHiveJob.IsDownloading = false; … … 206 199 } else { 207 200 // if the job is paused, download but don't integrate into parent optimizer (to avoid Prepare) 208 209 201 210 202 if (localJob.State == JobState.Paused) { … … 231 223 } 232 224 UpdateTotalExecutionTime(); 233 UpdateStat s();225 UpdateStatistics(); 234 226 } 235 227 … … 237 229 private void LogException(Exception exception) { 238 230 lock (logLocker) { 239 log.LogException(exception);231 this.log.LogException(exception); 240 232 } 241 233 } … … 243 235 private void LogMessage(string message) { 244 236 lock (logLocker) { 245 log.LogMessage(message);237 this.log.LogMessage(message); 246 238 } 247 239 } … … 256 248 } 257 249 258 private void UpdateStat s() {250 private void UpdateStatistics() { 259 251 var jobs = hiveExperiment.GetAllHiveJobs(); 260 252 hiveExperiment.JobCount = jobs.Count(); 261 253 hiveExperiment.CalculatingCount = jobs.Count(j => j.Job.State == JobState.Calculating); 262 254 hiveExperiment.FinishedCount = jobs.Count(j => j.Job.State == JobState.Finished); 255 OnJobStatisticsChanged(); 263 256 } 264 257 … … 269 262 && j.IsFinishedJobDownloaded); 270 263 } 271 272 //public bool AllJobsFinishedAndDownloaded() {273 // return this.AllJobsFinished() && hiveExperiment.GetAllHiveJobs().All(j => j.JobItem.;274 //}275 264 276 265 private void jobResultPoller_ExceptionOccured(object sender, EventArgs<Exception> e) { … … 359 348 if (handler != null) handler(this, EventArgs.Empty); 360 349 } 350 351 public event EventHandler JobStatisticsChanged; 352 private void OnJobStatisticsChanged() { 353 var handler = JobStatisticsChanged; 354 if (handler != null) handler(this, EventArgs.Empty); 355 } 361 356 #endregion 362 357 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj
r6178 r6200 123 123 <Compile Include="ExperimentManager\EngineHiveJob.cs" /> 124 124 <Compile Include="ExperimentManager\ExperimentManagerClient.cs" /> 125 <Compile Include="Exceptions\HiveException.cs" /> 125 126 <Compile Include="ExperimentManager\HiveJobDownloader.cs" /> 126 127 <Compile Include="ExperimentManager\ConcurrentJobDownloaderException.cs" /> … … 155 156 <Compile Include="ServiceClients\HiveItem.cs" /> 156 157 <Compile Include="ServiceClients\JobData.cs" /> 157 <Compile Include="ServiceClients\OperationJob.cs" />158 158 <Compile Include="ExperimentManager\RefreshableHiveExperiment.cs" /> 159 159 <Compile Include="ServiceClients\Plugin.cs" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Jobs/EngineJob.cs
r6178 r6200 129 129 130 130 public override string Name { 131 get { return Item .ToString(); }131 get { return Item != null ? Item.ToString() : null; } 132 132 set { throw new NotSupportedException(); } 133 133 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Progress/Progress.cs
r4629 r6200 64 64 private void OnFinished() { 65 65 var handler = Finished; 66 if (handler != null) handler(this, EventArgs.Empty); 66 try { 67 if (handler != null) handler(this, EventArgs.Empty); 68 } 69 catch (Exception) { } 67 70 } 68 71 … … 70 73 private void OnStatusChanged() { 71 74 var handler = StatusChanged; 72 if (handler != null) handler(this, EventArgs.Empty); 75 try { 76 if (handler != null) handler(this, EventArgs.Empty); 77 } 78 catch (Exception) { } 73 79 } 74 80 … … 76 82 private void OnProgressChanged() { 77 83 var handler = ProgressValueChanged; 78 if (handler != null) handler(this, EventArgs.Empty); 84 try { 85 if (handler != null) handler(this, EventArgs.Empty); 86 } 87 catch (Exception) { } 79 88 } 80 89 #endregion -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveExperiment.cs
r6168 r6200 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;29 28 30 29 namespace HeuristicLab.Clients.Hive { 31 [StorableClass]32 30 public partial class HiveExperiment : IDeepCloneable, IContent, IProgressReporter { 33 [Storable]34 31 private bool useLocalPlugins; 35 32 public bool UseLocalPlugins { … … 38 35 } 39 36 40 [Storable]41 37 private ExecutionState executionState; 42 38 public ExecutionState ExecutionState { … … 50 46 } 51 47 52 [Storable]53 48 private TimeSpan executionTime; 54 49 public TimeSpan ExecutionTime { … … 62 57 } 63 58 64 [Storable]65 59 private ItemCollection<HiveJob> hiveJobs; 66 60 public ItemCollection<HiveJob> HiveJobs { … … 74 68 } 75 69 76 [Storable]77 70 private bool isProgressing; 78 71 public bool IsProgressing { … … 86 79 } 87 80 88 [Storable]89 81 private IProgress progress; 90 82 public IProgress Progress { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveItem.cs
r5955 r6200 28 28 29 29 namespace HeuristicLab.Clients.Hive { 30 31 30 public partial class HiveItem : IHiveItem { 32 31 public string ItemName { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveItemCollection.cs
r5955 r6200 6 6 7 7 namespace HeuristicLab.Clients.Hive { 8 [Item("HiveItem Collection", "Represents a collection of OKBitems.")]8 [Item("HiveItem Collection", "Represents a collection of Hive items.")] 9 9 public class HiveItemCollection<T> : ItemCollection<T> where T : class, IHiveItem { 10 10 protected HiveItemCollection(HiveItemCollection<T> original, Cloner cloner) : base(original, cloner) { } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/Job.cs
r6006 r6200 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.Common; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;26 25 27 26 namespace HeuristicLab.Clients.Hive { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/JobData.cs
r5779 r6200 24 24 25 25 namespace HeuristicLab.Clients.Hive { 26 27 26 public partial class JobData : IDeepCloneable, IContent { 28 27 public JobData() { } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/MessageContainer.cs
r5614 r6200 22 22 using System; 23 23 using HeuristicLab.Common; 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;25 24 26 25 namespace HeuristicLab.Clients.Hive { 27 [StorableClass]28 26 public partial class MessageContainer : IDeepCloneable, IContent { 29 27
Note: See TracChangeset
for help on using the changeset viewer.