Beispiel #1
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)
        {
            var scs = new Session(this, _configuration.Policies,
                                  _configuration.ProtocolOptions,
                                  _configuration.PoolingOptions, _configuration.SocketOptions,
                                  _configuration.ClientOptions,
                                  _configuration.AuthInfoProvider, keyspace);
            scs.Init();
            lock (_connectedSessions)
                _connectedSessions.Add(scs);
            _logger.Info("Session connected!");

            _metadata.RefreshSchema();

            return scs;
        }
Beispiel #2
0
 /// <summary>
 /// Creates a new session on this cluster and using a keyspace an existing keyspace.
 /// </summary>
 /// <param name="keyspace">Case-sensitive keyspace name to use</param>
 public ISession Connect(string keyspace)
 {
     Init();
     var session = new Session(this, Configuration, keyspace, _protocolVersion);
     session.Init();
     _connectedSessions.Add(session);
     _logger.Info("Session connected ({0})", session.GetHashCode());
     return session;
 }
        /// <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;
        }
Beispiel #4
0
 /// <summary>
 /// Creates a new session on this cluster and using a keyspace an existing keyspace.
 /// </summary>
 /// <param name="keyspace">Case-sensitive keyspace name to use</param>
 public ISession Connect(string keyspace)
 {
     Init();
     var session = new Session(this, Configuration, keyspace, _binaryProtocolVersion);
     session.Init(true);
     _connectedSessions.Add(session);
     _logger.Info("Session connected!");
     return session;
 }
Beispiel #5
0
        /// <inheritdoc />
        public ISession Connect(string keyspace)
        {
            var scs = new Session(this, _configuration, keyspace, _binaryProtocolVersion);
            scs.Init(true);
            _connectedSessions.TryAdd(scs.Guid, scs);
            _logger.Info("Session connected!");

            return scs;
        }
Beispiel #6
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)
        {
            var scs = new Session(this, _configuration.Policies,
                                  _configuration.ProtocolOptions,
                                  _configuration.PoolingOptions,
                                  _configuration.SocketOptions,
                                  _configuration.ClientOptions,
                                  _configuration.AuthInfoProvider, keyspace);
            scs.Init();
            _connectedSessions.TryAdd(scs.Guid, scs);
            _logger.Info("Session connected!");

            return scs;
        }