コード例 #1
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);
        }
コード例 #2
0
ファイル: CassandraDAO.cs プロジェクト: aploetz/ShipCrew
 private void SetCluster()
 {
     if (Cluster == null)
     {
         Cluster = Connect();
     }
 }
コード例 #3
0
        private static void waitFor(string node, Cluster cluster, int maxTry, bool waitForDead, bool waitForOut)
        {
            // In the case where the we've killed the last node in the cluster, if we haven't
            // tried doing an actual query, the driver won't realize that last node is dead until'
            // keep alive kicks in, but that's a fairly long time. So we cheat and trigger a force'
            // the detection by forcing a request.
            bool disconnected = false;
            if (waitForDead || waitForOut)
            disconnected = !cluster.RefreshSchema(null, null);

            if (disconnected)
            return;

            IPAddress address;
            try {
             address = IPAddress.Parse(node);
            } catch (Exception e) {
            // That's a problem but that's not *our* problem
            return;
            }

            Metadata metadata = cluster.Metadata;
            for (int i = 0; i < maxTry; ++i) {
            bool found = false;
            foreach (Host host in metadata.AllHosts())
            {
                if (host.Address.Equals(address))
                {
                    found = true;
                    if (testHost(host, waitForDead))
                        return;
                }
            }
            if (waitForDead && !found)
                return;
            try { Thread.Sleep(1000); } catch (Exception e) {}
            }

            foreach(Host host in metadata.AllHosts())
            {
            if (host.Address.Equals(address)) {
                if (testHost(host, waitForDead)) {
                    return;
                } else {
                    // logging it because this give use the timestamp of when this happens
                    logger.Info(node + " is not " + (waitForDead ? "DOWN" : "UP") + " after " + maxTry + "s");
                    throw new InvalidOperationException(node + " is not " + (waitForDead ? "DOWN" : "UP") + " after " + maxTry + "s");
                }
            }
            }

            if (waitForOut){
            return;
            } else {
            logger.Info(node + " is not part of the cluster after " + maxTry + "s");
            throw new InvalidOperationException(node + " is not part of the cluster after " + maxTry + "s");
            }
        }
コード例 #4
0
 /// <summary>
 /// Creates the schema that it is going to be used in the samples.
 /// It is grouped into a helper to let the other classes to be cleaner.
 /// </summary>
 public static void CreateSchema(Cluster cluster)
 {
     //This part is not important for the sample purpose.
     //TL;DR
     var session = cluster.Connect();
     CreateKeyspace(session);
     CreateTimeSeriesTable(session);
     CreateForumTables(session);
 }
コード例 #5
0
ファイル: ColumnarDb.cs プロジェクト: Gravicode/IDLAKE
 public ColumnarDb(string DBName, ISchemaContext ctx, string UserName, string ClusterAddress = DefaultCluster)
 {
     this.UserName = UserName;
     this.DBName = DBName;
     this.ctx = ctx;
     cluster = Cluster.Builder().AddContactPoint(ClusterAddress).Build();
     SetDefaultConfig();
     //ISession session = cluster.Connect("demo");
 }
コード例 #6
0
 public CreateCat(
     IConfiguration config,
     ILogger <CreateCat> logger,
     cass.Cluster cluster)
 {
     _config  = config;
     _logger  = logger;
     _cluster = cluster;
 }
コード例 #7
0
ファイル: Session.cs プロジェクト: rasmus-s/csharp-driver
 internal Session(Cluster cluster, Configuration configuration, string keyspace, int binaryProtocolVersion)
 {
     Cluster = cluster;
     Configuration = configuration;
     Keyspace = keyspace;
     BinaryProtocolVersion = binaryProtocolVersion;
     Guid = Guid.NewGuid();
     UserDefinedTypes = new UdtMappingDefinitions(this);
     _connectionPool = new ConcurrentDictionary<IPAddress, HostConnectionPool>();
 }
コード例 #8
0
 public void Connect(String node)
 {
     _cluster = Cluster.Builder()
         .AddContactPoint(node).Build();
     Metadata metadata = _cluster.Metadata;
     Console.WriteLine("Connected to cluster: "
         + metadata.ClusterName.ToString());
     _session = _cluster.Connect();
      
 }
コード例 #9
0
 private ISession GetOrCreateSession(Cluster cluster, string keySpace)
 {
     ISession session;
     if (!_sessions.TryGetValue(cluster, out session))
     {
         session = cluster.Connect(keySpace);
         _sessions.TryAdd(cluster, session);
     }
     return session;
 }
コード例 #10
0
 public void init()
 {
     try
     {
         cluster = CassHosts.getCluster();
         Console.WriteLine("GOT CLUSTER");
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception Occurred Getting Cluster INIT  " + e);
     }
 }
コード例 #11
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         _cluster = Cluster.Builder().AddContactPoint("127.0.0.1").Build();
         _session = _cluster.Connect("demo");
         EscribirEnConsola("Conexión establecida correctamente");
     }
     catch(Exception ex)
     {
         EscribirEnConsola("Error al conectar con Cassandra. \n" + ex.Message);
     }
 }
コード例 #12
0
        public static void waitForDownWithWait(String node, Cluster cluster, int waitTime)
        {
            waitFor(node, cluster, 20, true, false);

            // FIXME: Once stop() works, remove this line
            try
            {
            Thread.Sleep(waitTime * 1000);
            }
            catch (InvalidQueryException e)
            {
            Debug.Write(e.StackTrace);
            }
        }
コード例 #13
0
        internal ControlConnection(Cluster cluster,
                                   IEnumerable<IPAddress> clusterEndpoints,
                                   Policies policies,
                                   ProtocolOptions protocolOptions,
                                   PoolingOptions poolingOptions,
                                   SocketOptions socketOptions,
                                   ClientOptions clientOptions,
                                   IAuthInfoProvider authProvider)
        {
            this._cluster = cluster;
            this._reconnectionSchedule = _reconnectionPolicy.NewSchedule();
            this._reconnectionTimer = new Timer(ReconnectionClb, null, Timeout.Infinite, Timeout.Infinite);

            _session = new Session(cluster, policies, protocolOptions, poolingOptions, socketOptions,
                                   clientOptions, authProvider, "", false);
        }
コード例 #14
0
        internal ControlConnection(Cluster cluster, 
                                   IEnumerable<IPAddress> clusterEndpoints,
                                   Policies policies,
                                   ProtocolOptions protocolOptions,
                                   PoolingOptions poolingOptions,
                                   SocketOptions socketOptions,
                                   ClientOptions clientOptions,
                                   IAuthInfoProvider authProvider,
                                   bool metricsEnabled)
        {
            this._cluster = cluster;
            this._reconnectionTimer = new Timer(ReconnectionClb, null, Timeout.Infinite, Timeout.Infinite);

            _session = new Session(cluster, clusterEndpoints, policies, protocolOptions, poolingOptions, socketOptions,
                                   clientOptions, authProvider, metricsEnabled, "", _cluster._hosts);
        }
コード例 #15
0
        public CassandraClient(IPortalFrontendSettings settings)
        {
            string[] nodeAddresses = settings.CassandraNodes;
            var privateAddresses = settings.CassandraPrivateAddresses;

            if (nodeAddresses.Length == 0)
            {
                throw new ArgumentException("settings");
            }

            // Credetials
            Builder clusterBuilder = Cluster.Builder();
            if (!string.IsNullOrEmpty(settings.CassandraUsername) && !string.IsNullOrEmpty(settings.CassandraPassword))
            {
                clusterBuilder = clusterBuilder.WithCredentials(settings.CassandraUsername, settings.CassandraPassword);
            }

            // Hosts
            clusterBuilder.AddContactPoints(nodeAddresses);

            if (privateAddresses.Length > 0)
            {
                if (privateAddresses.Length != nodeAddresses.Length)
                {
                    throw new ArgumentException("settings");
                }

                const int cqlPort = 9042;
                var addressMap = new Dictionary<IPEndPoint, IPEndPoint>(nodeAddresses.Length);
                for (int i = 0; i < nodeAddresses.Length; i++)
                {
                    // Create address map for cassandra nodes behind azure firewall
                    IPHostEntry host = Dns.GetHostEntry(nodeAddresses[i]);
                    var privateAddress = IPAddress.Parse(privateAddresses[i]);
                    var publicAddress = host.AddressList.First();

                    addressMap.Add(new IPEndPoint(privateAddress, cqlPort), new IPEndPoint(publicAddress, cqlPort));
                }

                clusterBuilder.WithAddressTranslator(new CassandraAddressTranslator(addressMap));
            }

            // Set heartbeat interval
            clusterBuilder.SocketOptions.SetIdleTimeoutMillis((int)TimeSpan.FromMinutes(3).TotalMilliseconds);

            _cluster = clusterBuilder.Build();
        }
コード例 #16
0
        void InitializeTenant(string tenant)
        {
            if (string.IsNullOrEmpty(tenant))
            {
                throw new ArgumentNullException(nameof(tenant));
            }

            string tenantPrefix = hasTenantsDefined ? $"{tenant}_" : string.Empty;
            var    keyspace     = $"{tenantPrefix}{settings.Keyspace}";

            if (keyspace.Length > 48)
            {
                throw new ArgumentException($"Cassandra keyspace exceeds maximum length of 48. Keyspace: {keyspace}");
            }

            DataStaxCassandra.Cluster cluster = null;
            if (ReferenceEquals(null, settings.Cluster))
            {
                cluster = DataStaxCassandra.Cluster
                          .Builder()
                          .WithReconnectionPolicy(settings.ReconnectionPolicy)
                          .WithRetryPolicy(settings.RetryPolicy)
                          .WithConnectionString(settings.ConnectionString)
                          .Build();
            }
            else
            {
                cluster = settings.Cluster;
            }

            var session        = cluster.Connect();
            var storageManager = new CassandraEventStoreStorageManager(session, keyspace, settings.EventStoreTableNameStrategy, settings.ReplicationStrategy);

            storageManager.CreateStorage();
            session.ChangeKeyspace(keyspace);
            var    serializer = builder.Container.Resolve <ISerializer>();
            string bc         = (this.settings as EventStore.Config.IEventStoreSettings).BoundedContext;
            var    eventStore = new CassandraEventStore(settings.BoundedContext, session, settings.EventStoreTableNameStrategy, serializer, settings.WriteConsistencyLevel, settings.ReadConsistencyLevel);
            var    player     = new CassandraEventStorePlayer(session, settings.EventStoreTableNameStrategy, bc, serializer);

            tenantStores.Add(tenant, eventStore);
            tenantPlayers.Add(tenant, player);
        }
コード例 #17
0
        public void checkKSMetadata()
        {
            CCMCluster = CCMBridge.CCMCluster.Create(2, Cluster.Builder());
            try
            {
                Session = CCMCluster.Session;
                Cluster = CCMCluster.Cluster;
                Session.CreateKeyspaceIfNotExists(Keyspace);
                Session.ChangeKeyspace(Keyspace);

                string keyspacename = "keyspace" + Guid.NewGuid().ToString("N").ToLower();
                bool durableWrites = false;
                string strgyClass = "SimpleStrategy";
                short rplctnFactor = 1;
                Session.Cluster.WaitForSchemaAgreement(
                    Session.Execute(
            string.Format(@"CREATE KEYSPACE {0}
             WITH replication = {{ 'class' : '{1}', 'replication_factor' : {2} }}
             AND durable_writes={3};"
            , keyspacename, strgyClass, rplctnFactor.ToString(), durableWrites.ToString())).QueriedHost
                );
                Session.ChangeKeyspace(keyspacename);

                for (int i = 0; i < 10; i++)
                    checkPureMetadata("table" + Guid.NewGuid().ToString("N"), keyspacename);

                KeyspaceMetadata ksmd = Cluster.Metadata.GetKeyspace(keyspacename);
                Assert.True(ksmd.DurableWrites == durableWrites);
                Assert.True(ksmd.Replication.Where(opt => opt.Key == "replication_factor").First().Value == rplctnFactor);
                Assert.True(ksmd.StrategyClass == strgyClass);

            }
            finally
            {
                CCMCluster.Discard();
            }
        }
コード例 #18
0
 public void Initialize(Cluster cluster)
 {
     this._cluster = cluster;
     _childPolicy.Initialize(cluster);
 }
コード例 #19
0
 public void Initialize(Cluster cluster)
 {
     this._cluster = cluster;
     this._index = StaticRandom.Instance.Next(cluster.Metadata.AllHosts().Count);
 }
コード例 #20
0
        public void checkMetadata(string TableName = null, string KeyspaceName = null, TableOptions tableOptions = null)
        {
            CCMCluster = CCMBridge.CCMCluster.Create(2, Cluster.Builder());
            try
            {
                Session = CCMCluster.Session;
                Cluster = CCMCluster.Cluster;
                Session.CreateKeyspaceIfNotExists(Keyspace);
                Session.ChangeKeyspace(Keyspace);

                checkPureMetadata(TableName, KeyspaceName, tableOptions);
            }
            finally
            {
                CCMCluster.Discard();
            }
        }
コード例 #21
0
        public void CreateKeyspaceWithPropertiesTest(string strategy_class)
        {
            CCMCluster = CCMBridge.CCMCluster.Create(2, Cluster.Builder());
            try
            {
                Session = CCMCluster.Session;
                Cluster = CCMCluster.Cluster;

                Randomm rndm = new Randomm(DateTime.Now.Millisecond);
                bool durable_writes = rndm.NextBoolean();

                int? replication_factor = null;
                int? data_centers_count = null;
                Dictionary<string, int> datacenters_replication_factors = null;

                if (strategy_class == ReplicationStrategies.SimpleStrategy)
                {
                    replication_factor = rndm.Next(1, 21);
                    Session.CreateKeyspaceIfNotExists(Keyspace,ReplicationStrategies.CreateSimpleStrategyReplicationProperty((int)replication_factor), durable_writes);
                    Session.ChangeKeyspace(Keyspace);
                }
                else
                    if (strategy_class == ReplicationStrategies.NetworkTopologyStrategy)
                    {
                        data_centers_count = rndm.Next(1, 11);
                        datacenters_replication_factors = new Dictionary<string, int>((int)data_centers_count);
                        for (int i = 0; i < data_centers_count; i++)
                            datacenters_replication_factors.Add("dc" + i.ToString(), rndm.Next(1, 21));
                        Session.CreateKeyspaceIfNotExists(Keyspace, ReplicationStrategies.CreateNetworkTopologyStrategyReplicationProperty(datacenters_replication_factors), durable_writes);
                    }

                KeyspaceMetadata ksmd = Cluster.Metadata.GetKeyspace(Keyspace);
                Assert.Equal(strategy_class, ksmd.StrategyClass);
                Assert.Equal(durable_writes, ksmd.DurableWrites);
                if (replication_factor != null)
                    Assert.Equal(replication_factor, ksmd.Replication["replication_factor"]);
                if (datacenters_replication_factors != null)
                    Assert.True(datacenters_replication_factors.SequenceEqual(ksmd.Replication));
            }
            finally
            {
                CCMCluster.Discard();
            }
        }
コード例 #22
0
        public void Open()
        {
            cluster = Cluster.Builder().AddContactPoint("127.0.0.1").Build();
            session = cluster.Connect("filewatch");
コード例 #23
0
 public void Initialize(Cluster cluster)
 {
     this._cluster = cluster;
     this._index   = StaticRandom.Instance.Next(cluster.Metadata.AllHosts().Count);
 }
コード例 #24
0
 public static void CreateCluster()
 {
     erroredOut = false;
     schemaCreated = false;
     cassandraCluster = CCMBridge.Create("test", 1);
     try
     {
         cluster = Cluster.Builder().AddContactPoints(IP_PREFIX + "1").Build();
         session = cluster.Connect();
     }
     catch (NoHostAvailableException e)
     {
         erroredOut = true;
         foreach (var entry in e.Errors)
             Trace.TraceError("Error connecting to " + entry.Key + ": " + entry.Value);
         throw new InvalidOperationException("", e);
     }
 }
コード例 #25
0
ファイル: CCMBridge.cs プロジェクト: hjarraya/csharp-driver
            public static void Build(Builder builder)
            {
                if (Options.Default.USE_COMPRESSION)
                {
                    builder.WithCompression(CompressionType.Snappy);
                    Console.WriteLine("Using Compression");
                }
                if (Options.Default.USE_NOBUFFERING)
                {
                    builder.WithoutRowSetBuffering();
                    Console.WriteLine("No buffering");
                }

                Cluster = builder.AddContactPoints(Options.Default.IP_PREFIX + "1").Build();
            }
コード例 #26
0
ファイル: CCMBridge.cs プロジェクト: hjarraya/csharp-driver
            public static void CreateCluster()
            {
                erroredOut = false;
                schemaCreated = false;
                cassandraCluster = CCMBridge.Create("test", 1);
                try
                {
                    var builder = Cluster.Builder().AddContactPoints(Options.Default.IP_PREFIX + "1");
                    if (Options.Default.USE_COMPRESSION)
                    {
                        builder.WithCompression(CompressionType.Snappy);
                        Console.WriteLine("Using Compression");
                    }
                    if (Options.Default.USE_NOBUFFERING)
                    {
                        builder.WithoutRowSetBuffering();
                        Console.WriteLine("No buffering");
                    }

                    cluster = builder.Build();
                    session = cluster.Connect();
                }
                catch (NoHostAvailableException e)
                {
                    erroredOut = true;
                    foreach (var entry in e.Errors)
                        Trace.TraceError("Error connecting to " + entry.Key + ": " + entry.Value);
                    throw new InvalidOperationException("", e);
                }
            }
コード例 #27
0
ファイル: CCMBridge.cs プロジェクト: hjarraya/csharp-driver
            private CCMCluster(CCMBridge ccmBridge, Builder builder)
            {
                int tryNo = 0;
                builder.AddContactPoints(Options.Default.IP_PREFIX + "1");
                if (Options.Default.USE_COMPRESSION)
                {
                    builder.WithCompression(CompressionType.Snappy);
                    Console.WriteLine("Using Compression");
                }
                if (Options.Default.USE_NOBUFFERING)
                {
                    builder.WithoutRowSetBuffering();
                    Console.WriteLine("No buffering");
                }

                this.Cluster = builder.Build();
                RETRY:
                this.CCMBridge = ccmBridge;
                try
                {
                    this.Session = Cluster.Connect();
                    if(tryNo>0)
                        Cluster.RefreshSchema();
                }
                catch (NoHostAvailableException e)
                {
                    if (tryNo < 10)
                    {
                        Console.WriteLine("CannotConnect to CCM node - give another try");
                        tryNo++;
                        Thread.Sleep(1000);
                        goto RETRY;
                    }
                    foreach (var entry in e.Errors)
                        Trace.TraceError("Error connecting to " + entry.Key + ": " + entry.Value);
                    throw new InvalidOperationException(null, e);
                }
            }
コード例 #28
0
 public void Initialize(Cluster cluster)
 {
     this._cluster = cluster;
 }
コード例 #29
0
        private int m_ttl = 2592000; //1 month

        #endregion

        #region IApplicationPlugin Members

        public void Initialize(OpenSimBase openSim)
        {
            IConfig config = openSim.ConfigSource.Source.Configs["ChatLogModule"];
            if (config == null) return;

            m_enabled = config.GetBoolean("Enabled", false) && config.GetString("Backend", "") == "Cassandra12Backend";
            m_debug = config.GetBoolean("Debug", m_debug);
            m_ttl = config.GetInt("TTL", m_ttl);

            Q_INS_TTL = Q_INSERT + m_ttl.ToString() + ";";

            if (m_enabled)
            {
                ExtractSeedNodesFromConfig(config);

                var clusterb = Cluster.Builder();

                foreach (string node in m_seedNodes)
                {
                    if (m_debug) m_log.DebugFormat("[CHATLOG.Cassandra]: Adding seed node {0}", node);
                    clusterb.AddContactPoint(node);
                }

                clusterb.WithDefaultKeyspace(KEYSPACE);
                
                m_cluster = clusterb.Build();
                m_session = m_cluster.Connect();

                ProviderRegistry.Instance.RegisterInterface<IChatMessageLogBackend>(this);
            }
        }
コード例 #30
0
ファイル: Basics.cs プロジェクト: abhijitchanda/csharp-driver
        public void SetFixture()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            var clusterb = Cluster.Builder().AddContactPoint("cassi.cloudapp.net");
            clusterb.WithDefaultKeyspace(Keyspace);

            if (Cassandra.MSTest.Properties.Settings.Default.Compression)
            {
                clusterb.WithCompression(CompressionType.Snappy);
                Console.WriteLine("Compression: Snappy Compression");
            }
            else Console.WriteLine("Compression: No Compression");

            Cluster = clusterb.Build();
            Diagnostics.CassandraTraceSwitch.Level = System.Diagnostics.TraceLevel.Verbose;
            Diagnostics.CassandraStackTraceIncluded = true;
            Diagnostics.CassandraPerformanceCountersEnabled = true;
            Session = Cluster.ConnectAndCreateDefaultKeyspaceIfNotExists(ReplicationStrategies.CreateSimpleStrategyReplicationProperty(2), true);
        }
コード例 #31
0
        public override void Open()
        {
            _connectionState = System.Data.ConnectionState.Connecting;

            lock (_clusters)
            {
                if (!_clusters.ContainsKey(_connectionStringBuilder.ClusterName))
                {
                    _managedCluster = _connectionStringBuilder.MakeClusterBuilder().Build();
                    _clusters.Add(_connectionStringBuilder.ClusterName, _managedCluster);
                }
                else
                    _managedCluster = _clusters[_connectionStringBuilder.ClusterName];
            }

            if (string.IsNullOrEmpty(_connectionStringBuilder.DefaultKeyspace))
                ManagedConnection = _managedCluster.Connect("");
            else
                ManagedConnection = _managedCluster.Connect(_connectionStringBuilder.DefaultKeyspace);

            _connectionState = System.Data.ConnectionState.Open;
        }
コード例 #32
0
 /// <summary>
 /// Use when you want to override all the default settings. You should use a connection string without the default keyspace and use the SetKeyspace method to specify it.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="self"></param>
 /// <param name="cluster">Fully configured Cassandra cluster object.</param>
 /// <returns></returns>
 public static T SetCluster <T>(this T self, DataStaxCassandra.Cluster cluster) where T : ICassandraEventStoreSettings
 {
     self.Cluster = cluster;
     return(self);
 }
コード例 #33
0
            private CCMCluster(CCMBridge cassandraCluster, Builder builder)
            {
                this.CassandraCluster = cassandraCluster;
                try
                {
                    this.Cluster = builder.AddContactPoints(IP_PREFIX + "1").Build();
                    this.Session = Cluster.Connect();

                }
                catch (NoHostAvailableException e)
                {
                    foreach (var entry in e.Errors)
                        Trace.TraceError("Error connecting to " + entry.Key + ": " + entry.Value);
                    throw new InvalidOperationException(null, e);
                }
            }
コード例 #34
0
ファイル: Session.cs プロジェクト: ntent-ad/csharp-driver
        internal Session(Cluster cluster,
                         Policies policies,
                         ProtocolOptions protocolOptions,
                         PoolingOptions poolingOptions,
                         SocketOptions socketOptions,
                         ClientOptions clientOptions,
                         IAuthInfoProvider authProvider,
                         string keyspace, bool init)
        {
            try
            {
                this._cluster = cluster;

                this._protocolOptions = protocolOptions;
                this._poolingOptions = poolingOptions;
                this._socketOptions = socketOptions;
                this._clientOptions = clientOptions;
                this._authProvider = authProvider;

                this._policies = policies ?? Policies.DefaultPolicies;

                this._policies.LoadBalancingPolicy.Initialize(_cluster);

                _keyspace = keyspace ?? clientOptions.DefaultKeyspace;

                Guid = Guid.NewGuid();

                _trashcanCleaner = new Timer(TranscanCleanup, null, Timeout.Infinite, Timeout.Infinite);

                if (init)
                {
                    var ci = this._policies.LoadBalancingPolicy.NewQueryPlan(null).GetEnumerator();
                    if (!ci.MoveNext())
                    {
                        var ex = new NoHostAvailableException(new Dictionary<IPAddress, List<Exception>>());
                        _logger.Error(ex.Message);
                        throw ex;
                    }

                    var triedHosts = new List<IPAddress>();
                    var innerExceptions = new Dictionary<IPAddress, List<Exception>>();
                    int streamId;
                    var con = Connect(ci, triedHosts, innerExceptions, out streamId);
                    con.FreeStreamId(streamId);
                }
            }
            catch
            {
                InternalDispose();
                throw;
            }
        }