source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/EngineJob.cs @ 6000

Last change on this file since 6000 was 6000, checked in by cneumuel, 9 years ago

#1233

  • added GetPlugin service method
  • fixed minor issues with double plugins in database
  • worked on HiveEngine
  • fixed wrong role name for Hive User
  • fixed bug in group assignment of slaves
File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Drawing;
4using HeuristicLab.Common;
5using HeuristicLab.Core;
6using HeuristicLab.Hive;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8
9namespace HeuristicLab.HiveEngine {
10  [StorableClass]
11  public class EngineJob : AbstractJob {
12    [Storable]
13    private IEngine engine;
14
15    [Storable]
16    protected IOperation initialOperation;
17    public IOperation InitialOperation {
18      get { return initialOperation; }
19      set { initialOperation = value; }
20    }
21
22    public override TimeSpan ExecutionTime {
23      get { return engine.ExecutionTime; }
24    }
25
26    public override ExecutionState ExecutionState {
27      get { return engine.ExecutionState; }
28    }
29
30    #region constructors and cloning
31    public EngineJob() { }
32    public EngineJob(IOperation initialOperation, IEngine engine) {
33      this.initialOperation = initialOperation;
34      this.engine = engine;
35      RegisterEngineEvents();
36    }
37
38    [StorableConstructor]
39    protected EngineJob(bool deserializing) : base(deserializing) { }
40    protected EngineJob(EngineJob original, Cloner cloner)
41      : base(original, cloner) {
42      this.engine = cloner.Clone(original.engine);
43      this.initialOperation = cloner.Clone(original.initialOperation);
44      RegisterEngineEvents();
45    }
46    public override IDeepCloneable Clone(Cloner cloner) {
47      return new EngineJob(this, cloner);
48    }
49    [StorableHook(HookType.AfterDeserialization)]
50    private void AfterDeserialization() {
51      RegisterEngineEvents();
52    }
53    #endregion
54
55    public override bool IsParallelizable {
56      get { return false; }
57    }
58
59    public override void Prepare() { }
60
61    public override void Start() {
62      engine.Prepare(initialOperation);
63      engine.Start();
64    }
65   
66    public override void Pause() {
67      engine.Pause();
68    }
69
70    public override void Stop() {
71      engine.Stop();
72    }
73   
74    public override void Resume(IEnumerable<IJob> childJobs) {
75      throw new NotImplementedException();
76    }
77
78    private void RegisterEngineEvents() {
79      engine.Stopped += new EventHandler(engine_Stopped);
80      engine.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(engine_ExceptionOccurred);
81    }
82
83    private void engine_ExceptionOccurred(object sender, EventArgs<Exception> e) {
84      OnJobFailed(e);
85    }
86
87    private void engine_Stopped(object sender, EventArgs e) {
88      OnJobStopped();
89    }
90
91    public override bool CanChangeDescription {
92      get { return false; }
93    }
94
95    public override bool CanChangeName {
96      get { return false; }
97    }
98
99    public override string Description {
100      get { return string.Empty; }
101      set { throw new NotSupportedException(); }
102    }
103
104    public override string Name {
105      get { return engine.ToString(); }
106      set { throw new NotSupportedException(); }
107    }
108
109    public override string ItemDescription {
110      get { return Description; }
111    }
112
113    public override Image ItemImage {
114      get { return HeuristicLab.Common.Resources.VSImageLibrary.Operator; }
115    }
116   
117    public override string ItemName {
118      get { return "EngineJob"; }
119    }
120
121    public override Version ItemVersion {
122      get { return null; }
123    }
124  }
125}
Note: See TracBrowser for help on using the repository browser.