Changeset 4173


Ignore:
Timestamp:
08/06/10 15:31:15 (9 years ago)
Author:
cneumuel
Message:
  • reorganized HiveExperiment code
  • disabled snapshot-functionality... this needs more refactoring serverside
  • added short documentation which explains how to use hive
  • some minor changes
Location:
branches/3.3-HiveMigration
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/HiveExperimentView.Designer.cs

    r4144 r4173  
    5454      this.hiveStatusTabPage = new System.Windows.Forms.TabPage();
    5555      this.jobListView = new HeuristicLab.Hive.Experiment.Views.JobItemListView();
     56      this.runsTabPage = new System.Windows.Forms.TabPage();
     57      this.runCollectionView = new HeuristicLab.Optimization.Views.RunCollectionView();
    5658      this.logTabPage = new System.Windows.Forms.TabPage();
    5759      this.logView = new HeuristicLab.Core.Views.LogView();
     
    6870      this.disconnectButton = new System.Windows.Forms.Button();
    6971      this.reconnectButton = new System.Windows.Forms.Button();
    70       this.runsTabPage = new System.Windows.Forms.TabPage();
    71       this.runCollectionView = new HeuristicLab.Optimization.Views.RunCollectionView();
    7272      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    7373      this.tabControl.SuspendLayout();
    7474      this.experimentTabPage.SuspendLayout();
    7575      this.hiveStatusTabPage.SuspendLayout();
     76      this.runsTabPage.SuspendLayout();
    7677      this.logTabPage.SuspendLayout();
    77       this.runsTabPage.SuspendLayout();
    7878      this.SuspendLayout();
    7979      //
     
    187187      this.jobListView.TabIndex = 0;
    188188      //
     189      // runsTabPage
     190      //
     191      this.runsTabPage.Controls.Add(this.runCollectionView);
     192      this.runsTabPage.Location = new System.Drawing.Point(4, 22);
     193      this.runsTabPage.Name = "runsTabPage";
     194      this.runsTabPage.Size = new System.Drawing.Size(727, 369);
     195      this.runsTabPage.TabIndex = 4;
     196      this.runsTabPage.Text = "Runs";
     197      this.runsTabPage.UseVisualStyleBackColor = true;
     198      //
     199      // runCollectionView
     200      //
     201      this.runCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     202                  | System.Windows.Forms.AnchorStyles.Left)
     203                  | System.Windows.Forms.AnchorStyles.Right)));
     204      this.runCollectionView.Caption = "RunCollection View";
     205      this.runCollectionView.Content = null;
     206      this.runCollectionView.Location = new System.Drawing.Point(0, 3);
     207      this.runCollectionView.Name = "runCollectionView";
     208      this.runCollectionView.ReadOnly = false;
     209      this.runCollectionView.Size = new System.Drawing.Size(727, 366);
     210      this.runCollectionView.TabIndex = 0;
     211      //
    189212      // logTabPage
    190213      //
     
    322345      this.disconnectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    323346      this.disconnectButton.Enabled = false;
    324       this.disconnectButton.Image = ((System.Drawing.Image)(resources.GetObject("disconnectButton.Image")));
    325       this.disconnectButton.Location = new System.Drawing.Point(120, 500);
     347      this.disconnectButton.Location = new System.Drawing.Point(131, 500);
    326348      this.disconnectButton.Name = "disconnectButton";
    327       this.disconnectButton.Size = new System.Drawing.Size(24, 24);
     349      this.disconnectButton.Size = new System.Drawing.Size(120, 24);
    328350      this.disconnectButton.TabIndex = 15;
     351      this.disconnectButton.Text = "Disconnect from Hive";
    329352      this.toolTip.SetToolTip(this.disconnectButton, "Disconnect from Hive (Jobs will be continue to be calculated)");
    330353      this.disconnectButton.UseVisualStyleBackColor = true;
     
    335358      this.reconnectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    336359      this.reconnectButton.Enabled = false;
    337       this.reconnectButton.Image = ((System.Drawing.Image)(resources.GetObject("reconnectButton.Image")));
    338       this.reconnectButton.Location = new System.Drawing.Point(150, 500);
     360      this.reconnectButton.Location = new System.Drawing.Point(257, 500);
    339361      this.reconnectButton.Name = "reconnectButton";
    340       this.reconnectButton.Size = new System.Drawing.Size(24, 24);
     362      this.reconnectButton.Size = new System.Drawing.Size(77, 24);
    341363      this.reconnectButton.TabIndex = 16;
     364      this.reconnectButton.Text = "Reconnect";
    342365      this.toolTip.SetToolTip(this.reconnectButton, "Reconnect to Hive");
    343366      this.reconnectButton.UseVisualStyleBackColor = true;
    344367      this.reconnectButton.Click += new System.EventHandler(this.reconnectButton_Click);
    345368      //
    346       // runsTabPage
    347       //
    348       this.runsTabPage.Controls.Add(this.runCollectionView);
    349       this.runsTabPage.Location = new System.Drawing.Point(4, 22);
    350       this.runsTabPage.Name = "runsTabPage";
    351       this.runsTabPage.Size = new System.Drawing.Size(727, 369);
    352       this.runsTabPage.TabIndex = 4;
    353       this.runsTabPage.Text = "Runs";
    354       this.runsTabPage.UseVisualStyleBackColor = true;
    355       //
    356       // runCollectionView
    357       //
    358       this.runCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    359                   | System.Windows.Forms.AnchorStyles.Left)
    360                   | System.Windows.Forms.AnchorStyles.Right)));
    361       this.runCollectionView.Caption = "RunCollection View";
    362       this.runCollectionView.Content = null;
    363       this.runCollectionView.Location = new System.Drawing.Point(0, 3);
    364       this.runCollectionView.Name = "runCollectionView";
    365       this.runCollectionView.ReadOnly = false;
    366       this.runCollectionView.Size = new System.Drawing.Size(727, 366);
    367       this.runCollectionView.TabIndex = 0;
    368       //
    369369      // HiveExperimentView
    370370      //
    371371      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    372372      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    373       this.Controls.Add(this.reconnectButton);
    374       this.Controls.Add(this.disconnectButton);
    375373      this.Controls.Add(this.resourceIdsTextBox);
    376374      this.Controls.Add(this.serverUrlTextBox);
    377375      this.Controls.Add(this.resourceIdsLabel);
    378376      this.Controls.Add(this.tabControl);
     377      this.Controls.Add(this.disconnectButton);
    379378      this.Controls.Add(this.startButton);
    380379      this.Controls.Add(this.executionTimeTextBox);
     
    384383      this.Controls.Add(this.stopButton);
    385384      this.Controls.Add(this.resetButton);
     385      this.Controls.Add(this.reconnectButton);
    386386      this.Name = "HiveExperimentView";
    387387      this.Size = new System.Drawing.Size(735, 524);
     388      this.Controls.SetChildIndex(this.reconnectButton, 0);
    388389      this.Controls.SetChildIndex(this.resetButton, 0);
    389390      this.Controls.SetChildIndex(this.stopButton, 0);
     
    393394      this.Controls.SetChildIndex(this.executionTimeTextBox, 0);
    394395      this.Controls.SetChildIndex(this.startButton, 0);
     396      this.Controls.SetChildIndex(this.disconnectButton, 0);
    395397      this.Controls.SetChildIndex(this.tabControl, 0);
    396398      this.Controls.SetChildIndex(this.resourceIdsLabel, 0);
    397399      this.Controls.SetChildIndex(this.serverUrlTextBox, 0);
    398400      this.Controls.SetChildIndex(this.resourceIdsTextBox, 0);
    399       this.Controls.SetChildIndex(this.disconnectButton, 0);
    400       this.Controls.SetChildIndex(this.reconnectButton, 0);
    401401      this.Controls.SetChildIndex(this.nameLabel, 0);
    402402      this.Controls.SetChildIndex(this.descriptionLabel, 0);
     
    407407      this.experimentTabPage.ResumeLayout(false);
    408408      this.hiveStatusTabPage.ResumeLayout(false);
     409      this.runsTabPage.ResumeLayout(false);
    409410      this.logTabPage.ResumeLayout(false);
    410       this.runsTabPage.ResumeLayout(false);
    411411      this.ResumeLayout(false);
    412412      this.PerformLayout();
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/HiveExperimentView.resx

    r4144 r4173  
    128128    <value>
    129129        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    130         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALDQAA
    131         Cw0B7QfALAAAAn9JREFUOE+lk2tI01EYxhf0oU8WqVEIRpaIBWJgSPUhROmippS3QkkTylsXDMW8ts3b
     130        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALDAAA
     131        CwwBP0AiyAAAAn9JREFUOE+lk2tI01EYxhf0oU8WqVEIRpaIBWJgSPUhROmippS3QkkTylsXDMW8ts3b
    132132        1G06daVibuqaOq0sxbBCKBSJ0PJCialZUFSKqaGSt1//TbIsww8deOBwznl+5zkv71kHiP5rGAFrKb1Q
    133133        5ypR6bmaVU6m2kCiXJv007Om2XgwJEaNT4QiyDi/GF9mKRVgsWkav+CYQkR1utwAQfypphqZ4l/JIhOL
     
    146146    <value>
    147147        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    148         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALDQAA
    149         Cw0B7QfALAAAAaJJREFUOE+Nkk1LAkEYx5egU9Sla9AX6NKhLlH3IujSoXtBn0EI+gB5qVBIKyIMtEDo
     148        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALDAAA
     149        CwwBP0AiyAAAAaJJREFUOE+Nkk1LAkEYx5egU9Sla9AX6NKhLlH3IujSoXtBn0EI+gB5qVBIKyIMtEDo
    150150        BUIhK6qDSUj4gqYloilmvqa5rrr/Zlx3dkU0B/48z87O/zfzPDMcAE7SOg8sB2AkqYdIXIoAK4LyX17X
    151151        HiVzYPhC0NBUB1yR6Jfy5lx59rQXRAKEhl6Y4YhMnXOSmUDywRlYHV5YbG6YLp1UW2pgEyBoSdARbdNP
     
    160160    <value>
    161161        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    162         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALAgAA
    163         CwIBm8luNgAAALZJREFUOE9j/P//PwNFAGQAOi7bn+2GTRybGIZmkKKEGRH/iTUEpwGWZfpEGYLVgKgp
     162        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALAQAA
     163        CwEBNnBPWwAAALZJREFUOE9j/P//PwNFAGQAOi7bn+2GTRybGIZmkKKEGRH/iTUEpwGWZfpEGYLVgKgp
    164164        Qf833Fr8nxhDsBoQPMEbZDtRhmA1wKfLGWwACEctCsDrEqwGODZb/M/YEAvWbNus/1+nWOG/RBo3iFZD
    165165        jwmsBpjX6KFo5k9gwaoZnIawxa1eqTLcZnyacRqgki8FdjYhzTgNkM4QJEozTgNEkjlx+pmoQMQW2rjy
     
    170170    <value>
    171171        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    172         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALAgAA
    173         CwIBm8luNgAAAXJJREFUOE+tkj1IQmEYhWsoaIi2xmhpiYSgKFoiCMLJJYSEJiEI0mgIyqjA6vaLUKIU
     172        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALAQAA
     173        CwEBNnBPWwAAAXJJREFUOE+tkj1IQmEYhWsoaIi2xmhpiYSgKFoiCMLJJYSEJiEI0mgIyqjA6vaLUKIU
    174174        iZlJKKUoWEbZDzVYCYlQYVxcNDIoRND8ud7idD83C27g7YNvPM8573nfcgBlgh4BCPmCxIX0Qtx/ATTu
    175175        Lyy78ph3ZKC2pTBlSWB86w2jhleMrD9jWB9N/jQsSkDEj5FPPERZ+J7yOL5j4PYzsPsYGL1piKR7nL64
     
    183183    <value>
    184184        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    185         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALAgAA
    186         CwIBm8luNgAAAYNJREFUOE9j/P//PwNFAGQAJZgizWDXI9veu/nvfxhuW/vtf+OKz/9rF7//XzHv1f+S
     185        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALAQAA
     186        CwEBNnBPWwAAAYNJREFUOE9j/P//PwNFAGQAJZgizWDXI9veu/nvfxhuW/vtf+OKz/9rF7//XzHv1f+S
    187187        2c//F0x//L901mOgFoSrUQzo2vDr/6aT3/6vPPTl/4I9n/5ffvDzf+/ad/+bl74BG5I3/cV/3dBVuA0A
    188188        2bri4Jf/83Z9+n/ryS+Qwv8NS978L5378n/O1Of/k3qf/Vf1W4TbAJCT5+z49P/hyx9gzSBQMvvl/6wp
     
    196196    <value>
    197197        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    198         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALAgAA
    199         CwIBm8luNgAAAMZJREFUOE9j/P//PwNFAGQAJZgizWDXU2I7VgN6N//937Xh1/+8qY8+gRSg89EtxHAB
    200         SPPVh3/+64auAqr9z4DOJ2hA29pv/289/f1f1W8R2AB0PkEDGld8/n/54e//cm6zwAag8wkaULv4/f8T
    201         13//F7ObBDYAnU/QgIp5r/7vvvDzP79ZN9gAdD5BA0pmP/+//uTP/5wGrWAD0PkEDSiY/vj/gj2f/7Pq
    202         NIINQOcTNAAU/2y6TXAD0PkEDSA1ZVI/KZPqAgBmE8VVB/UQsAAAAABJRU5ErkJggg==
    203 </value>
    204   </data>
    205   <data name="disconnectButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    206     <value>
    207         iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    208198        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALAQAA
    209199        CwEBNnBPWwAAAMZJREFUOE9j/P//PwNFAGQAJZgizWDXU2I7VgN6N//937Xh1/+8qY8+gRSg89EtxHAB
     
    213203</value>
    214204  </data>
    215   <data name="reconnectButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    216     <value>
    217         iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    218         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALAAAA
    219         CwAB5DetvwAAAMZJREFUOE9j/P//PwNFAGQAJZgizWDXU2I7VgN6N//937Xh1/+8qY8+gRSg89EtxHAB
    220         SPPVh3/+64auAqr9z4DOJ2hA29pv/289/f1f1W8R2AB0PkEDGld8/n/54e//cm6zwAag8wkaULv4/f8T
    221         13//F7ObBDYAnU/QgIp5r/7vvvDzP79ZN9gAdD5BA0pmP/+//uTP/5wGrWAD0PkEDSiY/vj/gj2f/7Pq
    222         NIINQOcTNAAU/2y6TXAD0PkEDSA1ZVI/KZPqAgBmE8VVB/UQsAAAAABJRU5ErkJggg==
    223 </value>
    224   </data>
    225205</root>
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/JobItemView.Designer.cs

    r4170 r4173  
    262262      this.snapshotGroupBox.TabStop = false;
    263263      this.snapshotGroupBox.Text = "Latest Snapshot";
     264      this.snapshotGroupBox.Visible = false;
    264265      //
    265266      // requestSnapshotButton
     
    433434      this.logTabPage.Name = "logTabPage";
    434435      this.logTabPage.Padding = new System.Windows.Forms.Padding(3);
    435       this.logTabPage.Size = new System.Drawing.Size(545, 453);
     436      this.logTabPage.Size = new System.Drawing.Size(619, 492);
    436437      this.logTabPage.TabIndex = 1;
    437438      this.logTabPage.Text = "Log";
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/JobItemView.cs

    r4170 r4173  
    102102
    103103    protected override void SetEnabledStateOfControls() {
    104       base.SetEnabledStateOfControls();
    105       if (Content != null) {
    106         openSnapshotButton.Enabled = Content.LatestSnapshot != null && Content.SnapshotRequestedState == SnapshotRequestedState.Idle;
    107         requestSnapshotButton.Enabled = Content.SnapshotRequestedState == SnapshotRequestedState.Idle;
     104      if (InvokeRequired) {
     105        this.InvokeIfRequired(c => { SetEnabledStateOfControls(); });
     106      } else {
     107        base.SetEnabledStateOfControls();
     108        if (Content != null) {
     109          openSnapshotButton.Enabled = Content.LatestSnapshot != null && Content.SnapshotRequestedState == SnapshotRequestedState.Idle;
     110          requestSnapshotButton.Enabled = Content.SnapshotRequestedState == SnapshotRequestedState.Idle;
     111        }
     112        this.jobIdTextBox.ReadOnly = this.ReadOnly;
     113        this.stateTextBox.ReadOnly = this.ReadOnly;
     114        this.userIdTextBox.ReadOnly = this.ReadOnly;
     115        this.percentageTextBox.ReadOnly = this.ReadOnly;
     116        this.dateCreatedTextBox.ReadOnly = this.ReadOnly;
     117        this.dateCalculatedText.ReadOnly = this.ReadOnly;
     118        this.dateFinishedTextBox.ReadOnly = this.ReadOnly;
     119        this.priorityTextBox.ReadOnly = this.ReadOnly;
     120        this.coresNeededTextBox.ReadOnly = this.ReadOnly;
     121        this.memoryNeededTextBox.ReadOnly = this.ReadOnly;
     122        this.exceptionTextBox.ReadOnly = this.ReadOnly;
     123        this.projectTextBox.ReadOnly = this.ReadOnly;
     124        this.snapshotStatusText.ReadOnly = this.ReadOnly;
     125        this.snapshotTimeText.ReadOnly = this.ReadOnly;
    108126      }
    109       this.jobIdTextBox.ReadOnly = this.ReadOnly;
    110       this.stateTextBox.ReadOnly = this.ReadOnly;
    111       this.userIdTextBox.ReadOnly = this.ReadOnly;
    112       this.percentageTextBox.ReadOnly = this.ReadOnly;
    113       this.dateCreatedTextBox.ReadOnly = this.ReadOnly;
    114       this.dateCalculatedText.ReadOnly = this.ReadOnly;
    115       this.dateFinishedTextBox.ReadOnly = this.ReadOnly;
    116       this.priorityTextBox.ReadOnly = this.ReadOnly;
    117       this.coresNeededTextBox.ReadOnly = this.ReadOnly;
    118       this.memoryNeededTextBox.ReadOnly = this.ReadOnly;
    119       this.exceptionTextBox.ReadOnly = this.ReadOnly;
    120       this.projectTextBox.ReadOnly = this.ReadOnly;
    121       this.snapshotStatusText.ReadOnly = this.ReadOnly;
    122       this.snapshotTimeText.ReadOnly = this.ReadOnly;
    123127    }
    124128
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/HiveExperiment.cs

    r4170 r4173  
    6565    private Semaphore fetchJobSemaphore = new Semaphore(2, 2);
    6666
    67     [Storable]
    68     private DateTime lastUpdateTime;
     67    private bool stopResultsPollingPending = false;
     68
     69    private Thread resultPollingThread;
    6970
    7071    private bool isPollingResults;
     
    7980    }
    8081
    81     private bool stopResultsPollingPending = false;
    82 
    83     private Thread resultPollingThread;
     82    public IEnumerable<string> ResourceGroups {
     83      get {
     84        if (!string.IsNullOrEmpty(resourceIds)) {
     85          return resourceIds.Split(';');
     86        } else {
     87          return new List<string>();
     88        }
     89      }
     90    }
     91   
     92    #region Storable Properties
     93    [Storable]
     94    private DateTime lastUpdateTime;
    8495
    8596    /// <summary>
     
    146157      get { return log; }
    147158    }
     159
     160    [Storable]
     161    private Core.ExecutionState executionState;
     162    public ExecutionState ExecutionState {
     163      get { return executionState; }
     164      private set {
     165        if (executionState != value) {
     166          executionState = value;
     167          OnExecutionStateChanged();
     168        }
     169      }
     170    }
     171
     172    [Storable]
     173    private TimeSpan executionTime;
     174    public TimeSpan ExecutionTime {
     175      get { return executionTime; }
     176      private set {
     177        if (executionTime != value) {
     178          executionTime = value;
     179          OnExecutionTimeChanged();
     180        }
     181      }
     182    }
     183    #endregion
    148184
    149185    [StorableConstructor]
     
    198234    }
    199235
     236    #region Execution Time Timer
    200237    private void InitTimer() {
    201238      timer = new System.Timers.Timer(100);
     
    209246      lastUpdateTime = now;
    210247    }
    211 
    212     public IEnumerable<string> ResourceGroups {
    213       get {
    214         if (!string.IsNullOrEmpty(resourceIds)) {
    215           return resourceIds.Split(';');
    216         } else {
    217           return new List<string>();
    218         }
    219       }
    220     }
    221     #region IExecutable Members
    222 
    223     [Storable]
    224     private Core.ExecutionState executionState;
    225     public ExecutionState ExecutionState {
    226       get { return executionState; }
    227       private set {
    228         if (executionState != value) {
    229           executionState = value;
    230           OnExecutionStateChanged();
    231         }
    232       }
    233     }
    234 
    235     [Storable]
    236     private TimeSpan executionTime;
    237     public TimeSpan ExecutionTime {
    238       get { return executionTime; }
    239       private set {
    240         if (executionTime != value) {
    241           executionTime = value;
    242           OnExecutionTimeChanged();
    243         }
    244       }
    245     }
    246 
     248    #endregion
     249
     250    #region IExecutable Methods
    247251    public void Pause() {
    248252      throw new NotSupportedException();
     
    252256      if (experiment != null) {
    253257        StopResultPolling();
    254         pendingOptimizersByJobId.Clear();
     258        lock (pendingOptimizersByJobId) {
     259          pendingOptimizersByJobId.Clear();
     260        }
    255261        parentOptimizersByPendingOptimizer.Clear();
    256         jobItems.Clear();
     262        lock (jobItems) {
     263          jobItems.Clear();
     264        }
    257265        experiment.Prepare();
    258266        this.ExecutionState = Core.ExecutionState.Prepared;
     
    262270
    263271    public void Start() {
     272      sendingJobsFinished = false;
    264273      OnStarted();
    265274      ExecutionTime = new TimeSpan();
     
    270279      Thread t = new Thread(() => {
    271280        IExecutionEngineFacade executionEngineFacade = GetExecutionEngineFacade();
    272        
     281
    273282        try {
    274283          pendingOptimizersByJobId = new Dictionary<Guid, IOptimizer>();
     
    277286          parentOptimizersByPendingOptimizer = GetOptimizers(true);
    278287          LogMessage("Extraction of jobs from Experiment finished");
    279          
     288
    280289          IEnumerable<string> groups = ResourceGroups;
    281290
    282           sendingJobsFinished = false;
    283291          foreach (IOptimizer optimizer in parentOptimizersByPendingOptimizer.Keys) {
    284292            SerializedJob serializedJob = CreateSerializedJob(optimizer);
    285293            ResponseObject<JobDto> response = executionEngineFacade.AddJobWithGroupStrings(serializedJob, groups);
    286             pendingOptimizersByJobId.Add(response.Obj.Id, optimizer);
     294            lock (pendingOptimizersByJobId) {
     295              pendingOptimizersByJobId.Add(response.Obj.Id, optimizer);
     296            }
    287297
    288298            JobItem jobItem = new JobItem() {
     
    296306            LogMessage(jobItem.JobDto.Id, "Job sent to Hive");
    297307          }
    298           sendingJobsFinished = true;
    299308        } catch (Exception e) {
    300309          LogMessage("Error: Starting HiveExperiment failed: " + e.Message);
     
    303312        }
    304313
     314        sendingJobsFinished = true;
    305315      });
    306316      t.Start();
     
    314324      OnStopped();
    315325    }
    316 
    317     public void StartResultPolling() {
    318       this.stopResultsPollingPending = false;
    319       this.IsPollingResults = true;
    320       resultPollingThread = CreateResultPollingThread();
    321       if (resultPollingThread.ThreadState != System.Threading.ThreadState.Running)
    322         resultPollingThread.Start();
    323     }
    324 
    325     public void StopResultPolling() {
    326       this.stopResultsPollingPending = true;
    327       resultPollingThread.Interrupt();
    328       this.stopResultsPollingPending = false;
    329     }
    330 
    331     private JobItem GetJobItemById(Guid jobId) {
    332       return jobItems.Single(x => x.JobDto.Id == jobId);
    333     }
    334 
     326    #endregion
     327
     328    #region Optimizier Management
    335329    /// <summary>
    336330    /// Returns all optimizers in the current Experiment
     
    381375        optimizer.Name = prepend + optimizer.Name;
    382376        optimizers.Add(optimizer, parent);
     377        LogMessage("Optimizer extracted: " + optimizer.Name);
    383378      } else {
    384379        Logger.Warn("Optimizer of type " + optimizers.GetType().ToString() + " unknown");
    385380        optimizer.Name = prepend + optimizer.Name;
    386381        optimizers.Add(optimizer, parent);
     382        LogMessage("Optimizer extracted: " + optimizer.Name);
    387383      }
    388384      return optimizers;
    389     }
    390 
    391     private void AddRange(IDictionary<IOptimizer, IOptimizer> optimizers, IDictionary<IOptimizer, IOptimizer> childs) {
    392       foreach (KeyValuePair<IOptimizer, IOptimizer> kvp in childs) {
    393         optimizers.Add(kvp);
    394       }
    395385    }
    396386
     
    414404    }
    415405
     406    private bool NoMorePendingOptimizers() {
     407      lock (pendingOptimizersByJobId) {
     408        return pendingOptimizersByJobId.Count == 0;
     409      }
     410    }
     411
     412    /// <summary>
     413    /// Removes optimizers from
     414    ///  - parentOptimizersByPendingOptimizer
     415    ///  - pendingOptimizersByJobId
     416    /// </summary>
     417    /// <param name="jobId"></param>
     418    private void DisposeOptimizerMappings(Guid jobId) {
     419      lock (pendingOptimizersByJobId) {
     420        LogMessage(jobId, "Disposing Optimizer Mappings");
     421        parentOptimizersByPendingOptimizer.Remove(pendingOptimizersByJobId[jobId]);
     422        pendingOptimizersByJobId.Remove(jobId);
     423      }
     424    }
     425
     426    #endregion
     427
     428    #region Job Management
     429    /// <summary>
     430    /// Updates all JobItems with the results
     431    /// </summary>
     432    /// <param name="jobResultList"></param>
     433    private void UpdateJobItems(JobResultList jobResultList) {
     434      // use a Dict to avoid quadratic runtime complexity
     435      IDictionary<Guid, JobResult> jobResultDict = jobResultList.ToDictionary(job => job.JobId);
     436      lock (jobItems) {
     437        foreach (JobItem jobItem in JobItems) {
     438          if (jobResultDict.ContainsKey(jobItem.JobDto.Id)) {
     439            jobItem.JobResult = jobResultDict[jobItem.JobDto.Id];
     440          }
     441        }
     442      }
     443    }
     444
     445    private void JobItem_JobStateChanged(object sender, EventArgs e) {
     446      JobItem jobItem = (JobItem)sender;
     447      Thread t = new Thread(() => {
     448        if (jobItem.State == State.Finished) {
     449          FetchAndUpdateJob(jobItem.JobDto.Id);
     450          DisposeOptimizerMappings(jobItem.JobDto.Id);
     451        } else if (jobItem.State == State.Failed) {
     452          DisposeOptimizerMappings(jobItem.JobDto.Id);
     453        }
     454
     455        if (NoMorePendingOptimizers()) {
     456          StopResultPolling();
     457          this.ExecutionState = Core.ExecutionState.Stopped;
     458          OnStopped();
     459        }
     460      });
     461      t.Start();
     462    }
     463
     464    /// <summary>
     465    /// Fetches the finished job from the server and updates the jobItem
     466    /// </summary>
     467    private void FetchAndUpdateJob(Guid jobId) {
     468      LogMessage(jobId, "FetchAndUpdateJob started");
     469      IExecutionEngineFacade executionEngineFacade = GetExecutionEngineFacade();
     470      IOptimizer originalOptimizer;
     471      lock (pendingOptimizersByJobId) {
     472        originalOptimizer = pendingOptimizersByJobId[jobId];
     473      }
     474
     475      fetchJobSemaphore.WaitOne();
     476      ResponseObject<SerializedJob> jobResponse = executionEngineFacade.GetLastSerializedResult(jobId, false, false);
     477      IJob restoredObject = XmlParser.Deserialize<IJob>(new MemoryStream(jobResponse.Obj.SerializedJobData));
     478      IOptimizer restoredOptimizer = ((OptimizerJob)restoredObject).Optimizer;
     479
     480      ReplaceOptimizer(parentOptimizersByPendingOptimizer[originalOptimizer], originalOptimizer, restoredOptimizer);
     481      fetchJobSemaphore.Release();
     482      LogMessage(jobId, "FetchAndUpdateJob ended");
     483    }
     484
     485    private void UpdateJobItem(JobDto jobDto) {
     486      JobItem jobItem = jobItems.Single(x => x.JobDto.Id == jobDto.Id);
     487      jobItem.JobDto = jobDto;
     488    }
     489
    416490    public void AbortJob(Guid jobId) {
    417491      IExecutionEngineFacade executionEngineFacade = GetExecutionEngineFacade();
    418492      Response response = executionEngineFacade.AbortJob(jobId);
    419493      LogMessage(jobId, "Aborting Job: " + response.StatusMessage);
    420     }
    421 
    422     #endregion
    423 
    424     private IExecutionEngineFacade GetExecutionEngineFacade() {
    425       IExecutionEngineFacade executionEngineFacade = null;
    426       do {
    427         try {
    428           executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(ServerUrl);
    429         } catch (EndpointNotFoundException exception) {
    430           LogMessage("Could not connect to Server: " + exception.Message + ". Will try again in " + (resultPollingIntervalMs / 1000) + " sec.");
    431           Thread.Sleep(resultPollingIntervalMs);
    432         }
    433       } while (executionEngineFacade == null && this.ExecutionState != Core.ExecutionState.Stopped);
    434       return executionEngineFacade;
    435494    }
    436495
     
    470529    }
    471530
    472     /// <summary>
    473     /// Requests a resultList for all jobItems not finished or aborted
    474     /// </summary>
    475     /// <returns></returns>
     531    private JobItem GetJobItemById(Guid jobId) {
     532      return jobItems.Single(x => x.JobDto.Id == jobId);
     533    }
     534    #endregion
     535
     536    #region Result Polling
     537    public void StartResultPolling() {
     538      this.stopResultsPollingPending = false;
     539      this.IsPollingResults = true;
     540      resultPollingThread = CreateResultPollingThread();
     541      if (resultPollingThread.ThreadState != System.Threading.ThreadState.Running)
     542        resultPollingThread.Start();
     543    }
     544
     545    public void StopResultPolling() {
     546      this.stopResultsPollingPending = true;
     547      resultPollingThread.Interrupt();
     548      this.stopResultsPollingPending = false;
     549    }
     550
    476551    private Thread CreateResultPollingThread() {
    477552      return new Thread(() => {
     
    512587    }
    513588
    514     /// <summary>
    515     /// Updates all JobItems with the results
    516     /// </summary>
    517     /// <param name="jobResultList"></param>
    518     private void UpdateJobItems(JobResultList jobResultList) {
    519       // use a Dict to avoid quadratic runtime complexity
    520       IDictionary<Guid, JobResult> jobResultDict = jobResultList.ToDictionary(job => job.JobId);
    521       lock (jobItems) {
    522         foreach (JobItem jobItem in JobItems) {
    523           if (jobResultDict.ContainsKey(jobItem.JobDto.Id)) {
    524             jobItem.JobResult = jobResultDict[jobItem.JobDto.Id];
    525           }
    526         }
    527       }
    528     }
    529 
    530     void JobItem_JobStateChanged(object sender, EventArgs e) {
    531       JobItem jobItem = (JobItem)sender;
    532       Thread t = new Thread(() => {
    533         if (jobItem.State == State.Finished) {
    534           FetchAndUpdateJob(jobItem.JobDto.Id);
    535           DisposeOptimizerMappings(jobItem.JobDto.Id);
    536         } else if (jobItem.State == State.Failed) {
    537           DisposeOptimizerMappings(jobItem.JobDto.Id);
    538         }
    539 
    540         if (NoMorePendingOptimizers()) {
    541           StopResultPolling();
    542           this.ExecutionState = Core.ExecutionState.Stopped;
    543           OnStopped();
    544         }
    545       });
    546       t.Start();
    547     }
    548 
    549     private bool NoMorePendingOptimizers() {
    550       return pendingOptimizersByJobId.Count == 0;
    551     }
    552 
    553     /// <summary>
    554     /// Removes optimizers from
    555     ///  - parentOptimizersByPendingOptimizer
    556     ///  - pendingOptimizersByJobId
    557     /// </summary>
    558     /// <param name="jobId"></param>
    559     private void DisposeOptimizerMappings(Guid jobId) {
    560       parentOptimizersByPendingOptimizer.Remove(pendingOptimizersByJobId[jobId]);
    561       pendingOptimizersByJobId.Remove(jobId);
    562     }
    563 
    564     /// <summary>
    565     /// Fetches the finished job from the server and updates the jobItem
    566     /// </summary>
    567     private void FetchAndUpdateJob(Guid jobId) {
    568       LogMessage(jobId, "FetchAndUpdateJob started");
    569       IExecutionEngineFacade executionEngineFacade = GetExecutionEngineFacade();
    570       IOptimizer originalOptimizer = pendingOptimizersByJobId[jobId];
    571 
    572       fetchJobSemaphore.WaitOne();
    573       ResponseObject<SerializedJob> jobResponse = executionEngineFacade.GetLastSerializedResult(jobId, false, false);
    574       UpdateSnapshot(jobResponse);
    575 
    576       IJob restoredObject = XmlParser.Deserialize<IJob>(new MemoryStream(jobResponse.Obj.SerializedJobData));
    577       IOptimizer restoredOptimizer = ((OptimizerJob)restoredObject).Optimizer;
    578 
    579       ReplaceOptimizer(parentOptimizersByPendingOptimizer[originalOptimizer], originalOptimizer, restoredOptimizer);
    580       fetchJobSemaphore.Release();
    581       LogMessage(jobId, "FetchAndUpdateJob ended");
    582     }
    583 
    584     //// ensure that not all resultPollingThreads can access the server simultaniously
    585     //private Semaphore resultPollingSemaphore = new Semaphore(5, 5);
    586 
    587     //private Thread CreateResultPollingThread(JobDto job) {
    588     //  return new Thread(() => {
    589     //    try {
    590     //      GetJobItemById(job.Id).LogMessage("Starting job results polling");
    591     //      IExecutionEngineFacade executionEngineFacade = GetExecutionEngineFacade();
    592     //      IJob restoredObject = null;
    593     //      IOptimizer originalOptimizer = pendingOptimizersByJobId[job.Id];
    594 
    595     //      do {
    596     //        // loop while
    597     //        // 1. the user doesn't request an abort
    598     //        // 2. there is a problem with server communication (success==false)
    599     //        // 3. no result for the job is available yet (response.Obj==null)
    600     //        // 4. the result that we get from the server is a snapshot and not the final result
    601     //        try {
    602     //          resultPollingSemaphore.WaitOne();
    603     //          if (stopPending || !this.IsPollingResults) {
    604     //            return;
    605     //          }
    606 
    607     //          ResponseObject<JobDto> response = null;
    608     //          try {
    609     //            response = executionEngineFacade.GetJobById(job.Id);
    610     //            LogMessage("Response: " + response.StatusMessage + " (jobId: " + job.Id + ")");
    611     //            GetJobItemById(job.Id).LogMessage("Response: " + response.StatusMessage);
    612 
    613     //            UpdateJobItem(response.Obj);
    614 
    615     //            if (response.Obj.State == State.Abort) {
    616     //              pendingOptimizersByJobId.Remove(job.Id);
    617     //              parentOptimizersByPendingOptimizer.Remove(originalOptimizer);
    618     //              GetJobItemById(job.Id).LogMessage("Job successfully aborted");
    619     //              return;
    620     //            }
    621 
    622     //            if (response.Obj.State == State.Failed) {
    623     //              pendingOptimizersByJobId.Remove(job.Id);
    624     //              parentOptimizersByPendingOptimizer.Remove(originalOptimizer);
    625     //              GetJobItemById(job.Id).LogMessage("Job failed with exception: " + response.Obj.Exception);
    626     //              return;
    627     //            }
    628     //          } catch (Exception e) {
    629     //            LogMessage("Error: Result polling failed for job (" + job.Id + "): " + e.Message);
    630     //            GetJobItemById(job.Id).LogMessage("Error: Result polling failed: " + e.Message);
    631     //          }
    632 
    633     //          if (response != null && response.Success && response.Obj != null && response.Obj.State == State.Finished) {
    634     //            try {
    635     //              ResponseObject<SerializedJob> jobResponse = executionEngineFacade.GetLastSerializedResult(job.Id, false, false);
    636     //              restoredObject = XmlParser.Deserialize<IJob>(new MemoryStream(jobResponse.Obj.SerializedJobData));
    637     //              UpdateSnapshot(jobResponse);
    638     //            } catch (Exception e) {
    639     //              LogMessage("Error: Retrieving final result failed for job (" + job.Id + "): " + e.Message);
    640     //              GetJobItemById(job.Id).LogMessage("Error: Retrieving final result failed: " + e.Message);
    641     //            }
    642     //          } else {
    643     //            Thread.Sleep(resultPollingIntervalMs);
    644     //          }
    645     //        } finally {
    646     //          // use finally to always release the semaphore lock
    647     //          resultPollingSemaphore.Release();
    648     //        }
    649     //      } while (restoredObject == null || restoredObject.ExecutionState != Core.ExecutionState.Stopped);
    650 
    651     //      LogMessage("Job finished (jobId: " + job.Id + ")");
    652     //      GetJobItemById(job.Id).LogMessage("Job finished");
    653     //      // job retrieved... replace the existing optimizers with the finished one
    654 
    655     //      IOptimizer restoredOptimizer = ((OptimizerJob)restoredObject).Optimizer;
    656 
    657     //      ReplaceOptimizer(parentOptimizersByPendingOptimizer[originalOptimizer], originalOptimizer, restoredOptimizer);
    658     //      pendingOptimizersByJobId.Remove(job.Id);
    659     //      parentOptimizersByPendingOptimizer.Remove(originalOptimizer);
    660 
    661     //    } catch (ThreadInterruptedException exception) {
    662 
    663     //    } finally {
    664     //      GetJobItemById(job.Id).LogMessage("ResultsPolling Thread stopped");
    665     //      //lock (resultPollingThreads) {
    666     //      //  resultPollingThreads.Remove(job.Id);
    667     //      //  if (resultPollingThreads.Count == 0) {
    668     //      //    IsPollingResults = false;
    669     //      //  }
    670     //      //}
    671 
    672     //      // check if finished
    673     //      if (pendingOptimizersByJobId.Count == 0) {
    674     //        this.ExecutionState = Core.ExecutionState.Stopped;
    675     //        OnStopped();
    676     //      }
    677     //    }
    678     //  });
    679     //}
    680 
    681     private void UpdateJobItem(JobDto jobDto) {
    682       JobItem jobItem = jobItems.Single(x => x.JobDto.Id == jobDto.Id);
    683       jobItem.JobDto = jobDto;
    684     }
     589    #endregion
     590
     591    #region Snapshots
    685592
    686593    private void UpdateSnapshot(ResponseObject<SerializedJob> response) {
     
    689596    }
    690597
    691     private void LogMessage(string message) {
    692       // HeuristicLab.Log is not Thread-Safe, so lock on every call
    693       lock (locker) {
    694         log.LogMessage(message);
    695       }
    696     }
    697 
    698     private void LogMessage(Guid jobId, string message) {
    699       GetJobItemById(jobId).LogMessage(message);
    700       LogMessage(message + " (jobId: " + jobId + ")");
     598    public void RequestSnapshot(Guid jobId) {
     599      Thread t = new Thread(() => {
     600        IExecutionEngineFacade executionEngineFacade = GetExecutionEngineFacade();
     601        ResponseObject<SerializedJob> response;
     602        int retryCount = 0;
     603
     604        Response snapShotResponse = executionEngineFacade.RequestSnapshot(jobId);
     605        if (snapShotResponse.StatusMessage == ApplicationConstants.RESPONSE_JOB_IS_NOT_BEEING_CALCULATED) {
     606          // job already finished
     607          Logger.Debug("HiveExperiment: Abort - GetLastResult(false)");
     608          response = executionEngineFacade.GetLastSerializedResult(jobId, false, false);
     609          Logger.Debug("HiveExperiment: Abort - Server: " + response.StatusMessage + " success: " + response.Success);
     610        } else {
     611          // server sent snapshot request to client
     612          // poll until snapshot is ready
     613          do {
     614            Thread.Sleep(snapshotPollingIntervalMs);
     615            Logger.Debug("HiveExperiment: Abort - GetLastResult(true)");
     616            response = executionEngineFacade.GetLastSerializedResult(jobId, false, true);
     617            Logger.Debug("HiveExperiment: Abort - Server: " + response.StatusMessage + " success: " + response.Success);
     618            retryCount++;
     619            // loop while
     620            // 1. problem with communication with server
     621            // 2. job result not yet ready
     622          } while (
     623            (retryCount < maxSnapshotRetries) && (
     624            !response.Success ||
     625            response.StatusMessage == ApplicationConstants.RESPONSE_JOB_RESULT_NOT_YET_HERE)
     626            );
     627        }
     628        if (response.Success) {
     629          LogMessage(jobId, "Snapshot polling successfull for job " + jobId);
     630          UpdateSnapshot(response);
     631        } else {
     632          LogMessage(jobId, "Error: Polling of Snapshot failed for job " + jobId + ": " + response.StatusMessage);
     633        }
     634      });
     635      t.Start();
    701636    }
    702637
     
    708643    }
    709644
    710     public void RequestSnapshot(Guid jobId) {
    711       IExecutionEngineFacade executionEngineFacade = GetExecutionEngineFacade();
    712       ResponseObject<SerializedJob> response;
    713       int retryCount = 0;
    714 
    715       Response snapShotResponse = executionEngineFacade.RequestSnapshot(jobId);
    716       if (snapShotResponse.StatusMessage == ApplicationConstants.RESPONSE_JOB_IS_NOT_BEEING_CALCULATED) {
    717         // job already finished
    718         Logger.Debug("HiveEngine: Abort - GetLastResult(false)");
    719         response = executionEngineFacade.GetLastSerializedResult(jobId, false, false);
    720         Logger.Debug("HiveEngine: Abort - Server: " + response.StatusMessage + " success: " + response.Success);
    721       } else {
    722         // server sent snapshot request to client
    723         // poll until snapshot is ready
    724         do {
    725           Thread.Sleep(snapshotPollingIntervalMs);
    726           Logger.Debug("HiveEngine: Abort - GetLastResult(true)");
    727           response = executionEngineFacade.GetLastSerializedResult(jobId, false, true);
    728           Logger.Debug("HiveEngine: Abort - Server: " + response.StatusMessage + " success: " + response.Success);
    729           retryCount++;
    730           // loop while
    731           // 1. problem with communication with server
    732           // 2. job result not yet ready
    733         } while (
    734           (retryCount < maxSnapshotRetries) && (
    735           !response.Success ||
    736           response.StatusMessage == ApplicationConstants.RESPONSE_JOB_RESULT_NOT_YET_HERE)
    737           );
    738       }
    739       if (response.Success) {
    740         LogMessage(jobId, "Snapshot polling successfull for job " + jobId);
    741         GetJobItemById(jobId).LatestSnapshot = response;
    742       } else {
    743         LogMessage(jobId, "Error: Polling of Snapshot failed for job " + jobId + ": " + response.StatusMessage);
    744       }
    745     }
     645    #endregion
    746646
    747647    #region Required Plugin Search
     
    915815      jobItems.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_ItemsRemoved);
    916816      jobItems.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_ItemsReplaced);
     817      foreach (JobItem jobItem in jobItems) {
     818        RegisterJobItemEvents(jobItem);
     819      }
    917820    }
    918821
     
    922825      jobItems.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_ItemsRemoved);
    923826      jobItems.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_ItemsReplaced);
     827      foreach (JobItem jobItem in jobItems) {
     828        DeregisterJobItemEvents(jobItem);
     829      }
    924830    }
    925831
     
    931837      if (e.OldItems != null) {
    932838        foreach (var item in e.OldItems) {
    933           item.Value.SnapshotRequestedStateChanged -= new EventHandler(JobItem_SnapshotRequestedStateChanged);
    934           item.Value.JobStateChanged -= new EventHandler(JobItem_JobStateChanged);
     839          DeregisterJobItemEvents(item.Value);
    935840        }
    936841      }
    937842      if (e.Items != null) {
    938843        foreach (var item in e.Items) {
    939           item.Value.JobStateChanged += new EventHandler(JobItem_JobStateChanged);
    940           item.Value.SnapshotRequestedStateChanged += new EventHandler(JobItem_SnapshotRequestedStateChanged);
    941         }
    942       }
     844          RegisterJobItemEvents(item.Value);
     845        }
     846      }
     847    }
     848
     849    private void RegisterJobItemEvents(JobItem jobItem) {
     850      jobItem.SnapshotRequestedStateChanged += new EventHandler(JobItem_SnapshotRequestedStateChanged);
     851      jobItem.JobStateChanged += new EventHandler(JobItem_JobStateChanged);
     852    }
     853
     854    private void DeregisterJobItemEvents(JobItem jobItem) {
     855      jobItem.SnapshotRequestedStateChanged -= new EventHandler(JobItem_SnapshotRequestedStateChanged);
     856      jobItem.JobStateChanged -= new EventHandler(JobItem_JobStateChanged);
    943857    }
    944858
     
    958872    }
    959873    #endregion
     874
     875    #region Helper Functions
     876    private IExecutionEngineFacade GetExecutionEngineFacade() {
     877      IExecutionEngineFacade executionEngineFacade = null;
     878      do {
     879        try {
     880          executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(ServerUrl);
     881        } catch (EndpointNotFoundException exception) {
     882          LogMessage("Could not connect to Server: " + exception.Message + ". Will try again in " + (resultPollingIntervalMs / 1000) + " sec.");
     883          Thread.Sleep(resultPollingIntervalMs);
     884        }
     885      } while (executionEngineFacade == null && this.ExecutionState != Core.ExecutionState.Stopped);
     886      return executionEngineFacade;
     887    }
     888
     889
     890    private void AddRange(IDictionary<IOptimizer, IOptimizer> optimizers, IDictionary<IOptimizer, IOptimizer> childs) {
     891      foreach (KeyValuePair<IOptimizer, IOptimizer> kvp in childs) {
     892        optimizers.Add(kvp);
     893      }
     894    }
     895
     896    #endregion
     897
     898    #region Logging
     899    private void LogMessage(string message) {
     900      // HeuristicLab.Log is not Thread-Safe, so lock on every call
     901      lock (locker) {
     902        log.LogMessage(message);
     903      }
     904    }
     905
     906    private void LogMessage(Guid jobId, string message) {
     907      GetJobItemById(jobId).LogMessage(message);
     908      LogMessage(message + " (jobId: " + jobId + ")");
     909    }
     910
     911    #endregion
    960912  }
    961913}
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/JobItem.cs

    r4170 r4173  
    155155    public event EventHandler JobStateChanged;
    156156    private void OnJobStateChanged() {
    157       LogMessage("JobStateChanged");
     157      LogMessage("JobStateChanged (State: " + this.State + ", Percentage: " + this.Percentage + ")");
    158158      EventHandler handler = JobStateChanged;
    159159      if (handler != null) handler(this, EventArgs.Empty);
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/ClientCommunicator.cs

    r4170 r4173  
    349349          response.Success = false;
    350350          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
    351           Logger.Error("There is no job calculated by this user " + hbData.ClientId);
     351
     352          foreach (Guid jobId in hbData.JobProgress.Keys) {
     353            response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, jobId));
     354          }
     355
     356          Logger.Error("There is no job calculated by this user " + hbData.ClientId + ", advise him to abort all");
    352357          return;
    353358        }
     
    359364            response.Success = false;
    360365            response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
     366            response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
    361367            Logger.Error("There is no job calculated by this user " + hbData.ClientId + " Job: " + curJob);
    362368          } else if (curJob.State == State.Abort) {
     
    524530        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID;
    525531        response.JobId = jobId;
    526 
    527532        Logger.Error("No job with Id " + jobId);
    528533
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/JobManager.cs

    r4170 r4173  
    235235    // [chn] [refactor] why does this method handle 3 different cases? wouldn't 3 methods be easier?
    236236    //Requested means: there MUST be a job result which gets sent back
     237    // requested==true: resultat mit job
     238    // requested==false:
    237239    public ResponseObject<SerializedJob> GetLastSerializedJobResultOf(Guid jobId, bool requested, bool snapshot) {
    238240      ResponseObject<SerializedJob> response = new ResponseObject<SerializedJob>();
Note: See TracChangeset for help on using the changeset viewer.