コード例 #1
0
 internal Metadata(Configuration config)
 {
     _config = config;
     Hosts = new Hosts(config.Policies.ReconnectionPolicy);
     Hosts.Down += OnHostDown;
     Hosts.Up += OnHostUp;
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 internal Metadata(Hosts hosts, ControlConnection controlConnection)
 {
     this._hosts             = hosts;
     this._controlConnection = controlConnection;
 }
コード例 #4
0
 public IEnumerable <IPEndPoint> AllReplicas()
 {
     return(Hosts.AllEndPointsToCollection());
 }
コード例 #5
0
 /// <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());
 }
コード例 #6
0
 internal void RemoveHost(IPEndPoint address)
 {
     Hosts.RemoveIfExists(address);
 }
コード例 #7
0
 internal Host AddHost(IPEndPoint address)
 {
     return(Hosts.Add(address));
 }
コード例 #8
0
 internal Metadata(IReconnectionPolicy rp)
 {
     this._hosts = new Hosts(rp);
 }
コード例 #9
0
ファイル: Metadata.cs プロジェクト: ntent-ad/csharp-driver
 internal Metadata(IReconnectionPolicy rp)
 {
     this._hosts = new Hosts(rp);
 }
コード例 #10
0
        /// <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;
        }
コード例 #11
0
ファイル: Session.cs プロジェクト: sdether/csharp-driver
        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;
        }
コード例 #12
0
 internal Metadata(IReconnectionPolicy rp)
 {
     Hosts       = new Hosts(rp);
     Hosts.Down += OnHostDown;
 }
コード例 #13
0
 internal Metadata(Hosts hosts, ControlConnection controlConnection)
 {
     this._hosts = hosts;
     this._controlConnection = controlConnection;
 }