Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/08/09 12:48:18 (15 years ago)
Author:
gkronber
Message:

Merged change sets from CEDMA branch to trunk:

File:
1 edited

Legend:

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

    r556 r1287  
    4242namespace HeuristicLab.CEDMA.Server {
    4343  public partial class ServerForm : Form {
    44     private ServiceHost host;
    45     private ServiceHost rdfHost;
    46     private Database database;
     44    private Server server;
    4745    private Store store;
    48     private static readonly string dbFile = AppDomain.CurrentDomain.BaseDirectory + "/test.db3";
    49     private static readonly string connectionString = "Data Source=\"" + dbFile + "\";Pooling=False";
     46    private IDispatcher dispatcher;
     47    private Executer executer;
     48
    5049    private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3";
    5150    private static readonly string rdfConnectionString = "sqlite:rdf:Data Source=\"" + rdfFile + "\"";
     51
    5252    public ServerForm() {
    5353      InitializeComponent();
    54       // windows XP returns the external ip on index 0 while windows vista returns the external ip on index 2
    55       if(System.Environment.OSVersion.Version.Major >= 6) {
    56         addressTextBox.Text = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[2] + ":8002/CEDMA/World";
    57       } else {
    58         addressTextBox.Text = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[0] + ":8002/CEDMA/World";
    59       }
     54      store = new Store(rdfConnectionString);
     55      server = new Server(store);
     56      server.Start();
     57      addressTextBox.Text = server.CedmaServiceUrl;
    6058    }
    6159
    62     private void InitRunScheduler() {
    63       JobManager jobManager = new JobManager(gridAddress.Text);
    64       jobManager.Reset();
    65       RunScheduler scheduler = new RunScheduler(database, jobManager, addressTextBox.Text);
    66       Thread runSchedulerThread = new Thread(scheduler.Run);
    67       runSchedulerThread.Start();
     60    private void refreshTimer_Tick(object sender, EventArgs e) {
     61      listBox.DataSource = executer.GetJobs();
    6862    }
    6963
    70     private void InitDatabase() {
    71       DbProviderFactory fact;
    72       fact = DbProviderFactories.GetFactory("System.Data.SQLite");
    73       if(!System.IO.File.Exists(dbFile)) {
    74         database = new Database(connectionString);
    75         database.CreateNew();
    76       } else {
    77         database = new Database(connectionString);
    78       }
     64    private void connectButton_Click(object sender, EventArgs e) {
     65      dispatcher = new RandomDispatcher(store);
     66      executer = new Executer(dispatcher, store, gridAddress.Text);
     67      executer.Start();
     68      maxActiveJobsUpDown.Enabled = true;
     69      maxActiveJobsUpDown.Value = executer.MaxActiveJobs;
     70      connectButton.Enabled = false;
     71      refreshTimer.Start();
    7972    }
    8073
    81     private void InitRdfStore() {
    82       store = new Store(rdfConnectionString);
    83     }
    84 
    85     private void Start() {
    86       InitDatabase();
    87       InitRdfStore();
    88       InitRunScheduler();
    89 
    90       host = new ServiceHost(database, new Uri(addressTextBox.Text));
    91       rdfHost = new ServiceHost(store, new Uri(addressTextBox.Text+"/RdfStore"));
    92       ServiceThrottlingBehavior throttlingBehavior = new ServiceThrottlingBehavior();
    93       throttlingBehavior.MaxConcurrentSessions = 20;
    94       host.Description.Behaviors.Add(throttlingBehavior);
    95       rdfHost.Description.Behaviors.Add(throttlingBehavior);
    96       try {
    97         NetTcpBinding binding = new NetTcpBinding();
    98         binding.MaxReceivedMessageSize = 100000000; // 100Mbytes
    99         binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars
    100         binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements;
    101         binding.Security.Mode = SecurityMode.None;
    102 
    103         host.AddServiceEndpoint(typeof(IDatabase), binding, addressTextBox.Text);
    104         host.Open();
    105         rdfHost.AddServiceEndpoint(typeof(IStore), binding, addressTextBox.Text+"/RdfStore");
    106         rdfHost.Open();
    107       } catch(CommunicationException ex) {
    108         MessageBox.Show("An exception occurred: " + ex.Message);
    109         host.Abort();
    110         rdfHost.Abort();
    111       }
    112     }
    113 
    114     private void startButton_Click(object sender, EventArgs e) {
    115       Start();
    116       startButton.Enabled = false;
     74    private void maxActiveJobsUpDown_ValueChanged(object sender, EventArgs e) {
     75      executer.MaxActiveJobs = Convert.ToInt32(maxActiveJobsUpDown.Value);
    11776    }
    11877  }
Note: See TracChangeset for help on using the changeset viewer.