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 System.Windows.Forms;
|
---|
26 | using HeuristicLab.PluginInfrastructure;
|
---|
27 | using System.Net;
|
---|
28 | using System.ServiceModel;
|
---|
29 | using System.ServiceModel.Description;
|
---|
30 | using HeuristicLab.Grid;
|
---|
31 | using HeuristicLab.Grid.HiveBridge;
|
---|
32 | using HeuristicLab.Core;
|
---|
33 | using HeuristicLab.Modeling.Database;
|
---|
34 | using HeuristicLab.Modeling.Database.SQLServerCompact;
|
---|
35 |
|
---|
36 | namespace HeuristicLab.CEDMA.Server {
|
---|
37 | public class Server : IViewable {
|
---|
38 | private static readonly string sqlServerCompactFile = AppDomain.CurrentDomain.BaseDirectory + "HeuristicLab.Modeling.database.sdf";
|
---|
39 | private static readonly string sqlServerCompactConnectionString = @"Data Source=" + sqlServerCompactFile;
|
---|
40 |
|
---|
41 | private DatabaseService database;
|
---|
42 | private IDispatcher dispatcher;
|
---|
43 | public IDispatcher Dispatcher { get { return dispatcher; } }
|
---|
44 | private IExecuter executer;
|
---|
45 | public IExecuter Executer { get { return executer; } }
|
---|
46 | private Problem problem;
|
---|
47 | public Problem Problem { get { return problem; } }
|
---|
48 |
|
---|
49 | private string gridServiceUrl;
|
---|
50 | public string GridServiceUrl {
|
---|
51 | get { return gridServiceUrl; }
|
---|
52 | set { gridServiceUrl = value; }
|
---|
53 | }
|
---|
54 |
|
---|
55 | public Server() {
|
---|
56 | database = new DatabaseService(sqlServerCompactConnectionString);
|
---|
57 | problem = new Problem();
|
---|
58 | try {
|
---|
59 | problem.Dataset = database.GetDataset();
|
---|
60 | }
|
---|
61 | catch (InvalidOperationException ex) {
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | internal void Connect(string serverUrl) {
|
---|
66 | dispatcher = new SimpleDispatcher(database, problem);
|
---|
67 | IGridServer gridServer = null;
|
---|
68 | if (serverUrl.Contains("ExecutionEngine")) {
|
---|
69 | gridServer = new HiveGridServerWrapper(serverUrl);
|
---|
70 | } else {
|
---|
71 | // default is grid backend
|
---|
72 | gridServer = new GridServerProxy(serverUrl);
|
---|
73 | }
|
---|
74 | executer = new GridExecuter(dispatcher, gridServer, database);
|
---|
75 | executer.Start();
|
---|
76 | }
|
---|
77 | #region IViewable Members
|
---|
78 |
|
---|
79 | public IView CreateView() {
|
---|
80 | return new ServerView(this);
|
---|
81 | }
|
---|
82 | #endregion
|
---|
83 | }
|
---|
84 | }
|
---|