- Timestamp:
- 05/17/11 11:34:40 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/RefreshableHiveExperimentView.cs
r6200 r6219 60 60 Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged); 61 61 Content.JobStatisticsChanged += new EventHandler(Content_JobStatisticsChanged); 62 Content.ExceptionOccured += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured); 62 63 } 63 64 … … 67 68 Content.IsControllableChanged -= new EventHandler(Content_IsControllableChanged); 68 69 Content.JobStatisticsChanged -= new EventHandler(Content_JobStatisticsChanged); 70 Content.ExceptionOccured -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured); 69 71 base.DeregisterContentEvents(); 70 72 } … … 252 254 } 253 255 } 256 private void Content_ExceptionOccured(object sender, EventArgs<Exception> e) { 257 if (Content.IsControllable) { 258 // show error dialog only if Controllable (otherwise it should continue trying without an error dialog (e.g. HiveEngine)) 259 ErrorHandling.ShowErrorDialog(this, e.Value); 260 } 261 } 254 262 #endregion 255 263 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/ConcurrentJobDownloader.cs
r6200 r6219 2 2 using System.Threading; 3 3 using System.Threading.Tasks; 4 using HeuristicLab.Common; 4 5 using HeuristicLab.Hive; 5 6 … … 20 21 } 21 22 22 public void DownloadJob(Job job, Action<Job, T , Exception> onFinishedAction) {23 public void DownloadJob(Job job, Action<Job, T> onFinishedAction) { 23 24 Task<T> task = Task<JobData>.Factory.StartNew((x) => DownloadJob(x), job.Id) 24 25 .ContinueWith((x) => DeserializeJob(x.Result)); … … 27 28 } 28 29 29 private void OnJobFinished(Job job, Task<T> task, Action<Job, T , Exception> onFinishedAction) {30 onFinishedAction(job, task.Result , null);30 private void OnJobFinished(Job job, Task<T> task, Action<Job, T> onFinishedAction) { 31 onFinishedAction(job, task.Result); 31 32 } 32 private void OnJobFailed(Job job, Task<T> task, Action<Job, T, Exception> onFinishedAction) { 33 onFinishedAction(job, task.Result, task.Exception.Flatten()); 33 private void OnJobFailed(Job job, Task<T> task, Action<Job, T> onFinishedAction) { 34 task.Exception.Flatten().Handle((e) => { return true; }); 35 OnExceptionOccured(task.Exception.Flatten()); 36 onFinishedAction(job, null); 34 37 } 35 38 … … 64 67 private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { 65 68 e.SetObserved(); // avoid crash of process because task crashes. first exception found is handled in Results property 69 OnExceptionOccured(new HiveException("Unobserved Exception in ConcurrentJobDownloader", e.Exception)); 70 } 71 72 public event EventHandler<EventArgs<Exception>> ExceptionOccured; 73 private void OnExceptionOccured(Exception exception) { 74 var handler = ExceptionOccured; 75 if (handler != null) handler(this, new EventArgs<Exception>(exception)); 66 76 } 67 77 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/ExperimentManagerClient.cs
r6200 r6219 192 192 193 193 #region Upload Experiment 194 private void UploadExperiment(RefreshableHiveExperiment optimizerHiveExperiment) {194 private void UploadExperiment(RefreshableHiveExperiment refreshableHiveExperiment) { 195 195 try { 196 optimizerHiveExperiment.HiveExperiment.Progress = new Progress("Connecting to server...");197 optimizerHiveExperiment.HiveExperiment.IsProgressing = true;196 refreshableHiveExperiment.HiveExperiment.Progress = new Progress("Connecting to server..."); 197 refreshableHiveExperiment.HiveExperiment.IsProgressing = true; 198 198 ServiceLocator.Instance.CallHiveService(service => { 199 IEnumerable<string> resourceNames = ToResourceNameList( optimizerHiveExperiment.HiveExperiment.ResourceNames);199 IEnumerable<string> resourceNames = ToResourceNameList(refreshableHiveExperiment.HiveExperiment.ResourceNames); 200 200 var resourceIds = new List<Guid>(); 201 201 foreach (var resourceName in resourceNames) { … … 207 207 } 208 208 209 foreach (OptimizerHiveJob hiveJob in optimizerHiveExperiment.HiveExperiment.HiveJobs.OfType<OptimizerHiveJob>()) {209 foreach (OptimizerHiveJob hiveJob in refreshableHiveExperiment.HiveExperiment.HiveJobs.OfType<OptimizerHiveJob>()) { 210 210 hiveJob.SetIndexInParentOptimizerList(null); 211 211 } 212 212 213 213 // upload HiveExperiment 214 optimizerHiveExperiment.HiveExperiment.Progress.Status = "Uploading HiveExperiment...";215 optimizerHiveExperiment.HiveExperiment.Id = service.AddHiveExperiment(optimizerHiveExperiment.HiveExperiment);216 217 int totalJobCount = optimizerHiveExperiment.HiveExperiment.GetAllHiveJobs().Count();214 refreshableHiveExperiment.HiveExperiment.Progress.Status = "Uploading HiveExperiment..."; 215 refreshableHiveExperiment.HiveExperiment.Id = service.AddHiveExperiment(refreshableHiveExperiment.HiveExperiment); 216 217 int totalJobCount = refreshableHiveExperiment.HiveExperiment.GetAllHiveJobs().Count(); 218 218 int jobCount = 0; 219 219 220 220 // upload plugins 221 optimizerHiveExperiment.HiveExperiment.Progress.Status = "Uploading plugins...";221 refreshableHiveExperiment.HiveExperiment.Progress.Status = "Uploading plugins..."; 222 222 this.OnlinePlugins = service.GetPlugins(); 223 223 this.AlreadyUploadedPlugins = new List<Plugin>(); … … 226 226 227 227 // upload jobs 228 optimizerHiveExperiment.HiveExperiment.Progress.Status = "Uploading jobs...";229 230 foreach (HiveJob hiveJob in optimizerHiveExperiment.HiveExperiment.HiveJobs) {231 UploadJobWithChildren( optimizerHiveExperiment.HiveExperiment.Progress, service, hiveJob, null, resourceIds, ref jobCount, totalJobCount, configFilePlugin.Id, optimizerHiveExperiment.HiveExperiment.UseLocalPlugins, optimizerHiveExperiment.HiveExperiment.Id);228 refreshableHiveExperiment.HiveExperiment.Progress.Status = "Uploading jobs..."; 229 230 foreach (HiveJob hiveJob in refreshableHiveExperiment.HiveExperiment.HiveJobs) { 231 UploadJobWithChildren(refreshableHiveExperiment.HiveExperiment.Progress, service, hiveJob, null, resourceIds, ref jobCount, totalJobCount, configFilePlugin.Id, refreshableHiveExperiment.HiveExperiment.UseLocalPlugins, refreshableHiveExperiment.HiveExperiment.Id, refreshableHiveExperiment.Log); 232 232 } 233 233 234 if ( optimizerHiveExperiment.RefreshAutomatically) optimizerHiveExperiment.StartResultPolling();234 if (refreshableHiveExperiment.RefreshAutomatically) refreshableHiveExperiment.StartResultPolling(); 235 235 }); 236 236 } 237 237 finally { 238 optimizerHiveExperiment.HiveExperiment.IsProgressing = false;238 refreshableHiveExperiment.HiveExperiment.IsProgressing = false; 239 239 } 240 240 } … … 268 268 /// <param name="parentHiveJob">shall be null if its the root job</param> 269 269 /// <param name="groups"></param> 270 private void UploadJobWithChildren(IProgress progress, IHiveService service, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<Guid> groups, ref int jobCount, int totalJobCount, Guid configPluginId, bool useLocalPlugins, Guid hiveExperimentId ) {270 private void UploadJobWithChildren(IProgress progress, IHiveService service, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<Guid> groups, ref int jobCount, int totalJobCount, Guid configPluginId, bool useLocalPlugins, Guid hiveExperimentId, ILog log) { 271 271 jobCount++; 272 272 progress.Status = string.Format("Serializing job {0} of {1}", jobCount, totalJobCount); … … 292 292 hiveJob.Job.HiveExperimentId = hiveExperimentId; 293 293 294 progress.Status = string.Format("Uploading job {0} of {1} ({2} kb )", jobCount, totalJobCount, jobData.Data.Count() / 1024);294 progress.Status = string.Format("Uploading job {0} of {1} ({2} kb, {3} objects)", jobCount, totalJobCount, jobData.Data.Count() / 1024, hiveJob.ItemJob.GetObjectGraphObjects().Count()); 295 295 progress.ProgressValue = (double)jobCount / totalJobCount; 296 296 297 297 log.LogMessage(progress.Status); 298 298 TryAndRepeat(() => { 299 299 if (parentHiveJob != null) { … … 305 305 306 306 foreach (HiveJob child in hiveJob.ChildHiveJobs) { 307 UploadJobWithChildren(progress, service, child, hiveJob, groups, ref jobCount, totalJobCount, configPluginId, useLocalPlugins, hiveExperimentId );307 UploadJobWithChildren(progress, service, child, hiveJob, groups, ref jobCount, totalJobCount, configPluginId, useLocalPlugins, hiveExperimentId, log); 308 308 } 309 309 } … … 331 331 hiveExperiment.Progress.Status = string.Format("Downloading/deserializing jobs... ({0}/{1} finished)", downloader.FinishedCount, totalJobCount); 332 332 Thread.Sleep(500); 333 334 if (downloader.IsFaulted) { 335 throw downloader.Exception; 336 } 333 337 } 334 338 IDictionary<Guid, HiveJob> allHiveJobs = downloader.Results; … … 393 397 /// </summary> 394 398 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); 399 while (true) { 400 try { action(); return; } 401 catch (Exception e) { 402 if (repetitions == 0) 403 throw new HiveException(errorMessage, e); 404 repetitions--; 405 } 401 406 } 402 407 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveJobDownloader.cs
r6198 r6219 25 25 using HeuristicLab.Clients.Hive.ExperimentManager; 26 26 using HeuristicLab.Clients.Hive.Jobs; 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Hive; 28 29 … … 32 33 private ConcurrentJobDownloader<ItemJob> jobDownloader; 33 34 private IDictionary<Guid, HiveJob> results; 35 private bool exceptionOccured = false; 36 private Exception currentException; 34 37 35 38 public bool IsFinished { … … 39 42 } 40 43 44 public bool IsFaulted { 45 get { 46 return exceptionOccured; 47 } 48 } 49 50 public Exception Exception { 51 get { 52 return currentException; 53 } 54 } 55 41 56 public int FinishedCount { 42 57 get { … … 54 69 this.jobIds = jobIds; 55 70 this.jobDownloader = new ConcurrentJobDownloader<ItemJob>(2, 2); 71 this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured); 56 72 this.results = new Dictionary<Guid, HiveJob>(); 57 73 } 58 74 59 75 public void StartAsync() { 60 76 foreach (Guid jobId in jobIds) { … … 62 78 63 79 jobDownloader.DownloadJob(job, 64 (localJob, itemJob, exception) => { 65 if (exception != null) { 66 throw new ConcurrentJobDownloaderException("Downloading job failed", exception); 67 } 80 (localJob, itemJob) => { 68 81 if (localJob != null && itemJob != null) { 69 82 HiveJob hiveJob; … … 79 92 } 80 93 } 94 95 private void jobDownloader_ExceptionOccured(object sender, EventArgs<Exception> e) { 96 OnExceptionOccured(e.Value); 97 } 98 99 public event EventHandler<EventArgs<Exception>> ExceptionOccured; 100 private void OnExceptionOccured(Exception exception) { 101 this.exceptionOccured = true; 102 this.currentException = exception; 103 var handler = ExceptionOccured; 104 if (handler != null) handler(this, new EventArgs<Exception>(exception)); 105 } 81 106 } 82 107 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/JobResultPoller.cs
r6111 r6219 54 54 } 55 55 56 private bool autoResumeOnException = false; 57 public bool AutoResumeOnException { 58 get { return autoResumeOnException; } 59 set { autoResumeOnException = value; } 60 } 61 62 56 63 public JobResultPoller(Guid hiveExperimentId, TimeSpan interval) { 57 64 this.isPolling = false; … … 61 68 62 69 public void Start() { 70 IsPolling = true; 63 71 stopRequested = false; 64 72 thread = new Thread(RunPolling); 65 73 thread.Start(); 66 IsPolling = true;67 74 } 68 75 69 76 public void Stop() { 70 // use AutoResetEvent.Set instead if Thread.Interrupt because its much cleaner71 77 stopRequested = true; 72 78 waitHandle.Set(); … … 76 82 77 83 private void RunPolling() { 78 try { 79 waitHandle = new AutoResetEvent(false); 80 while (!stopRequested) { 81 OnPollingStarted(); 82 FetchJobResults(); 83 OnPollingFinished(); 84 waitHandle.WaitOne(Interval); 84 while (true) { 85 IsPolling = true; 86 try { 87 waitHandle = new AutoResetEvent(false); 88 while (!stopRequested) { 89 OnPollingStarted(); 90 FetchJobResults(); 91 OnPollingFinished(); 92 waitHandle.WaitOne(Interval); 93 } 94 waitHandle.Close(); 85 95 } 86 waitHandle.Close();87 }88 catch (Exception e) {89 OnExceptionOccured(e);90 }91 finally {92 IsPolling = false;96 catch (Exception e) { 97 OnExceptionOccured(e); 98 } 99 finally { 100 IsPolling = false; 101 } 102 if (!autoResumeOnException) return; 93 103 } 94 104 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/RefreshableHiveExperiment.cs
r6200 r6219 32 32 public class RefreshableHiveExperiment : IHiveItem, IDeepCloneable, IContent, IProgressReporter { 33 33 private JobResultPoller jobResultPoller; 34 private ConcurrentJobDownloader<ItemJob> jobDownloader = new ConcurrentJobDownloader<ItemJob>(2, 2);34 private ConcurrentJobDownloader<ItemJob> jobDownloader; 35 35 private static object locker = new object(); 36 36 … … 78 78 } 79 79 80 // if true, all control buttons should be enabled. otherwise disabled (used for HiveEngine) 80 81 private bool isControllable = true; 81 82 public bool IsControllable { … … 103 104 this.HiveExperiment = new HiveExperiment(); 104 105 this.log = new Log(); 106 this.jobDownloader = new ConcurrentJobDownloader<ItemJob>(2, 2); 107 this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured); 105 108 } 106 109 public RefreshableHiveExperiment(HiveExperiment hiveExperiment) { … … 109 112 this.HiveExperiment = hiveExperiment; 110 113 this.log = new Log(); 114 this.jobDownloader = new ConcurrentJobDownloader<ItemJob>(2, 2); 115 this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured); 111 116 } 112 117 protected RefreshableHiveExperiment(RefreshableHiveExperiment original, Cloner cloner) { … … 117 122 this.Log = cloner.Clone(original.Log); 118 123 this.RefreshAutomatically = false; // do not start results polling automatically 124 this.jobDownloader = new ConcurrentJobDownloader<ItemJob>(2, 2); 125 this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured); 119 126 } 120 127 public IDeepCloneable Clone(Cloner cloner) { … … 143 150 jobResultPoller = new JobResultPoller(hiveExperiment.Id, /*ApplicationConstants.ResultPollingInterval*/new TimeSpan(0, 0, 5)); //TODO: find a better place for ApplicationConstants 144 151 RegisterResultPollingEvents(); 152 jobResultPoller.AutoResumeOnException = !IsControllable; 145 153 } 146 154 … … 184 192 LogMessage(string.Format("Downloading job {0}", lightweightJob.Id)); 185 193 hiveJob.IsDownloading = true; 186 jobDownloader.DownloadJob(hiveJob.Job, (localJob, itemJob , exception) => {194 jobDownloader.DownloadJob(hiveJob.Job, (localJob, itemJob) => { 187 195 LogMessage(string.Format("Finished downloading job {0}", localJob.Id)); 188 196 HiveJob localHiveJob = GetHiveJobById(localJob.Id); 189 197 190 if (exception != null) { 191 var ex = new ConcurrentJobDownloaderException("Downloading job failed", exception); 192 LogException(ex); 198 if (itemJob == null) { 193 199 localHiveJob.IsDownloading = false; 194 throw ex;195 200 } 196 201 … … 247 252 return null; 248 253 } 249 250 254 private void UpdateStatistics() { 251 255 var jobs = hiveExperiment.GetAllHiveJobs(); … … 264 268 265 269 private void jobResultPoller_ExceptionOccured(object sender, EventArgs<Exception> e) { 266 //OnExceptionOccured(e.Value); 267 } 268 270 OnExceptionOccured(e.Value); 271 } 272 private void jobDownloader_ExceptionOccured(object sender, EventArgs<Exception> e) { 273 OnExceptionOccured(e.Value); 274 } 269 275 public void UpdateTotalExecutionTime() { 270 276 hiveExperiment.ExecutionTime = TimeSpan.FromMilliseconds(hiveExperiment.GetAllHiveJobs().Sum(x => x.Job.ExecutionTime.HasValue ? x.Job.ExecutionTime.Value.TotalMilliseconds : 0)); … … 354 360 if (handler != null) handler(this, EventArgs.Empty); 355 361 } 362 363 public event EventHandler<EventArgs<Exception>> ExceptionOccured; 364 private void OnExceptionOccured(Exception exception) { 365 LogException(exception); 366 var handler = ExceptionOccured; 367 if (handler != null) handler(this, new EventArgs<Exception>(exception)); 368 } 356 369 #endregion 357 370 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Hive/3.4/ItemJob.cs
r6110 r6219 47 47 } 48 48 } 49 } 49 } 50 50 51 51 [Storable] … … 108 108 #region IJob Members 109 109 110 public abstract ExecutionState ExecutionState { get; }111 112 public abstract TimeSpan ExecutionTime { get; }110 public abstract ExecutionState ExecutionState { get; } 111 112 public abstract TimeSpan ExecutionTime { get; } 113 113 114 114 public abstract void Prepare(); … … 176 176 } 177 177 #endregion 178 178 179 179 #region INamedItem Members 180 180 public abstract bool CanChangeDescription { get; } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Test
- Property svn:ignore
-
old new 2 2 obj 3 3 HeuristicLab.HiveEngine.Test.csproj.vs10x 4 HeuristicLab.HiveEngine.Test.csproj.user
-
- Property svn:ignore
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Test/Program.cs
r6178 r6219 32 32 public override void Run() { 33 33 ContentManager.Initialize(new PersistenceContentManager()); 34 35 34 36 35 OptimizerJob job = new OptimizerJob(new Experiment()); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Views/3.4/Properties/AssemblyInfo.cs.frame
r6217 r6219 54 54 // by using the '*' as shown below: 55 55 // [assembly: AssemblyVersion("1.0.*")] 56 [assembly: AssemblyVersion("3. 3.0.0")]57 [assembly: AssemblyFileVersion("3. 3.0.$WCREV$")]56 [assembly: AssemblyVersion("3.4.0.0")] 57 [assembly: AssemblyFileVersion("3.4.0.$WCREV$")] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HeuristicLab.HiveEngine-3.4.csproj
r6212 r6219 134 134 <Compile Include="HeuristicLabHiveEnginePlugin.cs" /> 135 135 <Compile Include="Exceptions\ScopeMergeException.cs" /> 136 <Compile Include="Properties\AssemblyInfo.cs" /> 136 137 <None Include="HeuristicLabHiveEnginePlugin.cs.frame" /> 137 138 <Compile Include="HiveEngine.cs" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs
r6212 r6219 106 106 this.executionTimeOnHive = original.executionTimeOnHive; 107 107 this.useLocalPlugins = original.useLocalPlugins; 108 this.hiveExperiments = cloner.Clone(original.hiveExperiments);108 // this.hiveExperiments = cloner.Clone(original.hiveExperiments); do not clone hiveExperiments - otherwise they would be sent with every job 109 109 } 110 110 public override IDeepCloneable Clone(Cloner cloner) { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/Properties/AssemblyInfo.cs.frame
r6001 r6219 54 54 // by using the '*' as shown below: 55 55 // [assembly: AssemblyVersion("1.0.*")] 56 [assembly: AssemblyVersion("3. 3.0.0")]57 [assembly: AssemblyFileVersion("3. 3.0.$WCREV$")]56 [assembly: AssemblyVersion("3.4.0.0")] 57 [assembly: AssemblyFileVersion("3.4.0.$WCREV$")]
Note: See TracChangeset
for help on using the changeset viewer.