Changeset 5394 for branches/HeuristicLab.Hive-3.3/sources
- Timestamp:
- 01/29/11 13:29:21 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HiveEngine.cs
r5358 r5394 39 39 set { priority = value; } 40 40 } 41 42 [Storable] 43 private TimeSpan executionTimeOnHive; 44 public TimeSpan ExecutionTimeOnHive { 45 get { return executionTimeOnHive; } 46 set { 47 if (value != executionTimeOnHive) { 48 executionTimeOnHive = value; 49 OnExecutionTimeOnHiveChanged(); 50 } 51 } 52 } 41 53 42 54 #region constructors and cloning … … 44 56 ResourceIds = "HEAL"; 45 57 } 58 46 59 [StorableConstructor] 47 60 protected HiveEngine(bool deserializing) : base(deserializing) { } … … 51 64 this.currentOperator = cloner.Clone(original.currentOperator); 52 65 this.priority = original.priority; 66 this.executionTimeOnHive = original.executionTimeOnHive; 53 67 } 54 68 public override IDeepCloneable Clone(Cloner cloner) { 55 69 return new HiveEngine(this, cloner); 70 } 71 #endregion 72 73 #region Events 74 protected override void OnPrepared() { 75 base.OnPrepared(); 76 this.ExecutionTimeOnHive = TimeSpan.Zero; 77 } 78 79 public event EventHandler ExecutionTimeOnHiveChanged; 80 protected virtual void OnExecutionTimeOnHiveChanged() { 81 var handler = ExecutionTimeOnHiveChanged; 82 if (handler != null) handler(this, EventArgs.Empty); 56 83 } 57 84 #endregion … … 158 185 IScope[] scopes = new Scope[jobs.Length]; 159 186 object locker = new object(); 187 IDictionary<Guid, int> jobIndices = new Dictionary<Guid, int>(); 160 188 161 189 try { 162 IDictionary<Guid, int> jobIndices = new Dictionary<Guid, int>();163 190 List<Guid> remainingJobIds = new List<Guid>(); 164 191 JobResultList results; … … 203 230 } 204 231 jobs[key] = null; // relax memory 205 LogMessage(string.Format(" Submitted job #{0}", key + 1, jobDto.Id));232 LogMessage(string.Format("Uploaded job #{0}", key + 1, jobDto.Id)); 206 233 uploadTasks.Remove(task); 207 234 } … … 212 239 var downloadTasks = new List<Task<OperationJob>>(); 213 240 var executionTimes = new List<TimeSpan>(); 241 var executionTimeOnHiveBefore = executionTimeOnHive; 214 242 while (processUploadedJobsTask.Status != TaskStatus.RanToCompletion || remainingJobIds.Count > 0) { 215 243 cancellationToken.ThrowIfCancellationRequested(); … … 222 250 var jobsFinished = results.Where(j => j.State == JobState.Finished || j.State == JobState.Failed || j.State == JobState.Aborted); 223 251 finishedCount += jobsFinished.Count(); 224 var totalExecutionTime = TimeSpan.FromMilliseconds(results.Select(j => j.ExecutionTime).Union(executionTimes).Select(e => e.TotalMilliseconds).Sum()); 225 LogMessage(string.Format("Results polled. Jobs finished: {0}/{1}, TotalExecutionTime: {2}", finishedCount, jobs.Length, totalExecutionTime)); 252 if (jobsFinished.Count() > 0) LogMessage(string.Format("Finished: {0}/{1}", finishedCount, jobs.Length)); 253 ExecutionTimeOnHive = executionTimeOnHiveBefore + executionTimes.Sum() + results.Select(x => x.ExecutionTime).Sum(); 254 226 255 foreach (var result in jobsFinished) { 227 256 if (result.State == JobState.Finished) { … … 232 261 LogMessage(string.Format("Job #{0} aborted (id: {1})", jobIndices[result.Id] + 1, result.Id)); 233 262 } else if (result.State == JobState.Failed) { 234 LogMessage(string.Format("Job {0} failed (id: {1}): {2}", jobIndices[result.Id] + 1, result.Id, result.Exception));263 LogMessage(string.Format("Job #{0} failed (id: {1}): {2}", jobIndices[result.Id] + 1, result.Id, result.Exception)); 235 264 } 236 265 remainingJobIds.Remove(result.Id); … … 259 288 } 260 289 261 LogMessage(string.Format("All jobs finished (TotalExecutionTime: {0}). Deleting jobs on hive.", TimeSpan.FromMilliseconds(executionTimes.Select(e => e.TotalMilliseconds).Sum()))); 262 // delete jobs 290 LogMessage(string.Format("All jobs finished (TotalExecutionTime: {0}).", executionTimes.Sum())); 291 DeleteJobs(jobIndices); 292 293 return scopes; 294 } 295 catch (OperationCanceledException e) { 296 lock (locker) { 297 if (jobIndices != null) DeleteJobs(jobIndices); 298 } 299 throw e; 300 } 301 catch (Exception e) { 302 lock (locker) { 303 if (jobIndices != null) DeleteJobs(jobIndices); 304 } 305 LogException(e); 306 throw e; 307 } 308 } 309 310 private void DeleteJobs(IDictionary<Guid, int> jobIndices) { 311 if (jobIndices.Count > 0) { 263 312 using (Disposable<IClientFacade> service = ServiceLocator.Instance.ClientFacadePool.GetService()) { 264 313 foreach (Guid jobId in jobIndices.Keys) { 265 314 service.Obj.DeleteJob(jobId); 266 315 } 267 } 268 269 LogMessage(string.Format("Operations on the hive finished.", jobs.Length)); 270 return scopes; 271 } 272 catch (Exception e) { 273 LogException(e); 274 throw e; 316 LogMessage(string.Format("Deleted {0} jobs on hive.", jobIndices.Count)); 317 jobIndices.Clear(); 318 } 275 319 } 276 320 } … … 395 439 } 396 440 } 441 442 public static class EnumerableExtensions { 443 public static TimeSpan Sum(this IEnumerable<TimeSpan> times) { 444 return TimeSpan.FromMilliseconds(times.Select(e => e.TotalMilliseconds).Sum()); 445 } 446 } 397 447 } -
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/Views/HiveEngineView.Designer.cs
r5282 r5394 28 28 this.priorityLabel = new System.Windows.Forms.Label(); 29 29 this.priorityTextBox = new System.Windows.Forms.TextBox(); 30 this.label1 = new System.Windows.Forms.Label(); 31 this.executionTimeOnHiveTextBox = new System.Windows.Forms.TextBox(); 30 32 this.SuspendLayout(); 33 // 34 // executionTimeTextBox 35 // 36 this.executionTimeTextBox.Size = new System.Drawing.Size(623, 20); 31 37 // 32 38 // logView 33 39 // 34 this.logView.Location = new System.Drawing.Point(0, 81);35 this.logView.Size = new System.Drawing.Size( 430, 270);40 this.logView.Location = new System.Drawing.Point(0, 78); 41 this.logView.Size = new System.Drawing.Size(715, 469); 36 42 // 37 43 // resourceIdsLabel 38 44 // 39 45 this.resourceIdsLabel.AutoSize = true; 40 this.resourceIdsLabel.Location = new System.Drawing.Point( 3, 26);46 this.resourceIdsLabel.Location = new System.Drawing.Point(113, 55); 41 47 this.resourceIdsLabel.Name = "resourceIdsLabel"; 42 48 this.resourceIdsLabel.Size = new System.Drawing.Size(70, 13); … … 46 52 // resourceIdsTextBox 47 53 // 48 this.resourceIdsTextBox.Location = new System.Drawing.Point(73, 23); 54 this.resourceIdsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 55 | System.Windows.Forms.AnchorStyles.Left) 56 | System.Windows.Forms.AnchorStyles.Right))); 57 this.resourceIdsTextBox.Location = new System.Drawing.Point(189, 52); 49 58 this.resourceIdsTextBox.Name = "resourceIdsTextBox"; 50 this.resourceIdsTextBox.Size = new System.Drawing.Size( 357, 20);59 this.resourceIdsTextBox.Size = new System.Drawing.Size(526, 20); 51 60 this.resourceIdsTextBox.TabIndex = 4; 52 61 this.resourceIdsTextBox.Text = "HEAL"; … … 56 65 // 57 66 this.priorityLabel.AutoSize = true; 58 this.priorityLabel.Location = new System.Drawing.Point(3, 49);67 this.priorityLabel.Location = new System.Drawing.Point(3, 55); 59 68 this.priorityLabel.Name = "priorityLabel"; 60 69 this.priorityLabel.Size = new System.Drawing.Size(41, 13); … … 64 73 // priorityTextBox 65 74 // 66 this.priorityTextBox.Location = new System.Drawing.Point( 73, 46);75 this.priorityTextBox.Location = new System.Drawing.Point(50, 52); 67 76 this.priorityTextBox.Name = "priorityTextBox"; 68 this.priorityTextBox.Size = new System.Drawing.Size( 357, 20);77 this.priorityTextBox.Size = new System.Drawing.Size(57, 20); 69 78 this.priorityTextBox.TabIndex = 6; 79 this.priorityTextBox.Text = "0"; 70 80 this.priorityTextBox.TextChanged += new System.EventHandler(this.priorityTextBox_TextChanged); 81 // 82 // label1 83 // 84 this.label1.AutoSize = true; 85 this.label1.Location = new System.Drawing.Point(3, 29); 86 this.label1.Name = "label1"; 87 this.label1.Size = new System.Drawing.Size(123, 13); 88 this.label1.TabIndex = 7; 89 this.label1.Text = "Execution Time on Hive:"; 90 // 91 // executionTimeOnHiveTextBox 92 // 93 this.executionTimeOnHiveTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 94 | System.Windows.Forms.AnchorStyles.Left) 95 | System.Windows.Forms.AnchorStyles.Right))); 96 this.executionTimeOnHiveTextBox.Location = new System.Drawing.Point(129, 26); 97 this.executionTimeOnHiveTextBox.Name = "executionTimeOnHiveTextBox"; 98 this.executionTimeOnHiveTextBox.ReadOnly = true; 99 this.executionTimeOnHiveTextBox.Size = new System.Drawing.Size(586, 20); 100 this.executionTimeOnHiveTextBox.TabIndex = 8; 71 101 // 72 102 // HiveEngineView … … 74 104 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 75 105 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 106 this.Controls.Add(this.label1); 107 this.Controls.Add(this.executionTimeOnHiveTextBox); 108 this.Controls.Add(this.priorityTextBox); 109 this.Controls.Add(this.priorityLabel); 110 this.Controls.Add(this.resourceIdsLabel); 76 111 this.Controls.Add(this.resourceIdsTextBox); 77 this.Controls.Add(this.priorityTextBox);78 this.Controls.Add(this.resourceIdsLabel);79 this.Controls.Add(this.priorityLabel);80 112 this.Name = "HiveEngineView"; 113 this.Size = new System.Drawing.Size(715, 550); 114 this.Controls.SetChildIndex(this.resourceIdsTextBox, 0); 115 this.Controls.SetChildIndex(this.resourceIdsLabel, 0); 81 116 this.Controls.SetChildIndex(this.priorityLabel, 0); 82 this.Controls.SetChildIndex(this.resourceIdsLabel, 0);83 117 this.Controls.SetChildIndex(this.priorityTextBox, 0); 84 this.Controls.SetChildIndex(this.resourceIdsTextBox, 0);85 118 this.Controls.SetChildIndex(this.logView, 0); 86 119 this.Controls.SetChildIndex(this.executionTimeLabel, 0); 87 120 this.Controls.SetChildIndex(this.executionTimeTextBox, 0); 121 this.Controls.SetChildIndex(this.executionTimeOnHiveTextBox, 0); 122 this.Controls.SetChildIndex(this.label1, 0); 88 123 this.ResumeLayout(false); 89 124 this.PerformLayout(); … … 97 132 private System.Windows.Forms.Label priorityLabel; 98 133 private System.Windows.Forms.TextBox priorityTextBox; 134 private System.Windows.Forms.Label label1; 135 protected System.Windows.Forms.TextBox executionTimeOnHiveTextBox; 99 136 } 100 137 } -
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/Views/HiveEngineView.cs
r5282 r5394 24 24 25 25 protected override void DeregisterContentEvents() { 26 Content.ExecutionTimeOnHiveChanged -= new EventHandler(Content_ExecutionTimeOnHiveChanged); 26 27 base.DeregisterContentEvents(); 27 28 } … … 29 30 protected override void RegisterContentEvents() { 30 31 base.RegisterContentEvents(); 32 Content.ExecutionTimeOnHiveChanged += new EventHandler(Content_ExecutionTimeOnHiveChanged); 31 33 } 32 34 33 35 #region Event Handlers (Content) 34 // Put event handlers of the content here 36 private void Content_ExecutionTimeOnHiveChanged(object sender, EventArgs e) { 37 if (InvokeRequired) { 38 Invoke(new EventHandler(Content_ExecutionTimeOnHiveChanged), sender, e); 39 } else { 40 executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString(); 41 } 42 } 35 43 #endregion 36 44 … … 40 48 resourceIdsTextBox.Text = string.Empty; 41 49 priorityTextBox.Text = string.Empty; 50 executionTimeOnHiveTextBox.Text = string.Empty; 42 51 } else { 43 52 resourceIdsTextBox.Text = Content.ResourceIds; 44 53 priorityTextBox.Text = Content.Priority.ToString(); 54 executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString(); 45 55 } 46 56 } 47 48 57 49 58 protected override void SetEnabledStateOfControls() {
Note: See TracChangeset
for help on using the changeset viewer.