Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Engine/HiveEngine.cs @ 1510

Last change on this file since 1510 was 1510, checked in by kgrading, 15 years ago

added the stubs to the HiveEngine (#571)

File size: 4.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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.Collections.Generic;
24using System.Text;
25using HeuristicLab.Core;
26using System.Threading;
27using HeuristicLab.Hive.JobBase;
28using HeuristicLab.Hive.Contracts.Interfaces;
29using HeuristicLab.Hive.Contracts;
30using HeuristicLab.PluginInfrastructure;
31
32namespace HeuristicLab.Hive.Engine {
33  /// <summary>
34  /// Represents an engine that executes its operator-graph on the hive.
35  /// in parallel.
36  /// </summary>
37  public class HiveEngine : ItemBase, IEngine, IEditable {
38    private Guid jobId;
39    private Job job;
40    public string HiveServerUrl { get; set; }
41
42    public HiveEngine() {
43      job = new Job();
44    }
45
46
47    #region IEngine Members
48
49    public IOperatorGraph OperatorGraph {
50      get { return job.Engine.OperatorGraph; }
51    }
52
53    public IScope GlobalScope {
54      get { return job.Engine.GlobalScope; }
55    }
56
57    public TimeSpan ExecutionTime {
58      get { return job.Engine.ExecutionTime; }
59    }
60
61    public bool Running {
62      get { return job.Engine.Running; }
63    }
64
65    public bool Canceled {
66      get { return job.Engine.Canceled; }
67    }
68
69    public bool Terminated {
70      get { return job.Engine.Terminated; }
71    }
72
73    public void Execute() {
74      IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(HiveServerUrl);
75     
76      DiscoveryService dService = new DiscoveryService();
77      PluginInfo depInfo = dService.GetDeclaringPlugin(typeof(HiveEngine));
78      List<PluginInfo> dependentPlugins = PluginManager.Manager.GetDependentPluginsRec(depInfo);
79
80      HeuristicLab.Hive.Contracts.BusinessObjects.Job jobObj = new HeuristicLab.Hive.Contracts.BusinessObjects.Job();
81      jobObj.SerializedJob = PersistenceManager.SaveToGZip(job);
82      jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline;
83      jobObj.PluginsNeeded = dependentPlugins;
84      ResponseObject<Contracts.BusinessObjects.Job> res = executionEngineFacade.AddJob(jobObj);
85      jobId = res.Obj.Id;
86    }
87
88    public void ExecuteStep() {
89      throw new NotSupportedException();
90    }
91
92    public void ExecuteSteps(int steps) {
93      throw new NotSupportedException();
94    }
95
96    public void Abort() {
97      IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(HiveServerUrl);
98     
99     
100      //This are just Stubs on the server right now. There won't be any effect right now...
101      executionEngineFacade.AbortJob(jobId);     
102      executionEngineFacade.RequestSnapshot(Guid);
103     
104      //Requests the last result.
105      //false: There will always be a result that is been sent back
106      //true: if you hit "requestsnapshot" before - it won't send you the job back if
107      //      the snapshot hasn't been submitted to the server (because the client needs
108      //      more time).
109      executionEngineFacade.GetLastResult(jobId, false);
110
111      throw new NotImplementedException();
112    }
113
114    public void Reset() {
115      throw new NotImplementedException();
116    }
117
118    public event EventHandler Initialized;
119
120    public event EventHandler<OperationEventArgs> OperationExecuted;
121
122    public event EventHandler<ExceptionEventArgs> ExceptionOccurred;
123
124    public event EventHandler ExecutionTimeChanged;
125
126    public event EventHandler Finished;
127
128    #endregion
129
130    public void RequestSnapshot() {
131      throw new NotImplementedException();
132    }
133
134    public override IView CreateView() {
135      return new HiveEngineEditor(this);
136    }
137
138    #region IEditable Members
139
140    public IEditor CreateEditor() {
141      return new HiveEngineEditor(this);
142    }
143    #endregion
144  }
145}
Note: See TracBrowser for help on using the repository browser.