Changeset 13557 for branches/thasling/DistributedGA
- Timestamp:
- 01/19/16 12:45:18 (9 years ago)
- Location:
- branches/thasling/DistributedGA
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/thasling/DistributedGA/DistributedGA.ContactServer.Host/Program.cs
r13524 r13557 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 2 using System.ServiceModel; 5 using System.ServiceModel.Description;6 using System.Text;7 using System.Threading.Tasks;8 3 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); 4 namespace 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. 31 16 32 // Open the ServiceHost to start listening for messages. Since33 // no endpoints are explicitly configured, the runtime will create34 // one endpoint per base address for each service contract implemented35 // by the service.36 37 host.Open();38 17 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. 42 22 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 } 47 32 } 33 } 48 34 } -
branches/thasling/DistributedGA/DistributedGA.ContactServer/App.config
r13524 r13557 15 15 <binding name="LargeObjects" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" /> 16 16 </basicHttpBinding> 17 <netTcpBinding> 18 <binding name="LargeObjects" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" /> 19 </netTcpBinding> 17 20 </bindings> 18 21 <services> 19 22 <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"/> 21 24 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 22 25 <host> 23 26 <baseAddresses> 24 <add baseAddress=" http://localhost:9090/DistributedGA.ContactServer" />27 <add baseAddress="net.tcp://localhost:9090/DistributedGA.ContactServer" /> 25 28 </baseAddresses> 26 29 </host> -
branches/thasling/DistributedGA/DistributedGA.ContactServer/ContactServiceImpl.cs
r13555 r13557 64 64 65 65 private void UpdateHeartbeat(PeerInfo source) { 66 Console.WriteLine("hb from {0}:{1}", source.IpAddress, source.Port); 66 67 DateTime now = DateTime.Now; 67 68 allPeers.AddOrUpdate(source, now, (k, v) => v = now); -
branches/thasling/DistributedGA/DistributedGA.Core.Host/App.config
r13541 r13557 5 5 </startup> 6 6 <appSettings> 7 <add key="ContactServerURL" value=" http://localhost:9090/DistributedGA.ContactServer/ContactService"/>7 <add key="ContactServerURL" value="net.tcp://localhost:9090/DistributedGA.ContactServer/ContactService"/> 8 8 <add key="LanIpPrefix" value="10."/> 9 9 </appSettings> -
branches/thasling/DistributedGA/DistributedGA.Core.Host/DistributedGA.Core.Host.csproj
r13541 r13557 34 34 <ItemGroup> 35 35 <Reference Include="System" /> 36 <Reference Include="System.Configuration" /> 36 37 <Reference Include="System.Core" /> 37 38 <Reference Include="System.Xml.Linq" /> -
branches/thasling/DistributedGA/DistributedGA.Core.Host/Program.cs
r13556 r13557 1 1 using System; 2 using System.Configuration; 2 3 using System.Threading; 3 4 using DistributedGA.Core.Domain; … … 10 11 try { 11 12 Console.WriteLine("Starting peer..."); 13 string ipPrefix = ConfigurationManager.AppSettings["LanIpPrefix"]; 14 string serverUrl = ConfigurationManager.AppSettings["ContactServerURL"]; 15 16 12 17 IMessageHandler h = new PeerNetworkMessageHandler(); 13 h.Init( "","");18 h.Init(ipPrefix, serverUrl); 14 19 PeerInfo pi = h.GetPeerInfo(); 15 20 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 19 19 private IMessageContract CreateServerClient(string ip, int port) { 20 20 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")); 22 22 var serviceUri = new Uri(baseUri, serviceUrl); 23 23 24 var binding = new BasicHttpBinding();24 var binding = new NetTcpBinding(); 25 25 var endpoint = new EndpointAddress(serviceUri); 26 26 var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint); -
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageService.cs
r13553 r13557 24 24 var serviceUrl = "DistributedGA.svc"; 25 25 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")); 27 27 var serviceUri = new Uri(baseUri, serviceUrl); 28 BasicHttpBinding binding = new BasicHttpBinding();28 NetTcpBinding binding = new NetTcpBinding(); 29 29 //using (var host = new ServiceHost(typeof(MessageContractImpl), serviceUri)) 30 30 -
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs
r13556 r13557 33 33 34 34 private IContactService CreateClient() { 35 var binding = new BasicHttpBinding();35 var binding = new NetTcpBinding(); 36 36 var endpoint = new EndpointAddress(serverString); 37 37 var myChannelFactory = new ChannelFactory<IContactService>(binding, endpoint); -
branches/thasling/DistributedGA/DistributedGA.Hive/P2PTask.cs
r13556 r13557 19 19 public class P2PTask : ParameterizedNamedItem, IOptimizer { 20 20 21 [Storable] 22 private Log log; 21 23 22 [Storable] 24 23 private DateTime startTime; … … 31 30 protected P2PTask(P2PTask original, Cloner cloner) 32 31 : base(original, cloner) { 33 log = cloner.Clone(original.log);34 32 startTime = original.startTime; 35 33 runCollection = cloner.Clone(original.runCollection); … … 41 39 42 40 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 46 44 } 47 45 … … 83 81 OnStarted(); 84 82 83 var log = ((Log)(Parameters["Log"].ActualValue)); 84 85 85 86 try { 87 86 88 log.LogMessage("Starting peer..."); 87 89 IMessageHandler h = new PeerNetworkMessageHandler();
Note: See TracChangeset
for help on using the changeset viewer.