Changeset 6419
- Timestamp:
- 06/16/11 00:06:54 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources
- Files:
-
- 2 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.Designer.cs
r6381 r6419 21 21 22 22 using HeuristicLab.Clients.Hive.Views.ExperimentManager; 23 using HeuristicLab.MainForm.WindowsForms; 23 24 namespace HeuristicLab.Clients.Hive.ExperimentManager.Views { 24 25 partial class RefreshableHiveExperimentView { … … 66 67 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 67 68 this.refreshButton = new System.Windows.Forms.Button(); 69 this.isPrivilegedCheckBox = new System.Windows.Forms.CheckBox(); 68 70 this.refreshAutomaticallyCheckBox = new System.Windows.Forms.CheckBox(); 69 71 this.infoGroupBox = new System.Windows.Forms.GroupBox(); … … 74 76 this.calculatingLabel = new System.Windows.Forms.Label(); 75 77 this.jobsLabel = new System.Windows.Forms.Label(); 76 this.isPrivilegedCheckBox = new System.Windows.Forms.CheckBox(); 78 this.stateTabPage = new System.Windows.Forms.TabPage(); 79 this.stateLogViewHost = new ViewHost(); 77 80 this.tabControl.SuspendLayout(); 78 81 this.jobsTabPage.SuspendLayout(); 79 82 this.logTabPage.SuspendLayout(); 80 83 this.infoGroupBox.SuspendLayout(); 84 this.stateTabPage.SuspendLayout(); 81 85 this.SuspendLayout(); 82 86 // … … 87 91 | System.Windows.Forms.AnchorStyles.Right))); 88 92 this.tabControl.Controls.Add(this.jobsTabPage); 93 this.tabControl.Controls.Add(this.stateTabPage); 89 94 this.tabControl.Controls.Add(this.logTabPage); 90 95 this.tabControl.Location = new System.Drawing.Point(0, 78); … … 126 131 this.logTabPage.Location = new System.Drawing.Point(4, 22); 127 132 this.logTabPage.Name = "logTabPage"; 128 this.logTabPage.Size = new System.Drawing.Size( 813, 494);133 this.logTabPage.Size = new System.Drawing.Size(709, 426); 129 134 this.logTabPage.TabIndex = 3; 130 135 this.logTabPage.Text = "Log"; … … 271 276 this.refreshButton.UseVisualStyleBackColor = true; 272 277 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); 278 // 279 // isPrivilegedCheckBox 280 // 281 this.isPrivilegedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 282 this.isPrivilegedCheckBox.AutoSize = true; 283 this.isPrivilegedCheckBox.Location = new System.Drawing.Point(383, 55); 284 this.isPrivilegedCheckBox.Name = "isPrivilegedCheckBox"; 285 this.isPrivilegedCheckBox.Size = new System.Drawing.Size(80, 17); 286 this.isPrivilegedCheckBox.TabIndex = 26; 287 this.isPrivilegedCheckBox.Text = "IsPrivileged"; 288 this.toolTip.SetToolTip(this.isPrivilegedCheckBox, "If checked, the job will be executed in a privileged sandbox on the slave."); 289 this.isPrivilegedCheckBox.UseVisualStyleBackColor = true; 290 this.isPrivilegedCheckBox.CheckedChanged += new System.EventHandler(this.isPrivilegedCheckBox_CheckedChanged); 273 291 // 274 292 // refreshAutomaticallyCheckBox … … 353 371 this.jobsLabel.Text = "Jobs:"; 354 372 // 355 // isPrivilegedCheckBox 356 // 357 this.isPrivilegedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 358 this.isPrivilegedCheckBox.AutoSize = true; 359 this.isPrivilegedCheckBox.Location = new System.Drawing.Point(383, 55); 360 this.isPrivilegedCheckBox.Name = "isPrivilegedCheckBox"; 361 this.isPrivilegedCheckBox.Size = new System.Drawing.Size(80, 17); 362 this.isPrivilegedCheckBox.TabIndex = 26; 363 this.isPrivilegedCheckBox.Text = "IsPrivileged"; 364 this.toolTip.SetToolTip(this.isPrivilegedCheckBox, "If checked, the job will be executed in a privileged sandbox on the slave."); 365 this.isPrivilegedCheckBox.UseVisualStyleBackColor = true; 366 this.isPrivilegedCheckBox.CheckedChanged += new System.EventHandler(this.isPrivilegedCheckBox_CheckedChanged); 373 // stateTabPage 374 // 375 this.stateTabPage.Controls.Add(this.stateLogViewHost); 376 this.stateTabPage.Location = new System.Drawing.Point(4, 22); 377 this.stateTabPage.Name = "stateTabPage"; 378 this.stateTabPage.Size = new System.Drawing.Size(709, 426); 379 this.stateTabPage.TabIndex = 6; 380 this.stateTabPage.Text = "State"; 381 this.stateTabPage.UseVisualStyleBackColor = true; 382 // 383 // stateLogViewHost 384 // 385 this.stateLogViewHost.Caption = "StateLog View"; 386 this.stateLogViewHost.Content = null; 387 this.stateLogViewHost.Dock = System.Windows.Forms.DockStyle.Fill; 388 this.stateLogViewHost.Location = new System.Drawing.Point(0, 0); 389 this.stateLogViewHost.Name = "stateLogViewHost"; 390 this.stateLogViewHost.ReadOnly = false; 391 this.stateLogViewHost.Size = new System.Drawing.Size(709, 426); 392 this.stateLogViewHost.TabIndex = 0; 367 393 // 368 394 // RefreshableHiveExperimentView … … 393 419 this.infoGroupBox.ResumeLayout(false); 394 420 this.infoGroupBox.PerformLayout(); 421 this.stateTabPage.ResumeLayout(false); 395 422 this.ResumeLayout(false); 396 423 this.PerformLayout(); … … 426 453 private System.Windows.Forms.Label jobsLabel; 427 454 private System.Windows.Forms.CheckBox isPrivilegedCheckBox; 455 private System.Windows.Forms.TabPage stateTabPage; 456 private ViewHost stateLogViewHost; 428 457 429 458 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.cs
r6381 r6419 61 61 Content.JobStatisticsChanged += new EventHandler(Content_JobStatisticsChanged); 62 62 Content.ExceptionOccured += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured); 63 Content.StateLogListChanged += new EventHandler(Content_StateLogListChanged); 63 64 } 64 65 … … 69 70 Content.JobStatisticsChanged -= new EventHandler(Content_JobStatisticsChanged); 70 71 Content.ExceptionOccured -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured); 72 Content.StateLogListChanged -= new EventHandler(Content_StateLogListChanged); 71 73 base.DeregisterContentEvents(); 72 74 } … … 105 107 isPrivilegedCheckBox.Checked = false; 106 108 logView.Content = null; 107 refreshAutomaticallyCheckBox.Checked = false; 109 refreshAutomaticallyCheckBox.Checked = false; 108 110 logView.Content = null; 109 111 } else { … … 120 122 Content_HiveJobChanged(this, EventArgs.Empty); 121 123 Content_IsProgressingChanged(this, EventArgs.Empty); 124 Content_StateLogListChanged(this, EventArgs.Empty); 122 125 SetEnabledStateOfControls(); 123 126 } … … 260 263 // show error dialog only if Controllable (otherwise it should continue trying without an error dialog (e.g. HiveEngine)) 261 264 ErrorHandling.ShowErrorDialog(this, e.Value); 265 } 266 } 267 private void Content_StateLogListChanged(object sender, EventArgs e) { 268 if (InvokeRequired) 269 Invoke(new EventHandler(Content_StateLogListChanged), sender, e); 270 else { 271 UpdateStateLogList(); 272 } 273 } 274 275 private void UpdateStateLogList() { 276 if (Content != null && this.Content.HiveExperiment != null) { 277 stateLogViewHost.Content = this.Content.HiveExperiment.StateLogList; 278 } else { 279 stateLogViewHost.Content = null; 262 280 } 263 281 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs
r6381 r6419 31 31 /// </summary> 32 32 public class Executor : MarshalByRefObject, IDisposable { 33 public Guid JobId { get; set; }34 private IJob Job { get; set; }35 public int CoresNeeded { get; set; }36 public int MemoryNeeded { get; set; }37 33 private bool wasJobAborted = false; 38 34 private Semaphore pauseStopSem = new Semaphore(0, 1); 39 35 private Semaphore startJobSem = new Semaphore(0, 1); 40 //make pause or stop wait until start is finished 41 private Semaphore jobStartedSem = new Semaphore(0, 1); 36 private Semaphore jobStartedSem = new Semaphore(0, 1); // make pause or stop wait until start is finished 42 37 private ExecutorQueue executorQueue; 43 public ExecutorQueue ExecutorCommandQueue { 44 get { 45 return executorQueue; 46 } 47 } 38 private bool jobDataInvalid = false; // if true, the jobdata is not sent when the job is failed 39 private IJob job; 40 private DateTime creationTime; 41 42 public Guid JobId { get; set; } 43 public int CoresNeeded { get; set; } 44 public int MemoryNeeded { get; set; } 48 45 public bool IsStopping { get; set; } 49 46 public bool IsPausing { get; set; } 50 private DateTime CreationTime { get; set; } 47 51 48 private Exception currentException; 52 49 public String CurrentException { … … 60 57 } 61 58 59 public ExecutorQueue ExecutorCommandQueue { 60 get { return executorQueue; } 61 } 62 62 63 private ExecutionState ExecutionState { 63 get { 64 return Job != null ? Job.ExecutionState : HeuristicLab.Core.ExecutionState.Stopped; 65 } 64 get { return job != null ? job.ExecutionState : HeuristicLab.Core.ExecutionState.Stopped; } 66 65 } 67 66 68 67 public TimeSpan ExecutionTime { 69 get { 70 return Job != null ? Job.ExecutionTime : new TimeSpan(0, 0, 0); 71 } 68 get { return job != null ? job.ExecutionTime : new TimeSpan(0, 0, 0); } 72 69 } 73 70 … … 80 77 public void Start(byte[] serializedJob) { 81 78 try { 82 CreationTime = DateTime.Now;83 Job = PersistenceUtil.Deserialize<IJob>(serializedJob);79 creationTime = DateTime.Now; 80 job = PersistenceUtil.Deserialize<IJob>(serializedJob); 84 81 85 82 RegisterJobEvents(); 86 83 87 Job.Start(); 88 if (!jobStartedSem.WaitOne(TimeSpan.FromSeconds(15))) { 84 job.Start(); 85 if (!jobStartedSem.WaitOne(TimeSpan.FromSeconds(25))) { 86 jobDataInvalid = true; 89 87 throw new TimeoutException("Timeout when starting the job. JobStarted event was not fired."); 90 88 } … … 101 99 // wait until job is started. if this does not happen, the Job is null an we give up 102 100 jobStartedSem.WaitOne(TimeSpan.FromSeconds(15)); 103 if ( Job == null) {101 if (job == null) { 104 102 currentException = new Exception("Pausing job " + this.JobId + ": Job is null"); 105 103 return; 106 104 } 107 105 108 if ( Job.ExecutionState == ExecutionState.Started) {106 if (job.ExecutionState == ExecutionState.Started) { 109 107 try { 110 Job.Pause();108 job.Pause(); 111 109 //we need to block the pause... 112 110 pauseStopSem.WaitOne(); … … 122 120 // wait until job is started. if this does not happen, the Job is null an we give up 123 121 jobStartedSem.WaitOne(TimeSpan.FromSeconds(15)); 124 if ( Job == null) {122 if (job == null) { 125 123 currentException = new Exception("Stopping job " + this.JobId + ": Job is null"); 126 124 } … … 129 127 if ((ExecutionState == ExecutionState.Started) || (ExecutionState == ExecutionState.Paused)) { 130 128 try { 131 Job.Stop();129 job.Stop(); 132 130 pauseStopSem.WaitOne(); 133 131 } … … 139 137 140 138 private void RegisterJobEvents() { 141 Job.JobStopped += new EventHandler(Job_JobStopped);142 Job.JobFailed += new EventHandler(Job_JobFailed);143 Job.JobPaused += new EventHandler(Job_JobPaused);144 Job.JobStarted += new EventHandler(Job_JobStarted);139 job.JobStopped += new EventHandler(Job_JobStopped); 140 job.JobFailed += new EventHandler(Job_JobFailed); 141 job.JobPaused += new EventHandler(Job_JobPaused); 142 job.JobStarted += new EventHandler(Job_JobStarted); 145 143 } 146 144 147 145 private void DeregisterJobEvents() { 148 Job.JobStopped -= new EventHandler(Job_JobStopped);149 Job.JobFailed -= new EventHandler(Job_JobFailed);150 Job.JobPaused -= new EventHandler(Job_JobPaused);151 Job.JobStarted -= new EventHandler(Job_JobStarted);146 job.JobStopped -= new EventHandler(Job_JobStopped); 147 job.JobFailed -= new EventHandler(Job_JobFailed); 148 job.JobPaused -= new EventHandler(Job_JobPaused); 149 job.JobStarted -= new EventHandler(Job_JobStarted); 152 150 } 153 151 … … 182 180 183 181 public JobData GetJobData() { 184 if (Job.ExecutionState == ExecutionState.Started) { 182 if (jobDataInvalid) return null; 183 184 if (job.ExecutionState == ExecutionState.Started) { 185 185 throw new InvalidStateException("Job is still running"); 186 186 } else { 187 187 JobData jobData = new JobData(); 188 if ( Job == null) {188 if (job == null) { 189 189 //send empty job and save exception 190 190 jobData.Data = PersistenceUtil.Serialize(new JobData()); … … 193 193 } 194 194 } else { 195 jobData.Data = PersistenceUtil.Serialize( Job);195 jobData.Data = PersistenceUtil.Serialize(job); 196 196 } 197 197 jobData.JobId = JobId; … … 201 201 202 202 public void Dispose() { 203 if ( Job != null)203 if (job != null) 204 204 DeregisterJobEvents(); 205 Job = null;205 job = null; 206 206 } 207 207 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/WcfService.cs
r6381 r6419 105 105 service.UpdateJob(job); 106 106 job = service.UpdateJobState(job.Id, JobState.Transferring, slaveId, null, null); 107 service.UpdateJobData(job, jobData); 107 HiveClient.TryAndRepeat(() => { 108 service.UpdateJobData(job, jobData); 109 }, 3, "Could not upload jobdata."); 108 110 service.UpdateJobState(job.Id, state, slaveId, null, exception); 109 111 }); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/HeuristicLab.Clients.Hive.Views-3.4.csproj
r6381 r6419 149 149 <DependentUpon>HiveJobView.cs</DependentUpon> 150 150 </Compile> 151 <Compile Include="StateLog\StateLogListList.cs" />152 151 <Compile Include="TreeView\NewExperimentTreeNodeAction.cs" /> 153 152 <Compile Include="TreeView\DeleteJobTreeNodeAction.cs" /> … … 182 181 <DependentUpon>StateLogGanttChartView.cs</DependentUpon> 183 182 </Compile> 184 <Compile Include="StateLog\StateLogList.cs" />185 183 <Compile Include="StateLog\StateLogListView.cs"> 186 184 <SubType>UserControl</SubType> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/HiveJobs/HiveJobView.cs
r6373 r6419 21 21 22 22 using System; 23 using System.Linq;24 23 using System.Windows.Forms; 25 24 using HeuristicLab.Core.Views; … … 49 48 Content.JobChanged += new EventHandler(Content_JobChanged); 50 49 Content.JobStateChanged += new EventHandler(Content_JobStateChanged); 50 Content.StateLogChanged += new EventHandler(Content_StateLogChanged); 51 51 } 52 52 … … 55 55 Content.JobChanged -= new EventHandler(Content_JobChanged); 56 56 Content.JobStateChanged -= new EventHandler(Content_JobStateChanged); 57 Content.StateLogChanged -= new EventHandler(Content_StateLogChanged); 57 58 base.DeregisterContentEvents(); 58 59 } … … 129 130 this.exceptionTextBox.Text = Content.Job.CurrentStateLog != null ? Content.Job.CurrentStateLog.Exception : string.Empty; 130 131 this.lastUpdatedTextBox.Text = Content.Job.LastJobDataUpdate.ToString(); 131 if (Content.ItemJob.ComputeInParallel) {132 this.stateLogViewHost.Content = new StateLogListList(133 this.Content.ChildHiveJobs.Select(child => new StateLogList(child.Job.StateLog)134 ));135 } else {136 this.stateLogViewHost.Content = new StateLogList(Content.Job.StateLog);137 }138 132 } else { 139 133 this.stateTextBox.Text = string.Empty; … … 143 137 this.dateFinishedTextBox.Text = string.Empty; 144 138 this.exceptionTextBox.Text = string.Empty; 145 this.stateLogViewHost.Content = null;146 139 this.lastUpdatedTextBox.Text = string.Empty; 147 140 } 141 Content_StateLogChanged(this, EventArgs.Empty); 148 142 SetEnabledStateOfControls(); 149 143 } … … 155 149 } else { 156 150 computeInParallelCheckBox.Checked = Content.ItemJob.ComputeInParallel; 151 } 152 } 153 154 protected virtual void Content_StateLogChanged(object sender, EventArgs e) { 155 if (Content != null) { 156 if (Content.ItemJob.ComputeInParallel) { 157 this.stateLogViewHost.Content = Content.ChildStateLogList; 158 } else { 159 this.stateLogViewHost.Content = Content.StateLog; 160 } 161 } else { 162 this.stateLogViewHost.Content = null; 157 163 } 158 164 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj
r6373 r6419 115 115 <Compile Include="Jobs\ItemJob.cs" /> 116 116 <Compile Include="RefreshableHiveExperiment.cs" /> 117 <Compile Include="StateLogList.cs" /> 118 <Compile Include="StateLogListList.cs" /> 117 119 <Compile Include="ThreadSafeLog.cs" /> 118 120 <None Include="app_f005pc.config" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveClient.cs
r6407 r6419 297 297 hiveJob.Job.Id = service.AddJob(hiveJob.Job, jobData, groups.ToList()); 298 298 } 299 }, -1, "Failed to add job" );299 }, -1, "Failed to add job", log); 300 300 301 301 foreach (HiveJob child in hiveJob.ChildHiveJobs) { … … 391 391 /// If repetitions is -1, it is repeated infinitely. 392 392 /// </summary> 393 public static void TryAndRepeat(Action action, int repetitions, string errorMessage ) {393 public static void TryAndRepeat(Action action, int repetitions, string errorMessage, ILog log = null) { 394 394 while (true) { 395 395 try { action(); return; } 396 396 catch (Exception e) { 397 if (repetitions == 0) 398 throw new HiveException(errorMessage, e);397 if (repetitions == 0) throw new HiveException(errorMessage, e); 398 if (log != null) log.LogMessage(string.Format("{0}: {1} - will try again!", errorMessage, e.ToString())); 399 399 repetitions--; 400 400 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveJobs/EngineHiveJob.cs
r6381 r6419 71 71 return jobData; 72 72 } 73 74 public override void ClearData() { 75 base.ClearData(); 76 this.ItemJob.InitialOperation = null; 77 } 73 78 } 74 79 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveJobs/HiveJob.cs
r6381 r6419 123 123 protected bool syncJobsWithOptimizers = true; 124 124 125 public StateLogList StateLog { 126 get { return new StateLogList(this.job.StateLog); } 127 } 128 129 public StateLogListList ChildStateLogList { 130 get { return new StateLogListList(this.childHiveJobs.Select(x => x.StateLog)); } 131 } 132 125 133 #region Constructors and Cloning 126 134 public HiveJob() { … … 234 242 OnToStringChanged(); 235 243 OnItemImageChanged(); 244 OnStateLogChanged(); 236 245 } 237 246 } … … 255 264 } 256 265 257 #region Event s266 #region Event Handler 258 267 public event EventHandler JobChanged; 259 268 private void OnJobChanged() { … … 278 287 private void OnIsFinishedJobDownloadedChanged() { 279 288 var handler = IsFinishedJobDownloadedChanged; 289 if (handler != null) handler(this, EventArgs.Empty); 290 } 291 292 public event EventHandler StateLogChanged; 293 private void OnStateLogChanged() { 294 var handler = StateLogChanged; 280 295 if (handler != null) handler(this, EventArgs.Empty); 281 296 } … … 371 386 public event CollectionItemsChangedEventHandler<IItemTree<HiveJob>> CollectionReset; 372 387 private void OnCollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<HiveJob>> e) { 388 foreach (var item in e.Items) { 389 item.Value.StateLogChanged -= new EventHandler(ChildHiveJob_StateLogChanged); 390 } 373 391 var handler = CollectionReset; 374 392 if (handler != null) handler(this, ToCollectionItemsChangedEventArgs(e)); … … 377 395 public event CollectionItemsChangedEventHandler<IItemTree<HiveJob>> ItemsAdded; 378 396 private void OnItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<HiveJob>> e) { 397 foreach (var item in e.Items) { 398 item.Value.StateLogChanged += new EventHandler(ChildHiveJob_StateLogChanged); 399 } 379 400 var handler = ItemsAdded; 380 401 if (handler != null) handler(this, ToCollectionItemsChangedEventArgs(e)); … … 383 404 public event CollectionItemsChangedEventHandler<IItemTree<HiveJob>> ItemsRemoved; 384 405 private void OnItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<HiveJob>> e) { 406 foreach (var item in e.Items) { 407 item.Value.StateLogChanged -= new EventHandler(ChildHiveJob_StateLogChanged); 408 } 385 409 var handler = ItemsRemoved; 386 410 if (handler != null) handler(this, ToCollectionItemsChangedEventArgs(e)); … … 389 413 private static CollectionItemsChangedEventArgs<IItemTree<HiveJob>> ToCollectionItemsChangedEventArgs(CollectionItemsChangedEventArgs<IndexedItem<HiveJob>> e) { 390 414 return new CollectionItemsChangedEventArgs<IItemTree<HiveJob>>(e.Items.Select(x => x.Value), e.OldItems == null ? null : e.OldItems.Select(x => x.Value)); 415 } 416 417 private void ChildHiveJob_StateLogChanged(object sender, EventArgs e) { 418 OnStateLogChanged(); 391 419 } 392 420 #endregion … … 443 471 /// Delete ItemJob 444 472 /// </summary> 445 public v oid ClearData() {473 public virtual void ClearData() { 446 474 this.ItemJob.Item = null; 447 475 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Jobs/EngineJob.cs
r6200 r6419 1 1 using System; 2 using System.Collections.Generic;3 2 using System.Drawing; 4 3 using HeuristicLab.Common; 5 4 using HeuristicLab.Core; 6 using HeuristicLab.Hive;7 5 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 8 6 … … 65 63 public override void Stop() { 66 64 Item.Stop(); 67 }68 69 public override void Resume(IEnumerable<IJob> childJobs) {70 throw new NotImplementedException();71 65 } 72 66 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Jobs/ItemJob.cs
r6381 r6419 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Drawing; 25 24 using HeuristicLab.Common; … … 113 112 public abstract void Stop(); 114 113 115 public abstract void Resume(IEnumerable<IJob> childJobs);116 117 114 public event EventHandler JobStarted; 118 115 protected virtual void OnJobStarted() { … … 139 136 } 140 137 141 public event EventHandler<EventArgs<IJob>> NewChildJob;142 protected virtual void OnNewChildJob(IJob job) {143 EventHandler<EventArgs<IJob>> handler = NewChildJob;144 if (handler != null) handler(this, new EventArgs<IJob>(job));145 }146 147 public event EventHandler WaitForChildJobs;148 protected virtual void OnWaitForChildJobs() {149 EventHandler handler = WaitForChildJobs;150 if (handler != null) handler(this, EventArgs.Empty);151 }152 153 public event EventHandler DeleteChildJobs;154 protected virtual void OnDeleteChildJobs() {155 EventHandler handler = DeleteChildJobs;156 if (handler != null) handler(this, EventArgs.Empty);157 }158 159 138 public event EventHandler ComputeInParallelChanged; 160 139 protected virtual void OnComputeInParallelChanged() { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Jobs/OptimizerJob.cs
r6381 r6419 113 113 public override void Stop() { 114 114 Item.Stop(); 115 }116 117 public override void Resume(IEnumerable<IJob> childJobs) {118 OnJobStopped();119 115 } 120 116 #endregion -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/RefreshableHiveExperiment.cs
r6381 r6419 88 88 } 89 89 private static object logLocker = new object(); 90 91 90 92 91 #region Constructors and Cloning … … 220 219 UpdateTotalExecutionTime(); 221 220 UpdateStatistics(); 221 OnStateLogListChanged(); 222 222 } 223 223 … … 269 269 #endregion 270 270 271 #region HiveExperiment Events 271 272 private void RegisterHiveExperimentEvents() { 272 273 hiveExperiment.HiveJobsChanged += new EventHandler(hiveExperiment_HiveJobsChanged); … … 296 297 } 297 298 } 298 299 #region Events 299 #endregion 300 301 #region Event Handler 300 302 public event EventHandler RefreshAutomaticallyChanged; 301 303 private void OnRefreshAutomaticallyChanged() { … … 358 360 if (handler != null) handler(this, new EventArgs<Exception>(exception)); 359 361 } 362 363 public event EventHandler StateLogListChanged; 364 private void OnStateLogListChanged() { 365 var handler = StateLogListChanged; 366 if (handler != null) handler(this, EventArgs.Empty); 367 } 360 368 #endregion 361 369 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveExperiment.cs
r6381 r6419 24 24 using System.ComponentModel; 25 25 using System.Linq; 26 using HeuristicLab.Collections; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; … … 68 69 set { 69 70 if (hiveJobs != value) { 71 if (hiveJobs != null) DeregisterHiveJobsEvents(); 70 72 hiveJobs = value; 73 if (hiveJobs != null) RegisterHiveJobsEvents(); 71 74 OnHiveJobsChanged(); 72 75 } … … 89 92 get { return progress; } 90 93 set { this.progress = value; } 94 } 95 96 public StateLogListList StateLogList { 97 get { return new StateLogListList(this.GetAllHiveJobs().Select(x => x.StateLog)); } 91 98 } 92 99 … … 147 154 if (handler != null) handler(this, EventArgs.Empty); 148 155 } 156 157 public event EventHandler<CollectionItemsChangedEventArgs<HiveJob>> HiveJobsAdded; 158 private void OnHiveJobsAdded(CollectionItemsChangedEventArgs<HiveJob> e) { 159 var handler = HiveJobsAdded; 160 if (handler != null) handler(this, e); 161 } 162 163 public event EventHandler<CollectionItemsChangedEventArgs<HiveJob>> HiveJobsRemoved; 164 private void OnHiveJobsRemoved(CollectionItemsChangedEventArgs<HiveJob> e) { 165 var handler = HiveJobsRemoved; 166 if (handler != null) handler(this, e); 167 } 168 169 public event EventHandler<CollectionItemsChangedEventArgs<HiveJob>> HiveJobsReset; 170 private void OnHiveJobsReset(CollectionItemsChangedEventArgs<HiveJob> e) { 171 var handler = HiveJobsReset; 172 if (handler != null) handler(this, e); 173 } 174 175 public event EventHandler StateLogListChanged; 176 private void OnStateLogListChanged() { 177 var handler = StateLogListChanged; 178 if (handler != null) handler(this, EventArgs.Empty); 179 } 180 #endregion 181 182 #region HiveJobs Events 183 private void RegisterHiveJobsEvents() { 184 this.hiveJobs.ItemsAdded += new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsAdded); 185 this.hiveJobs.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsRemoved); 186 this.hiveJobs.CollectionReset += new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_CollectionReset); 187 } 188 189 private void DeregisterHiveJobsEvents() { 190 this.hiveJobs.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsAdded); 191 this.hiveJobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsRemoved); 192 this.hiveJobs.CollectionReset -= new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_CollectionReset); 193 } 194 195 private void hiveJobs_CollectionReset(object sender, CollectionItemsChangedEventArgs<HiveJob> e) { 196 foreach (var item in e.Items) { 197 item.StateLogChanged -= new EventHandler(item_StateLogChanged); 198 } 199 OnHiveJobsReset(e); 200 } 201 202 private void hiveJobs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<HiveJob> e) { 203 foreach (var item in e.Items) { 204 item.StateLogChanged -= new EventHandler(item_StateLogChanged); 205 } 206 OnHiveJobsRemoved(e); 207 } 208 209 private void hiveJobs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<HiveJob> e) { 210 foreach (var item in e.Items) { 211 item.StateLogChanged += new EventHandler(item_StateLogChanged); 212 } 213 OnHiveJobsAdded(e); 214 } 215 216 private void item_StateLogChanged(object sender, EventArgs e) { 217 OnStateLogListChanged(); 218 } 149 219 #endregion 150 220 … … 171 241 172 242 public IEnumerable<HiveJob> GetAllHiveJobs() { 243 if (hiveJobs == null) return Enumerable.Empty<HiveJob>(); 244 173 245 var jobs = new List<HiveJob>(); 174 246 foreach (HiveJob job in HiveJobs) { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Views/3.4/HiveEngineView.Designer.cs
r6381 r6419 64 64 this.resourceIdsTextBox.TabIndex = 4; 65 65 this.resourceIdsTextBox.Text = "HEAL"; 66 this.resourceIdsTextBox. TextChanged += new System.EventHandler(this.resourceIdsTextBox_TextChanged);66 this.resourceIdsTextBox.Validated += new System.EventHandler(this.resourceIdsTextBox_Validated); 67 67 // 68 68 // priorityLabel … … 82 82 this.priorityTextBox.TabIndex = 6; 83 83 this.priorityTextBox.Text = "0"; 84 this.priorityTextBox. TextChanged += new System.EventHandler(this.priorityTextBox_TextChanged);84 this.priorityTextBox.Validated += new System.EventHandler(this.priorityTextBox_Validated); 85 85 // 86 86 // label1 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Views/3.4/HiveEngineView.cs
r6381 r6419 105 105 106 106 #region Event Handlers (child controls) 107 private void resourceIdsTextBox_ TextChanged(object sender, EventArgs e) {107 private void resourceIdsTextBox_Validated(object sender, EventArgs e) { 108 108 Content.ResourceNames = resourceIdsTextBox.Text; 109 109 } 110 110 111 private void priorityTextBox_ TextChanged(object sender, EventArgs e) {111 private void priorityTextBox_Validated(object sender, EventArgs e) { 112 112 Content.Priority = int.Parse(priorityTextBox.Text); 113 113 } … … 121 121 } 122 122 #endregion 123 124 123 125 } 124 126 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs
r6381 r6419 196 196 //} else if (coll.Parallel) { 197 197 if (coll.Parallel) { 198 // clone the parent scope here and reuse it for each operation. otherwise for each job the whole scope-tree first needs to be copied and then cleaned, which causes a lot of work for the Garbage Collector 199 IScope parentScopeClone = (IScope)((IAtomicOperation)coll.First()).Scope.Parent.Clone(); 200 parentScopeClone.SubScopes.Clear(); 201 parentScopeClone.ClearParentScopes(); 202 203 EngineJob[] jobs = new EngineJob[coll.Count]; 204 for (int i = 0; i < coll.Count; i++) { 205 jobs[i] = new EngineJob(coll[i], new SequentialEngine.SequentialEngine()); 198 try { 199 // clone the parent scope here and reuse it for each operation. otherwise for each job the whole scope-tree first needs to be copied and then cleaned, which causes a lot of work for the Garbage Collector 200 IScope parentScopeClone = (IScope)((IAtomicOperation)coll.First()).Scope.Parent.Clone(); 201 parentScopeClone.SubScopes.Clear(); 202 parentScopeClone.ClearParentScopes(); 203 204 EngineJob[] jobs = new EngineJob[coll.Count]; 205 for (int i = 0; i < coll.Count; i++) { 206 jobs[i] = new EngineJob(coll[i], new SequentialEngine.SequentialEngine()); 207 } 208 209 var experiment = CreateHiveExperiment(); 210 IScope[] scopes = ExecuteOnHive(experiment, jobs, parentScopeClone, cancellationToken); 211 212 for (int i = 0; i < coll.Count; i++) { 213 if (coll[i] is IAtomicOperation) { 214 ExchangeScope(scopes[i], ((IAtomicOperation)coll[i]).Scope); 215 } else if (coll[i] is OperationCollection) { 216 // todo ?? 217 } 218 } 206 219 } 207 208 var experiment = CreateHiveExperiment(); 209 IScope[] scopes = ExecuteOnHive(experiment, jobs, parentScopeClone, cancellationToken); 210 DisposeHiveExperiment(experiment); 211 212 for (int i = 0; i < coll.Count; i++) { 213 if (coll[i] is IAtomicOperation) { 214 ExchangeScope(scopes[i], ((IAtomicOperation)coll[i]).Scope); 215 } else if (coll[i] is OperationCollection) { 216 // todo ?? 217 } 220 catch { 221 executionStack.Push(coll); throw; 218 222 } 219 223 } else { … … 305 309 306 310 var failedJobs = hiveExperiment.HiveJobs.Where(x => x.Job.State == JobState.Failed); 307 if (failedJobs.Count() > 0) {311 if (failedJobs.Count() > 0) { 308 312 throw new HiveEngineException("Job failed: " + failedJobs.First().Job.StateLog.Last().Exception); 309 313 } … … 318 322 } 319 323 catch (OperationCanceledException e) { 320 lock (locker) {321 DeleteHiveExperiment(hiveExperiment.Id);322 }323 324 throw e; 324 325 } 325 326 catch (Exception e) { 326 lock (locker) {327 DeleteHiveExperiment(hiveExperiment.Id);328 }329 327 LogException(e); 330 328 throw e; 329 } 330 finally { 331 DisposeHiveExperiment(refreshableHiveExperiment); 331 332 } 332 333 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/ApplicationConstants.cs
r6372 r6419 26 26 public static TimeSpan SlaveHeartbeatTimeout = TimeSpan.FromMinutes(1); 27 27 28 public static TimeSpan CalculatingJobHeartbeatTimeout = TimeSpan.FromMinutes( 1);28 public static TimeSpan CalculatingJobHeartbeatTimeout = TimeSpan.FromMinutes(5.5); 29 29 30 public static TimeSpan TransferringJobHeartbeatTimeout = TimeSpan.FromMinutes(5); 30 public static TimeSpan TransferringJobHeartbeatTimeout = TimeSpan.FromMinutes(5.5); 31 32 /// <summary> 33 /// Timeout for long running database command (storing or loading jobData) 34 /// </summary> 35 public static TimeSpan LongRunningDatabaseCommandTimeout = TimeSpan.FromMinutes(5); 31 36 32 37 /// <summary> 33 38 /// Interval in which the HL.HiveExperiment will poll results from server 34 39 /// </summary> 35 public static TimeSpan ResultPollingInterval = TimeSpan.FromSeconds(5); 36 37 /// <summary> 38 /// Maximum number of jobs that the server should send/receive simultaniously 39 /// </summary> 40 public static int MaxJobTransferCount = 6; 40 public static TimeSpan ResultPollingInterval = TimeSpan.FromSeconds(10); 41 41 } 42 42 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs
r6369 r6419 24 24 using System.Linq; 25 25 using System.Linq.Expressions; 26 using HeuristicLab.Services.Hive.Common; 27 using HeuristicLab.Services.Hive.Common.DataTransfer; 28 using HeuristicLab.Services.Hive.DataAccess.Properties; 29 using DT = HeuristicLab.Services.Hive.Common.DataTransfer; 26 30 27 31 namespace HeuristicLab.Services.Hive.DataAccess { 28 using HeuristicLab.Services.Hive.Common.DataTransfer;29 using HeuristicLab.Services.Hive.DataAccess.Properties;30 using DT = HeuristicLab.Services.Hive.Common.DataTransfer;31 32 32 public class HiveDao : IHiveDao { 33 public static HiveDataContext CreateContext() { 34 return new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString); 33 public static HiveDataContext CreateContext(bool longRunning = false) { 34 var context = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString); 35 if (longRunning) context.CommandTimeout = (int)ApplicationConstants.LongRunningDatabaseCommandTimeout.TotalSeconds; 36 return context; 35 37 } 36 38 … … 71 73 if (db.RequiredPlugins.Count(p => p.PluginId == pluginId) == 0) { 72 74 db.RequiredPlugins.InsertOnSubmit(new RequiredPlugin() { JobId = entity.JobId, PluginId = pluginId }); 73 } 75 } 74 76 } 75 77 db.SubmitChanges(); … … 153 155 #region JobData Methods 154 156 public DT.JobData GetJobData(Guid id) { 155 using (var db = CreateContext( )) {157 using (var db = CreateContext(true)) { 156 158 return Convert.ToDto(db.JobDatas.SingleOrDefault(x => x.JobId == id)); 157 159 } … … 159 161 160 162 public IEnumerable<DT.JobData> GetJobDatas(Expression<Func<JobData, bool>> predicate) { 161 using (var db = CreateContext( )) {163 using (var db = CreateContext(true)) { 162 164 return db.JobDatas.Where(predicate).Select(x => Convert.ToDto(x)).ToArray(); 163 165 } … … 165 167 166 168 public Guid AddJobData(DT.JobData dto) { 167 using (var db = CreateContext( )) {169 using (var db = CreateContext(true)) { 168 170 var entity = Convert.ToEntity(dto); 169 171 db.JobDatas.InsertOnSubmit(entity); … … 174 176 175 177 public void UpdateJobData(DT.JobData dto) { 176 using (var db = CreateContext( )) {178 using (var db = CreateContext(true)) { 177 179 var entity = db.JobDatas.FirstOrDefault(x => x.JobId == dto.JobId); 178 180 if (entity == null) db.JobDatas.InsertOnSubmit(Convert.ToEntity(dto)); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Tools/prepareHiveDatabase.sql
r6267 r6419 25 25 26 26 ALTER TABLE dbo.AssignedResources ALTER COLUMN AssignedRessourcesId ADD ROWGUIDCOL; 27 ALTER TABLE dbo.AssignedResources WITH NOCHECK ADD CONSTRAINT [DF_AssignedResources_AssignedRessourcesId] DEFAULT ( newid()) FOR AssignedRessourcesId;27 ALTER TABLE dbo.AssignedResources WITH NOCHECK ADD CONSTRAINT [DF_AssignedResources_AssignedRessourcesId] DEFAULT (NEWSEQUENTIALID()) FOR AssignedRessourcesId; 28 28 ALTER TABLE [dbo].[AssignedResources] DROP CONSTRAINT [Job_AssignedResource] 29 29 ALTER TABLE [dbo].[AssignedResources] WITH CHECK ADD CONSTRAINT [Job_AssignedResource] FOREIGN KEY([JobId]) … … 40 40 41 41 ALTER TABLE dbo.Job ALTER COLUMN JobId ADD ROWGUIDCOL; 42 ALTER TABLE dbo.Job WITH NOCHECK ADD CONSTRAINT [DF_Job_JobId] DEFAULT ( newid()) FOR JobId;42 ALTER TABLE dbo.Job WITH NOCHECK ADD CONSTRAINT [DF_Job_JobId] DEFAULT (NEWSEQUENTIALID()) FOR JobId; 43 43 GO 44 44 … … 57 57 58 58 ALTER TABLE dbo.Plugin ALTER COLUMN PluginId ADD ROWGUIDCOL; 59 ALTER TABLE dbo.Plugin WITH NOCHECK ADD CONSTRAINT [DF_Plugin_PluginId] DEFAULT ( newid()) FOR PluginId;59 ALTER TABLE dbo.Plugin WITH NOCHECK ADD CONSTRAINT [DF_Plugin_PluginId] DEFAULT (NEWSEQUENTIALID()) FOR PluginId; 60 60 61 61 ALTER TABLE dbo.PluginData ALTER COLUMN PluginDataId ADD ROWGUIDCOL; 62 ALTER TABLE dbo.PluginData WITH NOCHECK ADD CONSTRAINT [DF_PluginData_PluginDataId] DEFAULT ( newid()) FOR PluginDataId;62 ALTER TABLE dbo.PluginData WITH NOCHECK ADD CONSTRAINT [DF_PluginData_PluginDataId] DEFAULT (NEWSEQUENTIALID()) FOR PluginDataId; 63 63 64 64 ALTER TABLE [dbo].[PluginData] DROP CONSTRAINT [Plugin_PluginData] … … 70 70 71 71 ALTER TABLE dbo.RequiredPlugins ALTER COLUMN RequiredPluginId ADD ROWGUIDCOL; 72 ALTER TABLE dbo.RequiredPlugins WITH NOCHECK ADD CONSTRAINT [DF_RequiredPlugins_RequiredPluginId] DEFAULT ( newid()) FOR RequiredPluginId;72 ALTER TABLE dbo.RequiredPlugins WITH NOCHECK ADD CONSTRAINT [DF_RequiredPlugins_RequiredPluginId] DEFAULT (NEWSEQUENTIALID()) FOR RequiredPluginId; 73 73 74 74 ALTER TABLE [dbo].[RequiredPlugins] DROP CONSTRAINT [Job_RequiredPlugin] … … 87 87 88 88 ALTER TABLE dbo.Resource ALTER COLUMN ResourceId ADD ROWGUIDCOL; 89 ALTER TABLE dbo.Resource WITH NOCHECK ADD CONSTRAINT [DF_Resource_ResourceId] DEFAULT ( newid()) FOR ResourceId;89 ALTER TABLE dbo.Resource WITH NOCHECK ADD CONSTRAINT [DF_Resource_ResourceId] DEFAULT (NEWSEQUENTIALID()) FOR ResourceId; 90 90 91 91 ALTER TABLE dbo.UptimeCalendar ALTER COLUMN UptimeCalendarId ADD ROWGUIDCOL; 92 ALTER TABLE dbo.UptimeCalendar WITH NOCHECK ADD CONSTRAINT [DF_UptimeCalendar_UptimeCalendarId] DEFAULT ( newid()) FOR UptimeCalendarId;92 ALTER TABLE dbo.UptimeCalendar WITH NOCHECK ADD CONSTRAINT [DF_UptimeCalendar_UptimeCalendarId] DEFAULT (NEWSEQUENTIALID()) FOR UptimeCalendarId; 93 93 94 94 ALTER TABLE dbo.HiveExperiment ALTER COLUMN HiveExperimentId ADD ROWGUIDCOL; 95 ALTER TABLE dbo.HiveExperiment WITH NOCHECK ADD CONSTRAINT [DF_HiveExperiment_HiveExperimentId] DEFAULT ( newid()) FOR HiveExperimentId;95 ALTER TABLE dbo.HiveExperiment WITH NOCHECK ADD CONSTRAINT [DF_HiveExperiment_HiveExperimentId] DEFAULT (NEWSEQUENTIALID()) FOR HiveExperimentId; 96 96 97 97 ALTER TABLE dbo.StateLog ALTER COLUMN StateLogId ADD ROWGUIDCOL; 98 ALTER TABLE dbo.StateLog WITH NOCHECK ADD CONSTRAINT [DF_StateLog_StateLogId] DEFAULT ( newid()) FOR StateLogId;98 ALTER TABLE dbo.StateLog WITH NOCHECK ADD CONSTRAINT [DF_StateLog_StateLogId] DEFAULT (NEWSEQUENTIALID()) FOR StateLogId; 99 99 100 100 ALTER TABLE [dbo].[HiveExperimentPermission] DROP CONSTRAINT [HiveExperiment_HiveExperimentPermission] … … 106 106 107 107 ALTER TABLE [dbo].[Statistics] ALTER COLUMN StatisticsId ADD ROWGUIDCOL; 108 ALTER TABLE [dbo].[Statistics] WITH NOCHECK ADD CONSTRAINT [DF_Statistics_StatisticsId] DEFAULT ( newid()) FOR StatisticsId;108 ALTER TABLE [dbo].[Statistics] WITH NOCHECK ADD CONSTRAINT [DF_Statistics_StatisticsId] DEFAULT (NEWSEQUENTIALID()) FOR StatisticsId; 109 109 GO 110 110 111 111 ALTER TABLE [dbo].[DeletedJobStatistics] ALTER COLUMN DeletedJobStatisticsId ADD ROWGUIDCOL; 112 ALTER TABLE [dbo].[DeletedJobStatistics] WITH NOCHECK ADD CONSTRAINT [DF_DeletedJobStatistics_DeletedJobStatisticsId] DEFAULT ( newid()) FOR DeletedJobStatisticsId;112 ALTER TABLE [dbo].[DeletedJobStatistics] WITH NOCHECK ADD CONSTRAINT [DF_DeletedJobStatistics_DeletedJobStatisticsId] DEFAULT (NEWSEQUENTIALID()) FOR DeletedJobStatisticsId; 113 113 GO 114 114 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/TransactionManager.cs
r6367 r6419 22 22 using System; 23 23 using System.Transactions; 24 using HeuristicLab.Services.Hive.Common; 24 25 25 26 namespace HeuristicLab.Services.Hive.DataAccess { 26 27 public class TransactionManager { 27 public void UseTransaction(Action call, bool serializable = false ) {28 TransactionScope transaction = serializable ? CreateSerializableTransaction() : CreateTransaction();28 public void UseTransaction(Action call, bool serializable = false, bool longRunning = false) { 29 TransactionScope transaction = CreateTransaction(serializable, longRunning); 29 30 try { 30 31 call(); … … 36 37 } 37 38 38 public T UseTransaction<T>(Func<T> call, bool serializable = false ) {39 TransactionScope transaction = serializable ? CreateSerializableTransaction() : CreateTransaction();39 public T UseTransaction<T>(Func<T> call, bool serializable = false, bool longRunning = false) { 40 TransactionScope transaction = CreateTransaction(serializable, longRunning); 40 41 try { 41 42 T result = call(); … … 47 48 } 48 49 } 50 51 private static TransactionScope CreateTransaction(bool serializable, bool longRunning) { 52 var options = new TransactionOptions(); 53 if (serializable) 54 options.IsolationLevel = IsolationLevel.Serializable; 55 else 56 options.IsolationLevel = IsolationLevel.ReadUncommitted; 49 57 50 private static TransactionScope CreateTransaction() { 51 return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted }); 52 } 53 private static TransactionScope CreateSerializableTransaction() { 54 return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.Serializable }); 58 if (longRunning) 59 options.Timeout = ApplicationConstants.LongRunningDatabaseCommandTimeout; 60 61 return new TransactionScope(TransactionScopeOption.Required, options); 55 62 } 56 63 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs
r6407 r6419 47 47 dao.UpdateJobState(job.Id, JobState.Waiting, null, author.UserId, null); 48 48 return jobData.JobId; 49 } );49 }, false, true); 50 50 } 51 51 … … 55 55 job.ParentJobId = parentJobId; 56 56 return AddJob(job, jobData, dao.GetAssignedResources(parentJobId).Select(x => x.Id)); 57 } );57 }, false, true); 58 58 } 59 59 … … 97 97 public void UpdateJobData(Job job, JobData jobData) { 98 98 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 99 trans.UseTransaction(() => {99 //trans.UseTransaction(() => { // cneumuel: try without transaction 100 100 jobData.LastUpdate = DateTime.Now; 101 101 dao.UpdateJob(job); 102 102 dao.UpdateJobData(jobData); 103 });103 //}, false, true); 104 104 } 105 105
Note: See TracChangeset
for help on using the changeset viewer.