internal Metadata(Configuration config) { _config = config; Hosts = new Hosts(config.Policies.ReconnectionPolicy); Hosts.Down += OnHostDown; Hosts.Up += OnHostUp; }
internal void RebuildTokenMap() { if (!Configuration.Policies.LoadBalancingPolicy.RequiresTokenMap) { Logger.Info("Skip rebuilding token map"); return; } Logger.Info("Rebuilding token map"); if (Partitioner == null) { throw new DriverInternalError("Partitioner can not be null"); } _tokenMap = TokenMap.Build(Partitioner, Hosts.ToCollection(), _keyspaces.Values); }
internal Metadata(Hosts hosts, ControlConnection controlConnection) { this._hosts = hosts; this._controlConnection = controlConnection; }
public IEnumerable <IPEndPoint> AllReplicas() { return(Hosts.AllEndPointsToCollection()); }
/// <summary> /// Returns all known hosts of this cluster. /// </summary> /// <returns>collection of all known hosts of this cluster.</returns> public ICollection <Host> AllHosts() { return(Hosts.ToCollection()); }
internal void RemoveHost(IPEndPoint address) { Hosts.RemoveIfExists(address); }
internal Host AddHost(IPEndPoint address) { return(Hosts.Add(address)); }
internal Metadata(IReconnectionPolicy rp) { this._hosts = new Hosts(rp); }
/// <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 Session(Cluster cluster, IEnumerable<IPAddress> clusterEndpoints, Policies policies, ProtocolOptions protocolOptions, PoolingOptions poolingOptions, SocketOptions socketOptions, ClientOptions clientOptions, IAuthInfoProvider authProvider, bool metricsEnabled, string keyspace, Hosts hosts,ControlConnection controlConnection=null) { this._cluster = cluster; this._protocolOptions = protocolOptions; this._poolingOptions = poolingOptions; this._socketOptions = socketOptions; this._clientOptions = clientOptions; this._authProvider = authProvider; this._metricsEnabled = metricsEnabled; this._policies = policies ?? Policies.DefaultPolicies; _hosts = hosts ; this._controlConnection = controlConnection; foreach (var ep in clusterEndpoints) _hosts.AddIfNotExistsOrBringUpIfDown(ep, this._policies.ReconnectionPolicy); this._policies.LoadBalancingPolicy.Initialize(_cluster); _keyspace = keyspace ?? clientOptions.DefaultKeyspace; }
internal Metadata(IReconnectionPolicy rp) { Hosts = new Hosts(rp); Hosts.Down += OnHostDown; }