Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs @ 768

Last change on this file since 768 was 768, checked in by kgrading, 16 years ago

Implemented the Execution Engine, modified some parts of the JobBase (#358)

File size: 2.8 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.Linq;
25using System.Text;
26using HeuristicLab.Hive.Client.ExecutionEngine;
27using HeuristicLab.Hive.Client.Common;
28using System.Threading;
29
30
31namespace HeuristicLab.Hive.Client.Core {
32  public class Core {
33
34    Dictionary<long, Executor> engines = new Dictionary<long, Executor>();
35   
36    public void Start() {
37      Logging.getInstance().Info(this.ToString(), "Info Message");
38      //Logging.getInstance().Error(this.ToString(), "Error Message");
39      //Logging.getInstance().Error(this.ToString(), "Exception Message", new Exception("Exception"));     
40
41      Heartbeat beat = new Heartbeat();
42      beat.Interval = 5000;
43      beat.StartHeartbeat();
44
45      MessageQueue queue = MessageQueue.GetInstance();
46     
47      JobBase job = new TestJob();
48     
49      ExecutionEngine.Executor engine = new ExecutionEngine.Executor();
50      engine.Job = job;
51      engine.JobId = 1L;
52      engine.Queue = queue;     
53      engine.Start();
54      engines.Add(engine.JobId, engine);
55
56      Thread.Sleep(15000);
57      engine.RequestSnapshot();
58      while (true) {
59        MessageContainer container = queue.GetMessage();
60        Logging.getInstance().Info(this.ToString(), container.Message.ToString());
61        DetermineAction(container);
62
63       
64      }
65    }
66
67    private void DetermineAction(MessageContainer container) {
68      if(container.Message == MessageContainer.MessageType.AbortJob)
69        engines[container.JobId].Abort();
70      else if (container.Message == MessageContainer.MessageType.JobAborted)
71        //kill appdomain
72        Console.WriteLine("tmp");
73      else if (container.Message == MessageContainer.MessageType.RequestSnapshot)
74        engines[container.JobId].RequestSnapshot();
75      else if (container.Message == MessageContainer.MessageType.SnapshotReady)
76        // must be async!
77        engines[container.JobId].GetSnapshot();
78    }       
79  }
80}
Note: See TracBrowser for help on using the repository browser.