Changeset 2050


Ignore:
Timestamp:
06/16/09 11:15:34 (12 years ago)
Author:
gkronber
Message:

trivial refactoring of CEDMA server and server form. #644

Location:
trunk/sources/HeuristicLab.CEDMA.Server/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/Server.cs

    r1529 r2050  
    3333namespace HeuristicLab.CEDMA.Server {
    3434  public class Server {
     35    private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3";
     36    private static readonly string rdfConnectionString = "sqlite:rdf:Data Source=\"" + rdfFile + "\"";
     37
    3538    private ServiceHost host;
    36     private IStore store;
     39    private Store store;
     40    private IDispatcher dispatcher;
     41    private IExecuter executer;
    3742
    3843    private string gridServiceUrl;
    39 
    4044    public string GridServiceUrl {
    4145      get { return gridServiceUrl; }
     
    4448
    4549    private string cedmaServiceUrl;
    46 
    4750    public string CedmaServiceUrl {
    4851      get { return cedmaServiceUrl; }
     
    5053    }
    5154
    52     public Server(IStore store) {
     55    private int maxActiveJobs;
     56    public int MaxActiveJobs {
     57      get { return maxActiveJobs; }
     58      set {
     59        if (value > 0 && value <= 64) {
     60          maxActiveJobs = value;
     61        }
     62      }
     63    }
     64
     65    public Server() {
    5366      IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName());
    5467      // windows XP returns the external ip on index 0 while windows vista returns the external ip as one of the last entries
     
    6174      }
    6275      cedmaServiceUrl = "net.tcp://" + addresses[index] + ":8002/CEDMA";
    63       this.store = store;
     76      store = new Store(rdfConnectionString);
     77      maxActiveJobs = 10;
    6478    }
    6579
     
    8397      }
    8498    }
     99
     100    internal string[] GetActiveJobDescriptions() {
     101      if (executer != null) return executer.GetJobs();
     102      else return new string[] { };
     103    }
     104
     105    internal void Connect(string serverUrl) {
     106      dispatcher = new SimpleDispatcher(store);
     107      if (serverUrl.Contains("ExecutionEngine")) {
     108        executer = new HiveExecuter(dispatcher, store, serverUrl);
     109      } else {
     110        // default is grid backend
     111        executer = new GridExecuter(dispatcher, store, serverUrl);
     112      }
     113      executer.Start();
     114    }
    85115  }
    86116}
  • trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerForm.cs

    r1898 r2050  
    4343  public partial class ServerForm : Form {
    4444    private Server server;
    45     private Store store;
    46     private IDispatcher dispatcher;
    47     private IExecuter executer;
    4845
    49     private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3";
    50     private static readonly string rdfConnectionString = "sqlite:rdf:Data Source=\"" + rdfFile + "\"";
    5146
    5247    public ServerForm() {
    5348      InitializeComponent();
    54       store = new Store(rdfConnectionString);
    55       server = new Server(store);
     49      server = new Server();
    5650      server.Start();
    5751      addressTextBox.Text = server.CedmaServiceUrl;
     
    5953
    6054    private void refreshTimer_Tick(object sender, EventArgs e) {
    61       listBox.DataSource = executer.GetJobs();
     55      listBox.DataSource = server.GetActiveJobDescriptions();
    6256    }
    6357
    6458    private void connectButton_Click(object sender, EventArgs e) {
    65       dispatcher = new SimpleDispatcher(store);
    66       if (address.Text.Contains("ExecutionEngine")) {
    67         executer = new HiveExecuter(dispatcher, store, address.Text);
    68       } else {
    69         // default is grid backend
    70         executer = new GridExecuter(dispatcher, store, address.Text);
    71       }
    72       executer.Start();
     59      server.Connect(address.Text);
    7360      maxActiveJobsUpDown.Enabled = true;
    74       maxActiveJobsUpDown.Value = executer.MaxActiveJobs;
     61      maxActiveJobsUpDown.Value = server.MaxActiveJobs;
    7562      connectButton.Enabled = false;
    7663      refreshTimer.Start();
     
    7865
    7966    private void maxActiveJobsUpDown_ValueChanged(object sender, EventArgs e) {
    80       executer.MaxActiveJobs = Convert.ToInt32(maxActiveJobsUpDown.Value);
     67      server.MaxActiveJobs = Convert.ToInt32(maxActiveJobsUpDown.Value);
    8168    }
    8269  }
Note: See TracChangeset for help on using the changeset viewer.