public ServiceHost CreateServiceHost(ClusterConfiguration clusterConfiguration)
        {
            var managerNode = new ManagerNode(clusterConfiguration);
            managerNode.Start();
            var serviceHost = new ServiceHost(managerNode,
                                              new[]
                                                  {
                                                      new Uri(string.Format("http://localhost:{0}/brightstarcluster",
                                                                            Configuration.HttpPort)),
                                                      new Uri(string.Format("net.tcp://localhost:{0}/brightstarcluster",
                                                                            Configuration.TcpPort)),
                                                      new Uri(string.Format("net.pipe://localhost/{0}",
                                                                            Configuration.NamedPipeName))
                                                  });

            var basicHttpBinding = new BasicHttpContextBinding { TransferMode = TransferMode.StreamedResponse, MaxReceivedMessageSize = int.MaxValue, SendTimeout = TimeSpan.FromMinutes(30), ReaderQuotas = XmlDictionaryReaderQuotas.Max, Namespace = "http://www.networkedplanet.com/schemas/brightstar" };
            var netTcpContextBinding = new NetTcpContextBinding { TransferMode = TransferMode.StreamedResponse, MaxReceivedMessageSize = int.MaxValue, SendTimeout = TimeSpan.FromMinutes(30), ReaderQuotas = XmlDictionaryReaderQuotas.Max, Namespace = "http://www.networkedplanet.com/schemas/brightstar" };
            var netNamedPipeBinding = new NetNamedPipeBinding { TransferMode = TransferMode.StreamedResponse, MaxReceivedMessageSize = int.MaxValue, SendTimeout = TimeSpan.FromMinutes(30), ReaderQuotas = XmlDictionaryReaderQuotas.Max, Namespace = "http://www.networkedplanet.com/schemas/brightstar" };

            serviceHost.AddServiceEndpoint(typeof(IBrightstarClusterManagerService), basicHttpBinding, "");
            serviceHost.AddServiceEndpoint(typeof(IBrightstarClusterManagerService), netTcpContextBinding, "");
            serviceHost.AddServiceEndpoint(typeof(IBrightstarClusterManagerService), netNamedPipeBinding, "");

            var throttlingBehavior = new ServiceThrottlingBehavior { MaxConcurrentCalls = int.MaxValue };

            serviceHost.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true });
            serviceHost.Description.Behaviors.Add(throttlingBehavior);

            serviceHost.Closed += StopNode;
            return serviceHost;
            
        }
Esempio n. 2
0
 public TwoNodeClusterTests()
 {
     TestUtils.ResetDirectory("c:\\brightstar\\coreA");
     TestUtils.ResetDirectory("c:\\brightstar\\coreB");
     Thread.Sleep(2000);
     _coreA = new NodeCore("c:\\brightstar\\coreA");
     _coreB = new NodeCore("c:\\brightstar\\coreB");
     _testConfiguration = new ClusterConfiguration
                              {
                                  ClusterNodes = 
                                      new List<NodeConfiguration>
                                          {
                                              new NodeConfiguration("127.0.0.1", 10001, 8090, 8095),
                                              new NodeConfiguration("127.0.0.1", 10002, 8091, 8096)
                                          },
                                  MasterConfiguration = new MasterConfiguration { WriteQuorum = 1 }
                              };
     _clusterManager = new ManagerNode(_testConfiguration);
 }