private static IConnectionProvider CreateProvider(ConnectionBuilder builder)
 {
     if (builder.Pooled)
         return new PooledConnectionProvider(builder);
     else
         return new NormalConnectionProvider(builder);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="builder"></param>
        public PooledConnectionProvider(ConnectionBuilder builder)
            : base(builder)
        {
            PoolSize = builder.PoolSize;
            Lifetime = builder.Lifetime;

            _maintenanceTimer = new Timer(o => Cleanup(), null, 30000L, 30000L);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="builder"></param>
        public NormalConnectionProvider(ConnectionBuilder builder)
            : base(builder)
        {
            if (builder.Servers.Count > 1 && builder.Timeout == 0)
                throw new CassandraException("You must specify a timeout when using multiple servers.");

            Timeout = builder.Timeout;
            ActiveServers = builder.Servers;
        }
        public static IConnectionProvider Get(ConnectionBuilder connectionBuilder)
        {
            using (TimedLock.Lock(_lock))
            {
                IConnectionProvider provider;

                if (!_providers.TryGetValue(connectionBuilder.ConnectionString, out provider))
                {
                    provider = CreateProvider(connectionBuilder);
                    _providers.Add(connectionBuilder.ConnectionString, provider);
                }

                return provider;
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="builder"></param>
 protected ConnectionProvider(ConnectionBuilder builder)
 {
     Builder = builder;
 }
 public CassandraSession(ConnectionBuilder connectionBuilder)
     : this(ConnectionProviderFactory.Get(connectionBuilder), connectionBuilder.ReadConsistency, connectionBuilder.WriteConsistency)
 {
 }