Index: unk/sources/HeuristicLab.CEDMA.Server/3.3/Executer.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/Executer.cs	(revision 1897)
+++ 	(revision )
@@ -1,184 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Windows.Forms;
-using HeuristicLab.PluginInfrastructure;
-using System.Net;
-using System.ServiceModel;
-using HeuristicLab.CEDMA.DB.Interfaces;
-using HeuristicLab.CEDMA.DB;
-using System.ServiceModel.Description;
-using System.Linq;
-using HeuristicLab.CEDMA.Core;
-using HeuristicLab.GP.StructureIdentification;
-using HeuristicLab.Data;
-using HeuristicLab.Grid;
-using System.Diagnostics;
-using HeuristicLab.Core;
-using System.Threading;
-
-namespace HeuristicLab.CEDMA.Server {
-  public class Executer {
-    private IDispatcher dispatcher;
-    private JobManager jobManager;
-    private IStore store;
-    private Dictionary<WaitHandle, Execution> activeExecutions;
-
-    private TimeSpan StartJobInterval {
-      get { return TimeSpan.FromMilliseconds(500); }
-    }
-
-    private TimeSpan WaitForFinishedJobsTimeout {
-      get { return TimeSpan.FromMilliseconds(100); }
-    }
-
-    private int maxActiveJobs;
-    public int MaxActiveJobs {
-      get { return maxActiveJobs; }
-      set {
-        if (value < 0) throw new ArgumentException("Only positive values are allowed for MaxActiveJobs");
-        maxActiveJobs = value;
-      }
-    }
-
-    public Executer(IDispatcher dispatcher, IStore store, string gridUrl) {
-      activeExecutions = new Dictionary<WaitHandle, Execution>();
-      maxActiveJobs = 10;
-      this.dispatcher = dispatcher;
-      this.store = store;
-      this.jobManager = new JobManager(gridUrl);
-      jobManager.Reset();
-    }
-
-    internal void Start() {
-      new Thread(StartJobs).Start();
-    }
-
-    private void StartJobs() {
-      List<WaitHandle> wh = new List<WaitHandle>();
-      Dictionary<WaitHandle, AtomicOperation> activeOperations = new Dictionary<WaitHandle, AtomicOperation>();
-      while (true) {
-        try {
-          // start new jobs as long as there are less than MaxActiveJobs 
-          while (wh.Count < MaxActiveJobs) {
-            Thread.Sleep(StartJobInterval);
-            // get an execution from the dispatcher and execute in grid via job-manager
-            Execution execution = dispatcher.GetNextJob();
-            if (execution != null) {
-              AtomicOperation op = new AtomicOperation(execution.Engine.OperatorGraph.InitialOperator, execution.Engine.GlobalScope);
-              WaitHandle opWh = jobManager.BeginExecuteOperation(execution.Engine.GlobalScope, op);
-              wh.Add(opWh);
-              activeOperations.Add(opWh, op);
-              lock (activeExecutions) {
-                activeExecutions.Add(opWh, execution);
-              }
-            }
-          }
-          // wait until any job is finished
-          WaitHandle[] whArr = wh.ToArray();
-          int readyHandleIndex = WaitHandle.WaitAny(whArr, WaitForFinishedJobsTimeout);
-          if (readyHandleIndex != WaitHandle.WaitTimeout) {
-            WaitHandle readyHandle = whArr[readyHandleIndex];
-            AtomicOperation finishedOp = activeOperations[readyHandle];
-            wh.Remove(readyHandle);
-            Execution finishedExecution = null;
-            lock (activeExecutions) {
-              finishedExecution = activeExecutions[readyHandle];
-              activeExecutions.Remove(readyHandle);
-            }
-            activeOperations.Remove(readyHandle);
-            ProcessingEngine finishedEngine = null;
-            try {
-              finishedEngine = jobManager.EndExecuteOperation(finishedOp);
-            }
-            catch (Exception badEx) {
-              Trace.WriteLine("CEDMA Executer: Exception in job execution thread. " + badEx.Message);
-            }
-            if (finishedEngine != null) {
-              StoreResults(finishedExecution, finishedEngine);
-            }
-          }
-        }
-        catch (Exception ex) {
-          Trace.WriteLine("CEDMA Executer: Exception in job-management thread. " + ex.Message);
-        }
-      }
-    }
-
-    private void StoreResults(Execution finishedExecution, ProcessingEngine finishedEngine) {
-      Entity model = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid());
-      store.Add(new Statement(finishedExecution.DataSetEntity, Ontology.PredicateHasModel, model));
-      StoreModelAttribute(model, Ontology.TargetVariable, finishedExecution.TargetVariable);
-      StoreModelAttribute(model, Ontology.AlgorithmName, finishedExecution.Description);
-      Scope bestModelScope = finishedEngine.GlobalScope.GetVariableValue<Scope>("BestValidationSolution", false);
-      StoreModelVariable(model, Ontology.TrainingMeanSquaredError, bestModelScope, "Quality");
-      StoreModelVariable(model, Ontology.ValidationMeanSquaredError, bestModelScope, "ValidationQuality");
-      StoreModelVariable(model, Ontology.TestMeanSquaredError, bestModelScope, "TestQuality");
-      StoreModelVariable(model, Ontology.TrainingMeanAbsolutePercentageError, bestModelScope, "TrainingMAPE");
-      StoreModelVariable(model, Ontology.ValidationMeanAbsolutePercentageError, bestModelScope, "ValidationMAPE");
-      StoreModelVariable(model, Ontology.TestMeanAbsolutePercentageError, bestModelScope, "TestMAPE");
-      StoreModelVariable(model, Ontology.TrainingMeanAbsolutePercentageOfRangeError, bestModelScope, "TrainingMAPRE");
-      StoreModelVariable(model, Ontology.ValidationMeanAbsolutePercentageOfRangeError, bestModelScope, "ValidationMAPRE");
-      StoreModelVariable(model, Ontology.TestMeanAbsolutePercentageOfRangeError, bestModelScope, "TestMAPRE");
-      StoreModelVariable(model, Ontology.TrainingCoefficientOfDetermination, bestModelScope, "TrainingR2");
-      StoreModelVariable(model, Ontology.ValidationCoefficientOfDetermination, bestModelScope, "ValidationR2");
-      StoreModelVariable(model, Ontology.TestCoefficientOfDetermination, bestModelScope, "TestR2");
-      StoreModelVariable(model, Ontology.TrainingCoefficientOfDetermination, bestModelScope, "TrainingVAF");
-      StoreModelVariable(model, Ontology.ValidationCoefficientOfDetermination, bestModelScope, "ValidationVAF");
-      StoreModelVariable(model, Ontology.TestCoefficientOfDetermination, bestModelScope, "TestVAF");
-      StoreModelVariable(model, Ontology.TrainingTheilsInequalityCoefficient, bestModelScope, "TrainingTheilInequalityCoefficient");
-      StoreModelVariable(model, Ontology.ValidationTheilsInequalityCoefficient, bestModelScope, "ValidationTheilInequalityCoefficient");
-      StoreModelVariable(model, Ontology.TestTheilsInequalityCoefficient, bestModelScope, "TestTheilInequalityCoefficient");
-      StoreModelVariable(model, Ontology.TrainingAccuracy, bestModelScope, "TrainingAccuracy");
-      StoreModelVariable(model, Ontology.ValidationAccuracy, bestModelScope, "ValidationAccuracy");
-      StoreModelVariable(model, Ontology.TestAccuracy, bestModelScope, "TestAccuracy");
-      StoreModelVariable(model, Ontology.TreeSize, bestModelScope, "TreeSize");
-      StoreModelVariable(model, Ontology.TreeHeight, bestModelScope, "TreeHeight");
-      StoreModelVariable(model, Ontology.EvaluatedSolutions, bestModelScope, "EvaluatedSolutions");
-
-      byte[] serializedModel = PersistenceManager.SaveToGZip(bestModelScope.GetVariableValue("FunctionTree", false));
-      store.Add(new Statement(model, Ontology.PredicateSerializedData, new Literal(Convert.ToBase64String(serializedModel))));
-    }
-
-    private void StoreModelVariable(Entity model, Entity entity, Scope scope, string variableName) {
-      if (scope.GetVariable(variableName) != null)
-        StoreModelAttribute(model, entity, scope.GetVariableValue<ObjectData>(variableName, false).Data);
-    }
-
-    private void StoreModelAttribute(Entity model, Entity predicate, object value) {
-      store.Add(new Statement(model, predicate, new Literal(value)));
-    }
-
-    internal string[] GetJobs() {
-      lock (activeExecutions) {
-        string[] retVal = new string[activeExecutions.Count];
-        int i = 0;
-        foreach (Execution e in activeExecutions.Values) {
-          retVal[i++] = "Target-Variable: " + e.TargetVariable + " " + e.Description;
-        }
-        return retVal;
-      }
-    }
-  }
-}
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ExecuterBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ExecuterBase.cs	(revision 1898)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ExecuterBase.cs	(revision 1898)
@@ -0,0 +1,116 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using System.ServiceModel;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.CEDMA.DB;
+using System.ServiceModel.Description;
+using System.Linq;
+using HeuristicLab.CEDMA.Core;
+using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.Data;
+using HeuristicLab.Grid;
+using System.Diagnostics;
+using HeuristicLab.Core;
+using System.Threading;
+
+namespace HeuristicLab.CEDMA.Server {
+  public abstract class ExecuterBase : IExecuter {
+    private IDispatcher dispatcher;
+    protected IDispatcher Dispatcher {
+      get { return dispatcher; }
+    }
+    private IStore store;
+
+    private int maxActiveJobs;
+    public int MaxActiveJobs {
+      get { return maxActiveJobs; }
+      set {
+        if (value < 0) throw new ArgumentException("Only positive values are allowed for MaxActiveJobs");
+        maxActiveJobs = value;
+      }
+    }
+
+    public ExecuterBase(IDispatcher dispatcher, IStore store) {
+      maxActiveJobs = 10;
+      this.dispatcher = dispatcher;
+      this.store = store;
+    }
+
+    public void Start() {
+      new Thread(StartJobs).Start();
+    }
+
+    protected abstract void StartJobs();
+
+    protected void StoreResults(Execution finishedExecution, IEngine finishedEngine) {
+      Entity model = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid());
+      store.Add(new Statement(finishedExecution.DataSetEntity, Ontology.PredicateHasModel, model));
+      StoreModelAttribute(model, Ontology.TargetVariable, finishedExecution.TargetVariable);
+      StoreModelAttribute(model, Ontology.AlgorithmName, finishedExecution.Description);
+      Scope bestModelScope = finishedEngine.GlobalScope.GetVariableValue<Scope>("BestValidationSolution", false);
+      StoreModelVariable(model, Ontology.TrainingMeanSquaredError, bestModelScope, "Quality");
+      StoreModelVariable(model, Ontology.ValidationMeanSquaredError, bestModelScope, "ValidationQuality");
+      StoreModelVariable(model, Ontology.TestMeanSquaredError, bestModelScope, "TestQuality");
+      StoreModelVariable(model, Ontology.TrainingMeanAbsolutePercentageError, bestModelScope, "TrainingMAPE");
+      StoreModelVariable(model, Ontology.ValidationMeanAbsolutePercentageError, bestModelScope, "ValidationMAPE");
+      StoreModelVariable(model, Ontology.TestMeanAbsolutePercentageError, bestModelScope, "TestMAPE");
+      StoreModelVariable(model, Ontology.TrainingMeanAbsolutePercentageOfRangeError, bestModelScope, "TrainingMAPRE");
+      StoreModelVariable(model, Ontology.ValidationMeanAbsolutePercentageOfRangeError, bestModelScope, "ValidationMAPRE");
+      StoreModelVariable(model, Ontology.TestMeanAbsolutePercentageOfRangeError, bestModelScope, "TestMAPRE");
+      StoreModelVariable(model, Ontology.TrainingCoefficientOfDetermination, bestModelScope, "TrainingR2");
+      StoreModelVariable(model, Ontology.ValidationCoefficientOfDetermination, bestModelScope, "ValidationR2");
+      StoreModelVariable(model, Ontology.TestCoefficientOfDetermination, bestModelScope, "TestR2");
+      StoreModelVariable(model, Ontology.TrainingCoefficientOfDetermination, bestModelScope, "TrainingVAF");
+      StoreModelVariable(model, Ontology.ValidationCoefficientOfDetermination, bestModelScope, "ValidationVAF");
+      StoreModelVariable(model, Ontology.TestCoefficientOfDetermination, bestModelScope, "TestVAF");
+      StoreModelVariable(model, Ontology.TrainingTheilsInequalityCoefficient, bestModelScope, "TrainingTheilInequalityCoefficient");
+      StoreModelVariable(model, Ontology.ValidationTheilsInequalityCoefficient, bestModelScope, "ValidationTheilInequalityCoefficient");
+      StoreModelVariable(model, Ontology.TestTheilsInequalityCoefficient, bestModelScope, "TestTheilInequalityCoefficient");
+      StoreModelVariable(model, Ontology.TrainingAccuracy, bestModelScope, "TrainingAccuracy");
+      StoreModelVariable(model, Ontology.ValidationAccuracy, bestModelScope, "ValidationAccuracy");
+      StoreModelVariable(model, Ontology.TestAccuracy, bestModelScope, "TestAccuracy");
+      StoreModelVariable(model, Ontology.TreeSize, bestModelScope, "TreeSize");
+      StoreModelVariable(model, Ontology.TreeHeight, bestModelScope, "TreeHeight");
+      StoreModelVariable(model, Ontology.EvaluatedSolutions, bestModelScope, "EvaluatedSolutions");
+
+      byte[] serializedModel = PersistenceManager.SaveToGZip(bestModelScope.GetVariableValue("FunctionTree", false));
+      store.Add(new Statement(model, Ontology.PredicateSerializedData, new Literal(Convert.ToBase64String(serializedModel))));
+    }
+
+    private void StoreModelVariable(Entity model, Entity entity, Scope scope, string variableName) {
+      if (scope.GetVariable(variableName) != null)
+        StoreModelAttribute(model, entity, scope.GetVariableValue<ObjectData>(variableName, false).Data);
+    }
+
+    private void StoreModelAttribute(Entity model, Entity predicate, object value) {
+      store.Add(new Statement(model, predicate, new Literal(value)));
+    }
+
+    public abstract string[] GetJobs();
+  }
+}
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/GridExecuter.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/GridExecuter.cs	(revision 1898)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/GridExecuter.cs	(revision 1898)
@@ -0,0 +1,122 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using System.ServiceModel;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.CEDMA.DB;
+using System.ServiceModel.Description;
+using System.Linq;
+using HeuristicLab.CEDMA.Core;
+using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.Data;
+using HeuristicLab.Grid;
+using System.Diagnostics;
+using HeuristicLab.Core;
+using System.Threading;
+
+namespace HeuristicLab.CEDMA.Server {
+  public class GridExecuter : ExecuterBase {
+    private JobManager jobManager;
+    private Dictionary<WaitHandle, Execution> activeExecutions;
+
+    private TimeSpan StartJobInterval {
+      get { return TimeSpan.FromMilliseconds(500); }
+    }
+
+    private TimeSpan WaitForFinishedJobsTimeout {
+      get { return TimeSpan.FromMilliseconds(100); }
+    }
+
+    public GridExecuter(IDispatcher dispatcher, IStore store, string gridUrl) : base(dispatcher, store) {
+      this.jobManager = new JobManager(gridUrl);
+      jobManager.Reset();
+    }
+
+    protected override void StartJobs() {
+      List<WaitHandle> wh = new List<WaitHandle>();
+      Dictionary<WaitHandle, AtomicOperation> activeOperations = new Dictionary<WaitHandle, AtomicOperation>();
+      while (true) {
+        try {
+          // start new jobs as long as there are less than MaxActiveJobs 
+          while (wh.Count < MaxActiveJobs) {
+            Thread.Sleep(StartJobInterval);
+            // get an execution from the dispatcher and execute in grid via job-manager
+            Execution execution = Dispatcher.GetNextJob();
+            if (execution != null) {
+              AtomicOperation op = new AtomicOperation(execution.Engine.OperatorGraph.InitialOperator, execution.Engine.GlobalScope);
+              WaitHandle opWh = jobManager.BeginExecuteOperation(execution.Engine.GlobalScope, op);
+              wh.Add(opWh);
+              activeOperations.Add(opWh, op);
+              lock (activeExecutions) {
+                activeExecutions.Add(opWh, execution);
+              }
+            }
+          }
+          // wait until any job is finished
+          WaitHandle[] whArr = wh.ToArray();
+          int readyHandleIndex = WaitHandle.WaitAny(whArr, WaitForFinishedJobsTimeout);
+          if (readyHandleIndex != WaitHandle.WaitTimeout) {
+            WaitHandle readyHandle = whArr[readyHandleIndex];
+            AtomicOperation finishedOp = activeOperations[readyHandle];
+            wh.Remove(readyHandle);
+            Execution finishedExecution = null;
+            lock (activeExecutions) {
+              finishedExecution = activeExecutions[readyHandle];
+              activeExecutions.Remove(readyHandle);
+            }
+            activeOperations.Remove(readyHandle);
+            readyHandle.Close();
+            ProcessingEngine finishedEngine = null;
+            try {
+              finishedEngine = jobManager.EndExecuteOperation(finishedOp);
+            }
+            catch (Exception badEx) {
+              Trace.WriteLine("CEDMA Executer: Exception in job execution thread. " + badEx.Message);
+            }
+            if (finishedEngine != null) {
+              StoreResults(finishedExecution, finishedEngine);
+            }
+          }
+        }
+        catch (Exception ex) {
+          Trace.WriteLine("CEDMA Executer: Exception in job-management thread. " + ex.Message);
+        }
+      }
+    }
+
+    public override string[] GetJobs() {
+      lock (activeExecutions) {
+        string[] retVal = new string[activeExecutions.Count];
+        int i = 0;
+        foreach (Execution e in activeExecutions.Values) {
+          retVal[i++] = "Target-Variable: " + e.TargetVariable + " " + e.Description;
+        }
+        return retVal;
+      }
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLab.CEDMA.Server-3.3.csproj
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLab.CEDMA.Server-3.3.csproj	(revision 1897)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/HeuristicLab.CEDMA.Server-3.3.csproj	(revision 1898)
@@ -91,8 +91,13 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="ExecuterBase.cs" />
+    <Compile Include="HiveExecuter.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="IExecuter.cs" />
     <Compile Include="DispatcherBase.cs" />
+    <Compile Include="GridExecuter.cs" />
     <Compile Include="IDispatcher.cs" />
     <Compile Include="Execution.cs" />
-    <Compile Include="Executer.cs" />
     <Compile Include="Server.cs" />
     <Compile Include="ServerApplication.cs" />
@@ -136,4 +141,8 @@
       <Name>HeuristicLab.Grid-3.2</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Hive.Engine\3.2\HeuristicLab.Hive.Engine-3.2.csproj">
+      <Project>{C8FEDAC1-0326-4293-B585-F0FEDDEDFC11}</Project>
+      <Name>HeuristicLab.Hive.Engine-3.2</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.Modeling\3.2\HeuristicLab.Modeling-3.2.csproj">
       <Project>{80F7FADA-549D-4151-8856-79B620A50DBA}</Project>
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/HiveExecuter.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/HiveExecuter.cs	(revision 1898)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/HiveExecuter.cs	(revision 1898)
@@ -0,0 +1,127 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using System.ServiceModel;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.CEDMA.DB;
+using System.ServiceModel.Description;
+using System.Linq;
+using HeuristicLab.CEDMA.Core;
+using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.Data;
+using HeuristicLab.Grid;
+using System.Diagnostics;
+using HeuristicLab.Core;
+using System.Threading;
+using HeuristicLab.Hive.Engine;
+
+namespace HeuristicLab.CEDMA.Server {
+  public class HiveExecuter : ExecuterBase {
+    private Dictionary<WaitHandle, Execution> activeExecutions;
+    private Dictionary<WaitHandle, HiveEngine> activeEngines;
+    private string hiveUrl;
+
+    private TimeSpan StartJobInterval {
+      get { return TimeSpan.FromMilliseconds(500); }
+    }
+
+    private TimeSpan WaitForFinishedJobsTimeout {
+      get { return TimeSpan.FromMilliseconds(100); }
+    }
+
+    public HiveExecuter(IDispatcher dispatcher, IStore store, string hiveUrl)
+      : base(dispatcher, store) {
+      this.hiveUrl = hiveUrl;
+      activeExecutions = new Dictionary<WaitHandle, Execution>();
+      activeEngines = new Dictionary<WaitHandle, HiveEngine>();
+    }
+
+    protected override void StartJobs() {
+      List<WaitHandle> wh = new List<WaitHandle>();
+      while (true) {
+        try {
+          // start new jobs as long as there are less than MaxActiveJobs 
+          while (wh.Count < MaxActiveJobs) {
+            Thread.Sleep(StartJobInterval);
+            // get an execution from the dispatcher and execute in grid via job-manager
+            Execution execution = Dispatcher.GetNextJob();
+            if (execution != null) {
+              HiveEngine engine = new HiveEngine();
+              engine.HiveServerUrl = hiveUrl;
+              IOperator initialOp = execution.Engine.OperatorGraph.InitialOperator;
+              engine.OperatorGraph.AddOperator(initialOp);
+              engine.OperatorGraph.InitialOperator = initialOp;
+              RegisterFinishedCallback(engine, execution, wh);
+              engine.Reset();
+              engine.Execute();
+            }
+          }
+          // wait until any job is finished
+          WaitHandle[] whArr = wh.ToArray();
+          int readyHandleIndex = WaitHandle.WaitAny(whArr, WaitForFinishedJobsTimeout);
+          if (readyHandleIndex != WaitHandle.WaitTimeout) {
+            WaitHandle readyHandle = whArr[readyHandleIndex];
+            wh.Remove(readyHandle);
+            HiveEngine finishedEngine = activeEngines[readyHandle];
+            activeEngines.Remove(readyHandle);
+
+            Execution finishedExecution = activeExecutions[readyHandle];
+            lock (activeExecutions) {
+              activeExecutions.Remove(readyHandle);
+            }
+            StoreResults(finishedExecution, finishedEngine);
+            readyHandle.Close();
+          }
+        }
+        catch (Exception ex) {
+          Trace.WriteLine("CEDMA Executer: Exception in job-management thread. " + ex.Message);
+        }
+      }
+    }
+
+    private void RegisterFinishedCallback(HiveEngine engine, Execution execution, List<WaitHandle> wh) {
+      ManualResetEvent waithandle = new ManualResetEvent(false);
+      wh.Add(waithandle);
+      engine.Finished += (sender, args) => waithandle.Set();
+      lock (activeExecutions) {
+        activeExecutions.Add(waithandle, execution);
+      }
+      activeEngines.Add(waithandle, engine);
+    }
+
+    public override string[] GetJobs() {
+      lock (activeExecutions) {
+        string[] retVal = new string[activeExecutions.Count];
+        int i = 0;
+        foreach (Execution e in activeExecutions.Values) {
+          retVal[i++] = "Target-Variable: " + e.TargetVariable + " " + e.Description;
+        }
+        return retVal;
+      }
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/IExecuter.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/IExecuter.cs	(revision 1898)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/IExecuter.cs	(revision 1898)
@@ -0,0 +1,44 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.PluginInfrastructure;
+using System.Net;
+using System.ServiceModel;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.CEDMA.DB;
+using System.ServiceModel.Description;
+using System.Linq;
+using HeuristicLab.CEDMA.Core;
+using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.Data;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.CEDMA.Server {
+  public interface IExecuter {
+    int MaxActiveJobs { get; set; }
+    string[] GetJobs();
+    void Start();
+  }
+}
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.cs	(revision 1897)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.cs	(revision 1898)
@@ -45,5 +45,5 @@
     private Store store;
     private IDispatcher dispatcher;
-    private Executer executer;
+    private IExecuter executer;
 
     private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3";
@@ -64,5 +64,10 @@
     private void connectButton_Click(object sender, EventArgs e) {
       dispatcher = new SimpleDispatcher(store);
-      executer = new Executer(dispatcher, store, gridAddress.Text);
+      if (address.Text.Contains("ExecutionEngine")) {
+        executer = new HiveExecuter(dispatcher, store, address.Text);
+      } else { 
+        // default is grid backend
+        executer = new GridExecuter(dispatcher, store, address.Text);
+      }
       executer.Start();
       maxActiveJobsUpDown.Enabled = true;
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.designer.cs	(revision 1897)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.designer.cs	(revision 1898)
@@ -49,5 +49,5 @@
       this.externalAddressLabel = new System.Windows.Forms.Label();
       this.gridAddressLabel = new System.Windows.Forms.Label();
-      this.gridAddress = new System.Windows.Forms.TextBox();
+      this.address = new System.Windows.Forms.TextBox();
       this.connectButton = new System.Windows.Forms.Button();
       this.listBox = new System.Windows.Forms.ListBox();
@@ -86,8 +86,8 @@
       // gridAddress
       // 
-      this.gridAddress.Location = new System.Drawing.Point(106, 32);
-      this.gridAddress.Name = "gridAddress";
-      this.gridAddress.Size = new System.Drawing.Size(160, 20);
-      this.gridAddress.TabIndex = 8;
+      this.address.Location = new System.Drawing.Point(106, 32);
+      this.address.Name = "gridAddress";
+      this.address.Size = new System.Drawing.Size(160, 20);
+      this.address.TabIndex = 8;
       // 
       // connectButton
@@ -151,5 +151,5 @@
       this.Controls.Add(this.connectButton);
       this.Controls.Add(this.gridAddressLabel);
-      this.Controls.Add(this.gridAddress);
+      this.Controls.Add(this.address);
       this.Controls.Add(this.externalAddressLabel);
       this.Controls.Add(this.addressTextBox);
@@ -167,5 +167,5 @@
     private System.Windows.Forms.Label externalAddressLabel;
     private System.Windows.Forms.Label gridAddressLabel;
-    private System.Windows.Forms.TextBox gridAddress;
+    private System.Windows.Forms.TextBox address;
     private System.Windows.Forms.Button connectButton;
     private System.Windows.Forms.ListBox listBox;
