Changeset 13557


Ignore:
Timestamp:
01/19/16 12:45:18 (5 years ago)
Author:
thasling
Message:

Implemented P2PTask-class
Changed communication protocoll http --> net.tcp
Logger is now Parameter of P2PTask

Location:
branches/thasling/DistributedGA
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/thasling/DistributedGA/DistributedGA.ContactServer.Host/Program.cs

    r13524 r13557  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    42using System.ServiceModel;
    5 using System.ServiceModel.Description;
    6 using System.Text;
    7 using System.Threading.Tasks;
    83
    9 namespace DistributedGA.ContactServer.Host
    10 {
    11     class Program
    12     {
    13         static void Main(string[] args)
    14         {
    15             string baseAddress = string.Empty;
    16             if(args.GetUpperBound(0) > -1)
    17             {
    18                baseAddress = args[0];
    19             }
    20             if (string.IsNullOrWhiteSpace(baseAddress))
    21             {
    22                 baseAddress = "http://localhost:9090/DistributedGA.ContactServer/ContactService";
    23             }
    24             using (ServiceHost host = new ServiceHost(typeof(ContactServiceImpl), new Uri[] { new Uri(baseAddress) }))
    25             {
    26                 // Enable metadata publishing.
    27                 ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    28                 smb.HttpGetEnabled = true;
    29                 smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
    30                 host.Description.Behaviors.Add(smb);
     4namespace DistributedGA.ContactServer.Host {
     5  class Program {
     6    static void Main(string[] args) {
     7      string baseAddress = string.Empty;
     8      if (args.GetUpperBound(0) > -1) {
     9        baseAddress = args[0];
     10      }
     11      if (string.IsNullOrWhiteSpace(baseAddress)) {
     12        baseAddress = "net.tcp://localhost:9090/DistributedGA.ContactServer/ContactService";
     13      }
     14      using (ServiceHost host = new ServiceHost(typeof(ContactServiceImpl), new Uri[] { new Uri(baseAddress) })) {
     15        // Enable metadata publishing.
    3116
    32                 // Open the ServiceHost to start listening for messages. Since
    33                 // no endpoints are explicitly configured, the runtime will create
    34                 // one endpoint per base address for each service contract implemented
    35                 // by the service.
    36                
    37                 host.Open();
    3817
    39                 Console.WriteLine("The service is ready at {0}", baseAddress);
    40                 Console.WriteLine("Press <Enter> to stop the service.");
    41                 Console.ReadLine();
     18        // Open the ServiceHost to start listening for messages. Since
     19        // no endpoints are explicitly configured, the runtime will create
     20        // one endpoint per base address for each service contract implemented
     21        // by the service.
    4222
    43                 // Close the ServiceHost.
    44                 host.Close();
    45             }
    46         }
     23        host.Open();
     24
     25        Console.WriteLine("The service is ready at {0}", baseAddress);
     26        Console.WriteLine("Press <Enter> to stop the service.");
     27        Console.ReadLine();
     28
     29        // Close the ServiceHost.
     30        host.Close();
     31      }
    4732    }
     33  }
    4834}
  • branches/thasling/DistributedGA/DistributedGA.ContactServer/App.config

    r13524 r13557  
    1515        <binding name="LargeObjects" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
    1616      </basicHttpBinding>
     17      <netTcpBinding>
     18        <binding name="LargeObjects" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
     19      </netTcpBinding>
    1720    </bindings>
    1821    <services>
    1922      <service name="DistributedGA.ContactServer.ContactServiceImpl">
    20         <endpoint bindingConfiguration="LargeObjects" address="ContactService" binding="basicHttpBinding" contract="DistributedGA.ContactServer.IContactService"/>
     23        <endpoint bindingConfiguration="LargeObjects" address="ContactService" binding="netTcpBinding" contract="DistributedGA.ContactServer.IContactService"/>
    2124        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    2225        <host>
    2326          <baseAddresses>
    24             <add baseAddress="http://localhost:9090/DistributedGA.ContactServer" />
     27            <add baseAddress="net.tcp://localhost:9090/DistributedGA.ContactServer" />
    2528          </baseAddresses>
    2629        </host>
  • branches/thasling/DistributedGA/DistributedGA.ContactServer/ContactServiceImpl.cs

    r13555 r13557  
    6464
    6565    private void UpdateHeartbeat(PeerInfo source) {
     66      Console.WriteLine("hb from {0}:{1}", source.IpAddress, source.Port);
    6667      DateTime now = DateTime.Now;
    6768      allPeers.AddOrUpdate(source, now, (k, v) => v = now);
  • branches/thasling/DistributedGA/DistributedGA.Core.Host/App.config

    r13541 r13557  
    55    </startup>
    66  <appSettings>
    7     <add key="ContactServerURL" value="http://localhost:9090/DistributedGA.ContactServer/ContactService"/>
     7    <add key="ContactServerURL" value="net.tcp://localhost:9090/DistributedGA.ContactServer/ContactService"/>
    88    <add key="LanIpPrefix" value="10."/>
    99  </appSettings>
  • branches/thasling/DistributedGA/DistributedGA.Core.Host/DistributedGA.Core.Host.csproj

    r13541 r13557  
    3434  <ItemGroup>
    3535    <Reference Include="System" />
     36    <Reference Include="System.Configuration" />
    3637    <Reference Include="System.Core" />
    3738    <Reference Include="System.Xml.Linq" />
  • branches/thasling/DistributedGA/DistributedGA.Core.Host/Program.cs

    r13556 r13557  
    11using System;
     2using System.Configuration;
    23using System.Threading;
    34using DistributedGA.Core.Domain;
     
    1011      try {
    1112        Console.WriteLine("Starting peer...");
     13        string ipPrefix = ConfigurationManager.AppSettings["LanIpPrefix"];
     14        string serverUrl = ConfigurationManager.AppSettings["ContactServerURL"];
     15
     16
    1217        IMessageHandler h = new PeerNetworkMessageHandler();
    13         h.Init("","");
     18        h.Init(ipPrefix, serverUrl);
    1419        PeerInfo pi = h.GetPeerInfo();
    1520        Console.WriteLine(string.Format("Peer is hostet at IP: {0} and port: {1}", pi.IpAddress, pi.Port));
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs

    r13553 r13557  
    1919    private IMessageContract CreateServerClient(string ip, int port) {
    2020      var serviceUrl = "DistributedGA.svc";
    21       var baseUri = new Uri(string.Concat("http://", ip, ":", port, "/DistributedGA"));
     21      var baseUri = new Uri(string.Concat("net.tcp://", ip, ":", port, "/DistributedGA"));
    2222      var serviceUri = new Uri(baseUri, serviceUrl);
    2323
    24       var binding = new BasicHttpBinding();
     24      var binding = new NetTcpBinding();
    2525      var endpoint = new EndpointAddress(serviceUri);
    2626      var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint);
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageService.cs

    r13553 r13557  
    2424      var serviceUrl = "DistributedGA.svc";
    2525      new Thread(() => {
    26         var baseUri = new Uri(string.Concat("http://", ip, ":", port, "/DistributedGA"));
     26        var baseUri = new Uri(string.Concat("net.tcp://", ip, ":", port, "/DistributedGA"));
    2727        var serviceUri = new Uri(baseUri, serviceUrl);
    28         BasicHttpBinding binding = new BasicHttpBinding();
     28        NetTcpBinding binding = new NetTcpBinding();
    2929        //using (var host = new ServiceHost(typeof(MessageContractImpl), serviceUri))
    3030
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs

    r13556 r13557  
    3333
    3434    private IContactService CreateClient() {
    35       var binding = new BasicHttpBinding();
     35      var binding = new NetTcpBinding();
    3636      var endpoint = new EndpointAddress(serverString);
    3737      var myChannelFactory = new ChannelFactory<IContactService>(binding, endpoint);
  • branches/thasling/DistributedGA/DistributedGA.Hive/P2PTask.cs

    r13556 r13557  
    1919  public class P2PTask : ParameterizedNamedItem, IOptimizer {
    2020
    21     [Storable]
    22     private Log log;
     21
    2322    [Storable]
    2423    private DateTime startTime;
     
    3130    protected P2PTask(P2PTask original, Cloner cloner)
    3231      : base(original, cloner) {
    33       log = cloner.Clone(original.log);
    3432      startTime = original.startTime;
    3533      runCollection = cloner.Clone(original.runCollection);
     
    4139
    4240      Parameters.Add(new ValueParameter<StringValue>("LanIpPrefix", "", new StringValue("10.")));
    43       Parameters.Add(new ValueParameter<StringValue>("ContactServerURL", "", new StringValue("http://10.42.1.150:9090/DistributedGA.ContactServer/ContactService")));
    44 
    45       log = new Log();
     41      Parameters.Add(new ValueParameter<StringValue>("ContactServerURL", "", new StringValue("net.tcp://10.42.1.150:9090/DistributedGA.ContactServer/ContactService")));
     42      Parameters.Add(new ValueParameter<Log>("Log", "", new Log()));
     43
    4644    }
    4745
     
    8381        OnStarted();
    8482
     83        var log = ((Log)(Parameters["Log"].ActualValue));
     84
     85
    8586        try {
     87
    8688          log.LogMessage("Starting peer...");
    8789          IMessageHandler h = new PeerNetworkMessageHandler();
Note: See TracChangeset for help on using the changeset viewer.