Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/HiveJobView.cs @ 6362

Last change on this file since 6362 was 6267, checked in by cneumuel, 14 years ago

#1233

  • extended statistics recording:
    • execution times of users are captured
    • execution times and start-to-finish time of finished jobs is captured (to computer hive overhead)
    • data of deleted jobs is automatically captured in DeletedJobStatistics
  • changed ExecutionTime type in database from string to float (milliseconds are stored instead of TimeSpan.ToString())
  • added IsPrivileged field to job to indicate if it should be executed in a privileged sandbox
  • added CpuUtilization field to slave to be able to report cpu utilization
  • added GetJobsByResourceId to retrieve all jobs which are currently beeing calculated in a slave(-group)
  • TransactionManager now allows to use serializable tranactions (used for lifecycle trigger)
File size: 8.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Linq;
24using System.Windows.Forms;
25using HeuristicLab.Core.Views;
26using HeuristicLab.MainForm;
27
28namespace HeuristicLab.Clients.Hive.Views {
29  [View("HiveJob View")]
30  [Content(typeof(HiveJob), true)]
31  [Content(typeof(HiveJob<>), false)]
32  public partial class HiveJobView : ItemView {
33    public new HiveJob Content {
34      get { return (HiveJob)base.Content; }
35      set {
36        if (base.Content != value) {
37          base.Content = value;
38        }
39      }
40    }
41
42    public HiveJobView() {
43      InitializeComponent();
44    }
45
46    protected override void RegisterContentEvents() {
47      base.RegisterContentEvents();
48      Content.ItemJobChanged += new EventHandler(Content_JobItemChanged);
49      Content.JobChanged += new EventHandler(Content_JobChanged);
50      Content.JobStateChanged += new EventHandler(Content_JobStateChanged);
51    }
52
53    protected override void DeregisterContentEvents() {
54      Content.ItemJobChanged -= new EventHandler(Content_JobItemChanged);
55      Content.JobChanged -= new EventHandler(Content_JobChanged);
56      Content.JobStateChanged -= new EventHandler(Content_JobStateChanged);
57      base.DeregisterContentEvents();
58    }
59
60    protected override void OnContentChanged() {
61      base.OnContentChanged();
62      if (Content != null && Content.Job != null) {
63        computeInParallelCheckBox.Checked = Content.ItemJob.ComputeInParallel;
64      } else {
65        computeInParallelCheckBox.Checked = false;
66      }
67      Content_JobItemChanged(this, EventArgs.Empty);
68      Content_JobChanged(this, EventArgs.Empty);
69      Content_JobStateChanged(this, EventArgs.Empty);
70    }
71
72    protected virtual void RegisterJobEvents() {
73      if (Content != null && Content.Job != null) {
74        Content.ItemJob.ComputeInParallelChanged += new EventHandler(OptimizerJob_ComputeInParallelChanged);
75        Content.ItemJob.ItemChanged += new EventHandler(Job_ItemChanged);
76      }
77    }
78
79    protected virtual void DeregisterJobEvents() {
80      if (Content != null && Content.Job != null) {
81        Content.ItemJob.ComputeInParallelChanged -= new EventHandler(OptimizerJob_ComputeInParallelChanged);
82        Content.ItemJob.ItemChanged -= new EventHandler(Job_ItemChanged);
83      }
84    }
85
86    #region Content Events
87    protected virtual void Content_JobChanged(object sender, EventArgs e) {
88      if (InvokeRequired) {
89        Invoke(new EventHandler(Content_JobChanged), sender, e);
90      } else {
91        if (Content != null && Content.Job != null) {
92          this.jobIdTextBox.Text = Content.Job.Id.ToString();
93          this.dateCreatedTextBox.Text = Content.Job.DateCreated.HasValue ? Content.Job.DateCreated.ToString() : string.Empty;
94          this.priorityTextBox.Text = Content.Job.Priority.ToString();
95          this.coresNeededTextBox.Text = Content.Job.CoresNeeded.ToString();
96          this.memoryNeededTextBox.Text = Content.Job.MemoryNeeded.ToString();
97        } else {
98          this.jobIdTextBox.Text = string.Empty;
99          this.dateCreatedTextBox.Text = string.Empty;
100          this.priorityTextBox.Text = string.Empty;
101          this.coresNeededTextBox.Text = string.Empty;
102          this.memoryNeededTextBox.Text = string.Empty;
103        }
104      }
105    }
106
107    protected virtual void Content_JobItemChanged(object sender, EventArgs e) {
108      RegisterJobEvents();
109      Job_ItemChanged(this, e);
110    }
111
112    protected virtual void Job_ItemChanged(object sender, EventArgs e) {
113      if (Content != null && Content.Job != null && Content.ItemJob.Item != null) {
114        optimizerItemView.Content = Content.ItemJob.Item;
115      } else {
116        optimizerItemView.Content = null;
117      }
118    }
119
120    protected virtual void Content_JobStateChanged(object sender, EventArgs e) {
121      if (InvokeRequired) {
122        Invoke(new EventHandler(Content_JobStateChanged), sender, e);
123      } else {
124        if (Content != null && Content.Job != null) {
125          this.stateTextBox.Text = Content.Job.State.ToString();
126          this.commandTextBox.Text = Content.Job.Command.ToString();
127          this.executionTimeTextBox.Text = Content.Job.ExecutionTime.ToString();
128          this.dateFinishedTextBox.Text = Content.Job.DateFinished.ToString();
129          this.exceptionTextBox.Text = Content.Job.CurrentStateLog != null ? Content.Job.CurrentStateLog.Exception : string.Empty;
130          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        } else {
139          this.stateTextBox.Text = string.Empty;
140          this.commandTextBox.Text = string.Empty;
141          this.executionTimeTextBox.Text = string.Empty;
142          this.dateCalculatedText.Text = string.Empty;
143          this.dateFinishedTextBox.Text = string.Empty;
144          this.exceptionTextBox.Text = string.Empty;
145          this.stateLogViewHost.Content = null;
146          this.lastUpdatedTextBox.Text = string.Empty;
147        }
148        SetEnabledStateOfControls();
149      }
150    }
151
152    protected virtual void OptimizerJob_ComputeInParallelChanged(object sender, EventArgs e) {
153      if (InvokeRequired) {
154        Invoke(new EventHandler(OptimizerJob_ComputeInParallelChanged), sender, e);
155      } else {
156        computeInParallelCheckBox.Checked = Content.ItemJob.ComputeInParallel;
157      }
158    }
159    #endregion
160
161    #region Child Control Events
162     protected virtual void computeInParallelCheckBox_CheckedChanged(object sender, EventArgs e) {
163      if (Content != null && Content.ItemJob != null) {
164        this.Content.ItemJob.ComputeInParallel = this.computeInParallelCheckBox.Checked;
165      }
166    }
167
168    protected virtual void exceptionTextBox_DoubleClick(object sender, EventArgs e) {
169      using (TextDialog dialog = new TextDialog("Exception", exceptionTextBox.Text, ReadOnly || !Content.CanChangeDescription)) {
170        if (dialog.ShowDialog(this) == DialogResult.OK)
171          Content.Description = dialog.Content;
172      }
173    }
174
175    protected virtual void modifyItemButton_Click(object sender, EventArgs e) {
176      MainFormManager.MainForm.ShowContent(Content.ItemJob.Item);
177    }
178    #endregion
179
180    protected override void SetEnabledStateOfControls() {
181      base.SetEnabledStateOfControls();
182      this.jobIdTextBox.ReadOnly = true;
183      this.stateTextBox.ReadOnly = true;
184      this.commandTextBox.ReadOnly = true;
185      this.executionTimeTextBox.ReadOnly = true;
186      this.dateCreatedTextBox.ReadOnly = true;
187      this.dateCalculatedText.ReadOnly = true;
188      this.dateFinishedTextBox.ReadOnly = true;
189      this.exceptionTextBox.ReadOnly = true;
190      this.lastUpdatedTextBox.ReadOnly = true;
191
192      this.priorityTextBox.ReadOnly = this.ReadOnly;
193      this.coresNeededTextBox.ReadOnly = this.ReadOnly;
194      this.memoryNeededTextBox.ReadOnly = this.ReadOnly;
195      this.computeInParallelCheckBox.Enabled = !this.ReadOnly && this.Content != null && this.Content.ItemJob != null && this.Content.ItemJob.IsParallelizable;
196
197      this.modifyItemButton.Enabled = (Content != null && Content.ItemJob.Item != null && (Content.Job.State == JobState.Paused || Content.Job.State == JobState.Offline || Content.Job.State == JobState.Finished || Content.Job.State == JobState.Failed || Content.Job.State == JobState.Aborted));
198
199      optimizerItemView.ReadOnly = true;
200    }
201  }
202}
Note: See TracBrowser for help on using the repository browser.