예제 #1
0
 internal Metadata(Configuration config)
 {
     _config = config;
     Hosts = new Hosts(config.Policies.ReconnectionPolicy);
     Hosts.Down += OnHostDown;
     Hosts.Up += OnHostUp;
 }
예제 #2
0
 public HostConnectionPool(Host host, HostDistance hostDistance, byte protocolVersion, Configuration configuration)
 {
     this.Host = host;
     this.HostDistance = hostDistance;
     this.ProtocolVersion = protocolVersion;
     this.Configuration = configuration;
 }
예제 #3
0
 public HostConnectionPool(Host host, HostDistance hostDistance, Configuration configuration)
 {
     Host = host;
     Host.Down += OnHostDown;
     HostDistance = hostDistance;
     Configuration = configuration;
 }
 internal ControlConnection(byte initialProtocolVersion, Configuration config, Metadata metadata)
 {
     Metadata = metadata;
     _reconnectionSchedule = _reconnectionPolicy.NewSchedule();
     _reconnectionTimer = new Timer(_ => Refresh(true), null, Timeout.Infinite, Timeout.Infinite);
     _config = config;
     ProtocolVersion = initialProtocolVersion;
 }
예제 #5
0
 internal ControlConnection(byte initialProtocolVersion, Configuration config, Metadata metadata)
 {
     _metadata = metadata;
     _reconnectionPolicy = config.Policies.ReconnectionPolicy;
     _reconnectionSchedule = _reconnectionPolicy.NewSchedule();
     _reconnectionTimer = new Timer(_ => Reconnect(), null, Timeout.Infinite, Timeout.Infinite);
     _config = config;
     _serializer = new Serializer(initialProtocolVersion, config.TypeSerializers);
 }
예제 #6
0
 public HostConnectionPool(Host host, HostDistance distance, Configuration config)
 {
     _host = host;
     _host.Down += OnHostDown;
     _host.Up += OnHostUp;
     _distance = distance;
     _config = config;
     _timer = config.Timer;
 }
예제 #7
0
 internal Session(ICluster cluster, Configuration configuration, string keyspace, int binaryProtocolVersion)
 {
     Cluster = cluster;
     Configuration = configuration;
     Keyspace = keyspace;
     BinaryProtocolVersion = binaryProtocolVersion;
     UserDefinedTypes = new UdtMappingDefinitions(this);
     _connectionPool = new ConcurrentDictionary<IPEndPoint, HostConnectionPool>();
 }
예제 #8
0
 internal Session(ICluster cluster, Configuration configuration, string keyspace, Serializer serializer)
 {
     _serializer = serializer;
     Cluster = cluster;
     Configuration = configuration;
     Keyspace = keyspace;
     UserDefinedTypes = new UdtMappingDefinitions(this, serializer);
     _connectionPool = new ConcurrentDictionary<IPEndPoint, HostConnectionPool>();
 }
예제 #9
0
 public HostConnectionPool(Host host, HostDistance distance, Configuration config, Serializer serializer)
 {
     _host = host;
     _host.CheckedAsDown += OnHostCheckedAsDown;
     _host.Down += OnHostDown;
     _host.Up += OnHostUp;
     _host.Remove += OnHostRemoved;
     _distance = distance;
     _config = config;
     _serializer = serializer;
     _timer = config.Timer;
 }
예제 #10
0
 /// <summary>
 /// Creates a new instance of <see cref="DseConfiguration"/>.
 /// </summary>
 public DseConfiguration(Configuration cassandraConfiguration, GraphOptions graphOptions)
 {
     if (cassandraConfiguration == null)
     {
         throw new ArgumentNullException("cassandraConfiguration");
     }
     if (graphOptions == null)
     {
         throw new ArgumentNullException("graphOptions");
     }
     CassandraConfiguration = cassandraConfiguration;
     GraphOptions = graphOptions;
 }
예제 #11
0
        private Cluster(IEnumerable<IPAddress> contactPoints, Configuration configuration)
        {
            _contactPoints = contactPoints;
            _configuration = configuration;
            _metadata = new Metadata(configuration.Policies.ReconnectionPolicy);

            var controlpolicies = new Policies(
                _configuration.Policies.LoadBalancingPolicy,
                new ExponentialReconnectionPolicy(2*1000, 5*60*1000),
                Policies.DefaultRetryPolicy);

            foreach (IPAddress ep in _contactPoints)
                Metadata.AddHost(ep);

            //Use 1 connection per host
            //The connection will be reused, it wont create a connection per host.
            var controlPoolingOptions = new PoolingOptions()
                .SetCoreConnectionsPerHost(HostDistance.Local, 1)
                .SetMaxConnectionsPerHost(HostDistance.Local, 1)
                .SetMinSimultaneousRequestsPerConnectionTreshold(HostDistance.Local, 0)
                .SetMaxSimultaneousRequestsPerConnectionTreshold(HostDistance.Local, 127);

            var controlConnection = new ControlConnection
                (this,
                new List<IPAddress>(),
                controlpolicies,
                new ProtocolOptions(_configuration.ProtocolOptions.Port, configuration.ProtocolOptions.SslOptions),
                controlPoolingOptions,
                _configuration.SocketOptions,
                new ClientOptions(true, _configuration.ClientOptions.QueryAbortTimeout, null),
                _configuration.AuthProvider,
                _configuration.AuthInfoProvider
                );

            _metadata.SetupControllConnection(controlConnection);
            _binaryProtocolVersion = controlConnection.ProtocolVersion;
            _logger.Info("Binary protocol version: [" + _binaryProtocolVersion + "]");
        }
예제 #12
0
 public Connection(byte protocolVersion, IPEndPoint endpoint, Configuration configuration)
 {
     this.ProtocolVersion = protocolVersion;
     this.Configuration = configuration;
     _tcpSocket = new TcpSocket(endpoint, configuration.SocketOptions, configuration.ProtocolOptions.SslOptions);
 }
예제 #13
0
 public Connection(byte protocolVersion, IPEndPoint endpoint, Configuration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     if (configuration.BufferPool == null)
     {
         throw new ArgumentNullException(null, "BufferPool can not be null");
     }
     ProtocolVersion = protocolVersion;
     Configuration = configuration;
     _tcpSocket = new TcpSocket(endpoint, configuration.SocketOptions, configuration.ProtocolOptions.SslOptions);
     _idleTimer = new Timer(IdleTimeoutHandler, null, Timeout.Infinite, Timeout.Infinite);
 }
예제 #14
0
 /// <summary>
 ///  The configuration that will be used for the new cluster. <p> You <b>should
 ///  not</b> modify this object directly as change made to the returned object may
 ///  not be used by the cluster build. Instead, you should use the other methods
 ///  of this <c>Builder</c></p>.
 /// </summary>
 /// 
 /// <returns>the configuration to use for the new cluster.</returns>
 public Configuration GetConfiguration()
 {
     var policies = new Policies(
         _loadBalancingPolicy ?? Policies.DefaultLoadBalancingPolicy,
         _reconnectionPolicy ?? Policies.DefaultReconnectionPolicy,
         _retryPolicy ?? Policies.DefaultRetryPolicy,
         _speculativeExecutionPolicy ?? Policies.DefaultSpeculativeExecutionPolicy);
     var config = new Configuration(policies,
         new ProtocolOptions(_port, _sslOptions).SetCompression(_compression)
                                                .SetCustomCompressor(_customCompressor).SetMaxProtocolVersion(_maxProtocolVersion),
         _poolingOptions,
         _socketOptions,
         new ClientOptions(_withoutRowSetBuffering, _queryAbortTimeout, _defaultKeyspace),
         _authProvider,
         _authInfoProvider,
         _queryOptions,
         _addressTranslator);
     if (_typeSerializerDefinitions != null)
     {
         config.TypeSerializers = _typeSerializerDefinitions.Definitions;
     }
     return config;
 }
예제 #15
0
        private Cluster(IEnumerable<IPAddress> contactPoints, Configuration configuration)
        {
            this._contactPoints = contactPoints;
            this._configuration = configuration;
            this._metadata = new Metadata(configuration.Policies.ReconnectionPolicy);

            var controlpolicies = new Cassandra.Policies(
                _configuration.Policies.LoadBalancingPolicy,
                new ExponentialReconnectionPolicy(2 * 1000, 5 * 60 * 1000),
                Cassandra.Policies.DefaultRetryPolicy);

            foreach (var ep in _contactPoints)
                Metadata.AddHost(ep);

            var poolingOptions = new PoolingOptions().SetCoreConnectionsPerHost(HostDistance.Local, 1);

            var controlConnection = new ControlConnection(this, new List<IPAddress>(), controlpolicies,
                                                        new ProtocolOptions(_configuration.ProtocolOptions.Port),
                                                       poolingOptions, _configuration.SocketOptions,
                                                       new ClientOptions(
                                                           true,
                                                           _configuration.ClientOptions.QueryAbortTimeout, null,
                                                           _configuration.ClientOptions.AsyncCallAbortTimeout),
                                                       _configuration.AuthInfoProvider);

            _metadata.SetupControllConnection(controlConnection);
        }
예제 #16
0
 private Cluster(IEnumerable<IPEndPoint> contactPoints, Configuration configuration)
 {
     Configuration = configuration;
     _metadata = new Metadata(configuration);
     foreach (var ep in contactPoints)
     {
         _metadata.AddHost(ep);
     }
 }
예제 #17
0
        internal ControlConnection(Cluster cluster,
                                   IEnumerable<IPAddress> clusterEndpoints,
                                   Policies policies,
                                   ProtocolOptions protocolOptions,
                                   PoolingOptions poolingOptions,
                                   SocketOptions socketOptions,
                                   ClientOptions clientOptions,
                                   IAuthProvider authProvider,
                                   IAuthInfoProvider authInfoProvider)
        {
            _cluster = cluster;
            _reconnectionSchedule = _reconnectionPolicy.NewSchedule();
            _reconnectionTimer = new Timer(ReconnectionClb, null, Timeout.Infinite, Timeout.Infinite);

            var config = new Configuration
            (
                policies,
                protocolOptions,
                poolingOptions,
                socketOptions,
                clientOptions,
                authProvider,
                authInfoProvider,
                new QueryOptions()
            );

            _session = new Session(cluster, config, "", ControlConnectionProtocolVersion);
        }
예제 #18
0
 public Connection(byte protocolVersion, IPEndPoint endpoint, Configuration configuration)
 {
     ProtocolVersion = protocolVersion;
     Configuration = configuration;
     _tcpSocket = new TcpSocket(endpoint, configuration.SocketOptions, configuration.ProtocolOptions.SslOptions);
     _idleTimer = new Timer(IdleTimeoutHandler, null, Timeout.Infinite, Timeout.Infinite);
 }
예제 #19
0
 private Cluster(IEnumerable<IPAddress> contactPoints, Configuration configuration)
 {
     this._contactPoints = contactPoints;
     this._configuration = configuration;
 }
예제 #20
0
 internal ControlConnection(ICluster cluster, Metadata metadata)
 {
     Metadata = metadata;
     _reconnectionSchedule = _reconnectionPolicy.NewSchedule();
     _reconnectionTimer = new Timer(_ => Refresh(true), null, Timeout.Infinite, Timeout.Infinite);
     _config = cluster.Configuration;
 }