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; }
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); }
internal KeyspaceMetadata(Metadata parent, string name, bool durableWrites, string strategyClass, IDictionary<string, int> replicationOptions) { //Can not directly reference to schemaParser as it might change _parent = parent; Name = name; DurableWrites = durableWrites; StrategyClass = strategyClass; if (strategyClass != null && strategyClass.StartsWith("org.apache.cassandra.locator.")) { StrategyClass = strategyClass.Replace("org.apache.cassandra.locator.", ""); } Replication = replicationOptions; }
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 + "]"); }
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); }
private Cluster(IEnumerable<IPEndPoint> contactPoints, Configuration configuration) { Configuration = configuration; _metadata = new Metadata(configuration); foreach (var ep in contactPoints) { _metadata.AddHost(ep); } }
/// <summary> /// Creates a new session on this cluster and sets a keyspace to use. /// </summary> /// <param name="keyspace"> The name of the keyspace to use for the created <code>Session</code>. </param> /// <returns>a new session on this cluster set to keyspace: /// <code>keyspaceName</code>. </returns> public Session Connect(string keyspace) { bool controlConnectionCreated = false; lock (_controlConnectionGuard) { if (_controlConnection == null) { controlConnectionCreated = true; var controlpolicies = new Cassandra.Policies( _configuration.Policies.LoadBalancingPolicy, new ExponentialReconnectionPolicy(2 * 1000, 5 * 60 * 1000), Cassandra.Policies.DefaultRetryPolicy); _hosts = new Hosts(_configuration.Policies.ReconnectionPolicy); foreach (var ep in _contactPoints) _hosts.AddIfNotExistsOrBringUpIfDown(ep); var poolingOptions = new PoolingOptions().SetCoreConnectionsPerHost(HostDistance.Local, 1); _controlConnection = new ControlConnection(this, new List<IPAddress>(), controlpolicies, _configuration.ProtocolOptions, poolingOptions, _configuration.SocketOptions, new ClientOptions( _configuration.ClientOptions.WithoutRowSetBuffering, _configuration.ClientOptions.QueryAbortTimeout, null, _configuration.ClientOptions.AsyncCallAbortTimeout), _configuration.AuthInfoProvider, _configuration.MetricsEnabled); _metadata = new Metadata(_hosts, _controlConnection); _controlConnection.Init(); } } var scs = new Session(this, _contactPoints, _configuration.Policies, _configuration.ProtocolOptions, _configuration.PoolingOptions, _configuration.SocketOptions, _configuration.ClientOptions, _configuration.AuthInfoProvider, _configuration.MetricsEnabled, keyspace, _hosts); scs.Init(); lock (_connectedSessions) _connectedSessions.Add(scs); _logger.Info("Session connected!"); if (controlConnectionCreated) RefreshSchema(); return scs; }
internal ControlConnection(ICluster cluster, Metadata metadata) { Metadata = metadata; _reconnectionSchedule = _reconnectionPolicy.NewSchedule(); _reconnectionTimer = new Timer(_ => Refresh(true), null, Timeout.Infinite, Timeout.Infinite); _config = cluster.Configuration; }
internal KeyspaceMetadata(Metadata parent, string name, bool durableWrites, string strategyClass, IDictionary <string, int> replicationOptions, bool isVirtual = false) : this(parent, name, durableWrites, strategyClass, replicationOptions, new ReplicationStrategyFactory(), isVirtual) { }
internal SchemaParserV3(Metadata parent, Func <string, string, Task <UdtColumnInfo> > udtResolver) : base(parent, udtResolver) { }
protected SchemaParser(Metadata parent) { Cc = parent.ControlConnection; Parent = parent; }
internal SchemaParserV1(Metadata parent) : base(parent) { }