Exemple #1
0
 public IKeyspace Create(
     ICassandraClient client,
     string keyspaceName,
     IDictionary <string, Dictionary <string, string> > keyspaceDesc,
     ConsistencyLevel consistencyLevel,
     FailoverPolicy failoverPolicy,
     IKeyedObjectPool <Endpoint, ICassandraClient> pool)
 {
     return(new Keyspace(
                client,
                keyspaceName,
                keyspaceDesc,
                consistencyLevel,
                failoverPolicy,
                pool,
                monitor
                ));
 }
        public IKeyspace Create(
			ICassandraClient client,
			string keyspaceName,
			IDictionary<string, Dictionary<string, string>> keyspaceDesc,
			ConsistencyLevel consistencyLevel,
			FailoverPolicy failoverPolicy,
			IKeyedObjectPool<Endpoint, ICassandraClient> pool)
        {
            return new Keyspace(
                client,
                keyspaceName,
                keyspaceDesc,
                consistencyLevel,
                failoverPolicy,
                pool,
                monitor
                );
        }
Exemple #3
0
        public Keyspace(
			ICassandraClient client,
			string keyspaceName,
			IDictionary<string, Dictionary<string, string>> description,
			ConsistencyLevel consistencyLevel,
			FailoverPolicy failoverPolicy,
			IKeyedObjectPool<Endpoint, ICassandraClient> pool,
			ICassandraClientMonitor monitor)
        {
            if (client == null)
                throw new ArgumentNullException("client");

            this.Client = client;
            this.ConsistencyLevel = consistencyLevel;
            this.Description = description;
            this.Name = keyspaceName;
            this.cassandra = client.Client as Cassandra.Client;
            this.FailoverPolicy = failoverPolicy;
            this.pool = pool;
            this.monitor = monitor;
            InitFailover();
        }
Exemple #4
0
        public Keyspace(
            ICassandraClient client,
            string keyspaceName,
            IDictionary <string, Dictionary <string, string> > description,
            ConsistencyLevel consistencyLevel,
            FailoverPolicy failoverPolicy,
            IKeyedObjectPool <Endpoint, ICassandraClient> pool,
            ICassandraClientMonitor monitor)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            this.Client           = client;
            this.ConsistencyLevel = consistencyLevel;
            this.Description      = description;
            this.Name             = keyspaceName;
            this.cassandra        = client.Client as Cassandra.Client;
            this.FailoverPolicy   = failoverPolicy;
            this.pool             = pool;
            this.monitor          = monitor;
            InitFailover();
        }
 /// <summary>
 /// Creates a unique map name for the keyspace and its consistency level
 /// </summary>
 /// <param name="keyspaceName"></param>
 /// <param name="consistencyLevel"></param>
 /// <param name="failoverPolicy"></param>
 /// <returns></returns>
 string BuildKeyspaceMapName(string keyspaceName, ConsistencyLevel consistencyLevel, FailoverPolicy failoverPolicy)
 {
     return string.Format("{0}[{1},{2}]", keyspaceName, consistencyLevel, failoverPolicy);
 }
        public IKeyspace GetKeyspace(string keyspaceName, ConsistencyLevel consistencyLevel, FailoverPolicy failoverPolicy)
        {
            var key = BuildKeyspaceMapName(keyspaceName, consistencyLevel, failoverPolicy);

            IKeyspace keyspace;

            if (keyspaceMap.ContainsKey(key))
                keyspace = keyspaceMap[key];
            else
            {
                if (Keyspaces.Contains(keyspaceName))
                {
                    IDictionary<string, Dictionary<string, string>> keyspaceDesc = null;

                    keyspaceDesc = cassandra.describe_keyspace(keyspaceName);
                    keyspace = keyspaceFactory.Create(this, keyspaceName, keyspaceDesc,
                         consistencyLevel, failoverPolicy, pool);
                    IKeyspace tmp = null;
                    if (!keyspaceMap.ContainsKey(key))
                    {
                        keyspaceMap.Add(key, keyspace);
                        tmp = keyspaceMap[key];
                    }
                    if (tmp != null)
                        // There was another put that got here before we did.
                        keyspace = tmp;
                }
                else
                    throw new Exception("Requested key space not exist, keyspaceName=" + keyspaceName);
            }
            return keyspace;
        }
Exemple #7
0
 /// <summary>
 /// Creates a unique map name for the keyspace and its consistency level
 /// </summary>
 /// <param name="keyspaceName"></param>
 /// <param name="consistencyLevel"></param>
 /// <param name="failoverPolicy"></param>
 /// <returns></returns>
 string BuildKeyspaceMapName(string keyspaceName, ConsistencyLevel consistencyLevel, FailoverPolicy failoverPolicy)
 {
     return(string.Format("{0}[{1},{2}]", keyspaceName, consistencyLevel, failoverPolicy));
 }
Exemple #8
0
        public IKeyspace GetKeyspace(string keyspaceName, ConsistencyLevel consistencyLevel, FailoverPolicy failoverPolicy)
        {
            var key = BuildKeyspaceMapName(keyspaceName, consistencyLevel, failoverPolicy);

            IKeyspace keyspace;

            if (keyspaceMap.ContainsKey(key))
            {
                keyspace = keyspaceMap[key];
            }
            else
            {
                if (Keyspaces.Contains(keyspaceName))
                {
                    IDictionary <string, Dictionary <string, string> > keyspaceDesc = null;

                    keyspaceDesc = cassandra.describe_keyspace(keyspaceName);
                    keyspace     = keyspaceFactory.Create(this, keyspaceName, keyspaceDesc,
                                                          consistencyLevel, failoverPolicy, pool);
                    IKeyspace tmp = null;
                    if (!keyspaceMap.ContainsKey(key))
                    {
                        keyspaceMap.Add(key, keyspace);
                        tmp = keyspaceMap[key];
                    }
                    if (tmp != null)
                    {
                        // There was another put that got here before we did.
                        keyspace = tmp;
                    }
                }
                else
                {
                    throw new Exception("Requested key space not exist, keyspaceName=" + keyspaceName);
                }
            }
            return(keyspace);
        }