Free cookie consent management tool by TermsFeed Policy Generator

Changeset 800


Ignore:
Timestamp:
11/20/08 17:52:05 (15 years ago)
Author:
msteinbi
Message:

Added additional WCF endpoint for the server management console - fixed #381

Location:
trunk/sources
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Contracts/HeuristicLab.Hive.Contracts.csproj

    r795 r800  
    6969    <Compile Include="Interfaces\IClientManager.cs" />
    7070    <Compile Include="Interfaces\IJobManager.cs" />
     71    <Compile Include="Interfaces\IServerConsoleFacade.cs" />
    7172    <Compile Include="Interfaces\IUserRoleManager.cs" />
    7273    <Compile Include="MessageContainer.cs" />
  • trunk/sources/HeuristicLab.Hive.Server.Core/HeuristicLab.Hive.Server.Core.csproj

    r744 r800  
    4949  <ItemGroup>
    5050    <Compile Include="ClientCommunicator.cs" />
     51    <Compile Include="ClientManager.cs" />
    5152    <Compile Include="HiveServerCorePlugin.cs" />
     53    <Compile Include="JobManager.cs" />
    5254    <Compile Include="Properties\AssemblyInfo.cs" />
     55    <Compile Include="ServerConsoleFacade.cs" />
     56    <Compile Include="UserRoleManager.cs" />
    5357  </ItemGroup>
    5458  <ItemGroup>
  • trunk/sources/HeuristicLab.Hive.Server/HiveServerApplication.cs

    r780 r800  
    3636      AutoRestart = true)]
    3737  class HiveServerApplication : ApplicationBase {
    38     const int port = 9000;
     38    const int port =
     39      9000;
    3940
    40     public override void Run() {
    41       IPHostEntry IPHost = Dns.GetHostEntry(Dns.GetHostName());
    42       string externalIP = IPHost.AddressList[0].ToString();
     41    DiscoveryService discService =
     42        new DiscoveryService();
    4343
    44       DiscoveryService discService =
    45         new DiscoveryService();
    46       IClientCommunicator[] instances =
     44    private bool AddMexEndpoint(ServiceHost serviceHost) {
     45      if(serviceHost != null) {
     46        ServiceMetadataBehavior behavior =
     47            new ServiceMetadataBehavior();
     48          serviceHost.Description.Behaviors.Add(behavior);
     49
     50          return serviceHost.AddServiceEndpoint(
     51            typeof(IMetadataExchange),
     52            MetadataExchangeBindings.CreateMexTcpBinding(),
     53            "mex") != null;
     54      } else
     55        return false;
     56    }
     57
     58    private ServiceHost StartClientCommunicator(Uri uriTcp) {
     59      IClientCommunicator[] clientCommunicatorInstances =
    4760        discService.GetInstances<IClientCommunicator>();
    4861
    49       if (instances.Length > 0) {
    50         Uri uriTcp =
    51           new Uri("net.tcp://" + externalIP + ":" + port +"/HiveServer/");
    52 
     62      if (clientCommunicatorInstances.Length > 0) {
    5363        ServiceHost serviceHost =
    54                 new ServiceHost(instances[0].GetType(),
     64                new ServiceHost(clientCommunicatorInstances[0].GetType(),
    5565                  uriTcp);
    5666
    57         System.ServiceModel.Channels.Binding binding = 
     67        System.ServiceModel.Channels.Binding binding =
    5868          new NetTcpBinding();
    5969
     
    6373              "ClientCommunicator");
    6474
    65         ServiceMetadataBehavior behavior =
    66           new ServiceMetadataBehavior();
    67         serviceHost.Description.Behaviors.Add(behavior);
    68 
    69         serviceHost.AddServiceEndpoint(
    70           typeof(IMetadataExchange),
    71           MetadataExchangeBindings.CreateMexTcpBinding(),
    72           "mex");
     75        AddMexEndpoint(serviceHost);
    7376
    7477        serviceHost.Open();
    7578
    76         Form mainForm = new MainForm(serviceHost.BaseAddresses[0]);
    77         Application.Run(mainForm);
     79        return serviceHost;
     80      } else
     81        return null;
     82    }
    7883
    79         serviceHost.Close();
    80       } else {
    81         MessageBox.Show("Error - no ClientCommunicator instance");
    82       }
     84    private ServiceHost StartServerConsoleFacade(Uri uriTcp) {
     85      IServerConsoleFacade[] serverConsoleInstances =
     86        discService.GetInstances<IServerConsoleFacade>();
     87
     88      if (serverConsoleInstances.Length > 0) {
     89        ServiceHost serviceHost =
     90                new ServiceHost(serverConsoleInstances[0].GetType(),
     91                  uriTcp);
     92
     93        System.ServiceModel.Channels.Binding binding =
     94          new NetTcpBinding();
     95
     96        serviceHost.AddServiceEndpoint(
     97          typeof(IClientManager),
     98              binding,
     99              "ClientManager");
     100
     101        serviceHost.AddServiceEndpoint(
     102          typeof(IJobManager),
     103              binding,
     104              "JobManager");
     105
     106        serviceHost.AddServiceEndpoint(
     107          typeof(IUserRoleManager),
     108              binding,
     109              "UserRoleManager");
     110
     111        AddMexEndpoint(serviceHost);
     112
     113        serviceHost.Open();
     114
     115        return serviceHost;
     116      } else
     117        return null;
     118    }
     119
     120    public override void Run() {
     121      string externalIP =
     122        Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
     123
     124      Uri uriTcp =
     125          new Uri("net.tcp://" + externalIP + ":" + port + "/HiveServer/");
     126
     127      ServiceHost clientCommunicator =
     128        StartClientCommunicator(uriTcp);
     129
     130      uriTcp =
     131        new Uri("net.tcp://" + externalIP + ":" + port + "/HiveServerConsole/");
     132
     133      ServiceHost serverConsoleFacade =
     134        StartServerConsoleFacade(uriTcp);
     135
     136      Form mainForm = new MainForm(clientCommunicator.BaseAddresses[0],
     137        serverConsoleFacade.BaseAddresses[0]);
     138
     139      Application.Run(mainForm);
     140
     141      clientCommunicator.Close();
     142      serverConsoleFacade.Close();
    83143    }
    84144  }
  • trunk/sources/HeuristicLab.Hive.Server/MainForm.Designer.cs

    r741 r800  
    3030        {
    3131          this.label1 = new System.Windows.Forms.Label();
    32           this.lblAddress = new System.Windows.Forms.Label();
     32          this.lblAddress1 = new System.Windows.Forms.Label();
     33          this.label2 = new System.Windows.Forms.Label();
     34          this.lblAddress2 = new System.Windows.Forms.Label();
    3335          this.SuspendLayout();
    3436          //
     
    4244          this.label1.Text = "Hive server running @";
    4345          //
    44           // lblAddress
     46          // lblAddress1
    4547          //
    46           this.lblAddress.AutoSize = true;
    47           this.lblAddress.Location = new System.Drawing.Point(18, 43);
    48           this.lblAddress.Name = "lblAddress";
    49           this.lblAddress.Size = new System.Drawing.Size(44, 13);
    50           this.lblAddress.TabIndex = 1;
    51           this.lblAddress.Text = "address";
     48          this.lblAddress1.AutoSize = true;
     49          this.lblAddress1.Location = new System.Drawing.Point(18, 43);
     50          this.lblAddress1.Name = "lblAddress1";
     51          this.lblAddress1.Size = new System.Drawing.Size(44, 13);
     52          this.lblAddress1.TabIndex = 1;
     53          this.lblAddress1.Text = "address";
     54          //
     55          // label2
     56          //
     57          this.label2.AutoSize = true;
     58          this.label2.Location = new System.Drawing.Point(18, 76);
     59          this.label2.Name = "label2";
     60          this.label2.Size = new System.Drawing.Size(195, 13);
     61          this.label2.TabIndex = 2;
     62          this.label2.Text = "Hive Server Console Facade running @";
     63          //
     64          // lblAddress2
     65          //
     66          this.lblAddress2.AutoSize = true;
     67          this.lblAddress2.Location = new System.Drawing.Point(18, 102);
     68          this.lblAddress2.Name = "lblAddress2";
     69          this.lblAddress2.Size = new System.Drawing.Size(44, 13);
     70          this.lblAddress2.TabIndex = 3;
     71          this.lblAddress2.Text = "address";
    5272          //
    5373          // MainForm
     
    5575          this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    5676          this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    57           this.ClientSize = new System.Drawing.Size(304, 78);
    58           this.Controls.Add(this.lblAddress);
     77          this.ClientSize = new System.Drawing.Size(304, 128);
     78          this.Controls.Add(this.lblAddress2);
     79          this.Controls.Add(this.label2);
     80          this.Controls.Add(this.lblAddress1);
    5981          this.Controls.Add(this.label1);
    6082          this.Name = "MainForm";
     
    6890
    6991        private System.Windows.Forms.Label label1;
    70         private System.Windows.Forms.Label lblAddress;
     92        private System.Windows.Forms.Label lblAddress1;
     93        private System.Windows.Forms.Label label2;
     94        private System.Windows.Forms.Label lblAddress2;
    7195    }
    7296}
  • trunk/sources/HeuristicLab.Hive.Server/MainForm.cs

    r741 r800  
    1111{
    1212    public partial class MainForm : Form {
    13         public MainForm(Uri address) {
     13        public MainForm(Uri address1, Uri address2) {
    1414          InitializeComponent();
    15           if(address != null)
    16             this.lblAddress.Text = address.ToString();
     15          if(address1 != null)
     16            this.lblAddress1.Text = address1.ToString();
     17          if (address2 != null)
     18            this.lblAddress2.Text = address2.ToString();
    1719        }
    1820    }
Note: See TracChangeset for help on using the changeset viewer.