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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Text;
|
---|
25 | using HeuristicLab.Core;
|
---|
26 | using System.Threading;
|
---|
27 | using HeuristicLab.Hive.JobBase;
|
---|
28 | using HeuristicLab.Hive.Contracts.Interfaces;
|
---|
29 | using HeuristicLab.Hive.Contracts;
|
---|
30 |
|
---|
31 | namespace HeuristicLab.Hive.Engine {
|
---|
32 | /// <summary>
|
---|
33 | /// Represents an engine that executes its operator-graph on the hive.
|
---|
34 | /// in parallel.
|
---|
35 | /// </summary>
|
---|
36 | public class HiveEngine : ItemBase, IEngine, IEditable {
|
---|
37 | private Job job;
|
---|
38 | public string HiveServerUrl { get; set; }
|
---|
39 |
|
---|
40 | public HiveEngine() {
|
---|
41 | job = new Job();
|
---|
42 | }
|
---|
43 |
|
---|
44 |
|
---|
45 | #region IEngine Members
|
---|
46 |
|
---|
47 | public IOperatorGraph OperatorGraph {
|
---|
48 | get { return job.Engine.OperatorGraph; }
|
---|
49 | }
|
---|
50 |
|
---|
51 | public IScope GlobalScope {
|
---|
52 | get { return job.Engine.GlobalScope; }
|
---|
53 | }
|
---|
54 |
|
---|
55 | public TimeSpan ExecutionTime {
|
---|
56 | get { return job.Engine.ExecutionTime; }
|
---|
57 | }
|
---|
58 |
|
---|
59 | public bool Running {
|
---|
60 | get { return job.Engine.Running; }
|
---|
61 | }
|
---|
62 |
|
---|
63 | public bool Canceled {
|
---|
64 | get { return job.Engine.Canceled; }
|
---|
65 | }
|
---|
66 |
|
---|
67 | public bool Terminated {
|
---|
68 | get { return job.Engine.Terminated; }
|
---|
69 | }
|
---|
70 |
|
---|
71 | public void Execute() {
|
---|
72 | IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(HiveServerUrl);
|
---|
73 | HeuristicLab.Hive.Contracts.BusinessObjects.Job jobObj = new HeuristicLab.Hive.Contracts.BusinessObjects.Job();
|
---|
74 | jobObj.SerializedJob = PersistenceManager.SaveToGZip(job);
|
---|
75 | jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline;
|
---|
76 | ResponseObject<Contracts.BusinessObjects.Job> res = executionEngineFacade.AddJob(jobObj);
|
---|
77 | }
|
---|
78 |
|
---|
79 | public void ExecuteStep() {
|
---|
80 | throw new NotSupportedException();
|
---|
81 | }
|
---|
82 |
|
---|
83 | public void ExecuteSteps(int steps) {
|
---|
84 | throw new NotSupportedException();
|
---|
85 | }
|
---|
86 |
|
---|
87 | public void Abort() {
|
---|
88 | throw new NotImplementedException();
|
---|
89 | }
|
---|
90 |
|
---|
91 | public void Reset() {
|
---|
92 | throw new NotImplementedException();
|
---|
93 | }
|
---|
94 |
|
---|
95 | public event EventHandler Initialized;
|
---|
96 |
|
---|
97 | public event EventHandler<OperationEventArgs> OperationExecuted;
|
---|
98 |
|
---|
99 | public event EventHandler<ExceptionEventArgs> ExceptionOccurred;
|
---|
100 |
|
---|
101 | public event EventHandler ExecutionTimeChanged;
|
---|
102 |
|
---|
103 | public event EventHandler Finished;
|
---|
104 |
|
---|
105 | #endregion
|
---|
106 |
|
---|
107 | public void RequestSnapshot() {
|
---|
108 | throw new NotImplementedException();
|
---|
109 | }
|
---|
110 |
|
---|
111 | public override IView CreateView() {
|
---|
112 | return new HiveEngineEditor(this);
|
---|
113 | }
|
---|
114 |
|
---|
115 | #region IEditable Members
|
---|
116 |
|
---|
117 | public IEditor CreateEditor() {
|
---|
118 | return new HiveEngineEditor(this);
|
---|
119 | }
|
---|
120 | #endregion
|
---|
121 | }
|
---|
122 | }
|
---|