Changeset 1287 for trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.cs
- Timestamp:
- 03/08/09 12:48:18 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.cs
r556 r1287 42 42 namespace HeuristicLab.CEDMA.Server { 43 43 public partial class ServerForm : Form { 44 private ServiceHost host; 45 private ServiceHost rdfHost; 46 private Database database; 44 private Server server; 47 45 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 50 49 private static readonly string rdfFile = AppDomain.CurrentDomain.BaseDirectory + "rdf_store.db3"; 51 50 private static readonly string rdfConnectionString = "sqlite:rdf:Data Source=\"" + rdfFile + "\""; 51 52 52 public ServerForm() { 53 53 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; 60 58 } 61 59 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(); 68 62 } 69 63 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(); 79 72 } 80 73 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); 117 76 } 118 77 }
Note: See TracChangeset
for help on using the changeset viewer.