public void TestCreateCustom() { string customType = typeof(CustomSnitch).AssemblyQualifiedName; IEndpointSnitch snitch = ServiceActivator <Factory> .Create <IEndpointSnitch>(customType); Assert.IsTrue(snitch is CustomSnitch); }
public NearestEndpointStrategy(IEnumerable<IPAddress> endpoints, IEndpointSnitch snitch) { _snitch = snitch; IPAddress clientAddress = NetworkFinder.Find(Dns.GetHostName()); _healthyEndpoints = snitch.GetSortedListByProximity(clientAddress, endpoints); _bannedEndpoints = new List<IPAddress>(); _clientAddress = NetworkFinder.Find(Dns.GetHostName()); }
public NearestEndpointStrategy(IEnumerable<IPAddress> endpoints, IEndpointSnitch snitch) { _snitch = snitch; _clientAddress = Network.Find(Dns.GetHostName()); if (null == _clientAddress) { throw new ArgumentException("Failed to resolve IP for client address"); } _healthyEndpoints = snitch.GetSortedListByProximity(_clientAddress, endpoints); _bannedEndpoints = new List<IPAddress>(); }
public NearestEndpointStrategy(IEnumerable <IPAddress> endpoints, IEndpointSnitch snitch) { _snitch = snitch; _clientAddress = Network.Find(Dns.GetHostName()); if (null == _clientAddress) { throw new ArgumentException("Failed to resolve IP for client address"); } _healthyEndpoints = snitch.GetSortedListByProximity(_clientAddress, endpoints); _bannedEndpoints = new List <IPAddress>(); }
public ICluster GetCluster(ClusterConfig clusterConfig) { clusterConfig.CheckArgumentNotNull("clusterConfig"); clusterConfig.Endpoints.CheckArgumentNotNull("clusterConfig.Endpoints"); TransportConfig transportConfig = clusterConfig.Transport ?? new TransportConfig(); IRecoveryService recoveryService = GetRecoveryService(transportConfig.Recoverable); KeyspaceConfig keyspaceConfig = clusterConfig.DefaultKeyspace ?? new KeyspaceConfig(); // create endpoints IEndpointSnitch snitch = ServiceActivator <Factory> .Create <IEndpointSnitch>(clusterConfig.Endpoints.Snitch, _logger); IEnumerable <IPAddress> endpoints = clusterConfig.Endpoints.Servers.Select(Network.Find).Where(x => null != x).ToArray(); if (!endpoints.Any()) { throw new ArgumentException("Expecting at least one valid endpoint"); } // create required services IEndpointStrategy endpointsManager = ServiceActivator <EndpointStrategy.Factory> .Create <IEndpointStrategy>(clusterConfig.Endpoints.Strategy, endpoints, snitch, _logger, clusterConfig.Endpoints); IConnectionFactory connectionFactory = ServiceActivator <Transport.Factory> .Create <IConnectionFactory>(transportConfig.Type, transportConfig, keyspaceConfig, _logger, _instrumentation); IPartitioner partitioner = ServiceActivator <Partitioner.Factory> .Create <IPartitioner>(clusterConfig.Partitioner); // create the cluster now ICluster cluster = ServiceActivator <Cluster.Factory> .Create <ICluster>(clusterConfig.Type, endpointsManager, _logger, connectionFactory, recoveryService, partitioner, clusterConfig); IDiscoveryService discoveryService = ServiceActivator <Discovery.Factory> .Create <IDiscoveryService>(clusterConfig.Endpoints.Discovery.Type, clusterConfig.Endpoints.Discovery, _logger, cluster); discoveryService.OnTopologyUpdate += endpointsManager.Update; cluster.OnClosed += discoveryService.SafeDispose; return(cluster); }
public EndpointComparer(IEndpointSnitch snitch, IPAddress clientAddress) { _snitch = snitch; _client = clientAddress; }
public CustomEndpointStrategy(IEnumerable <IPAddress> endpoints, IEndpointSnitch snitch) { Endpoints = endpoints; }
public CustomEndpointStrategy(IEnumerable<IPAddress> endpoints, IEndpointSnitch snitch) { Endpoints = endpoints; }
public RandomEndpointStrategy(IEnumerable<IPAddress> endpoints, IEndpointSnitch snitch) { _healthyEndpoints = new List<IPAddress>(endpoints); _bannedEndpoints = new List<IPAddress>(); _rnd = new Random(); }
public void TestCreateSimple() { IEndpointSnitch snitch = ServiceActivator <Factory> .Create <IEndpointSnitch>("Simple"); Assert.IsTrue(snitch is SimpleSnitch); }
public void TestCreateRackInferring() { IEndpointSnitch snitch = ServiceActivator <Factory> .Create <IEndpointSnitch>("RackInferring"); Assert.IsTrue(snitch is RackInferringSnitch); }