public CassandraTestFixture()
 {
     Pool = new CassandraClientPoolFactory().Create();
     Client = new KeyedCassandraClientFactory(Pool, new KeyedCassandraClientFactory.Config { Timeout = 10 })
         .Make(new Endpoint("localhost", 9160));
     Keyspace = Client.GetKeyspace("Keyspace1", ConsistencyLevel.ONE, new FailoverPolicy(0) { Strategy = FailoverStrategy.FAIL_FAST });
 }
Example #2
0
        public HectorSharpFixture()
        {
            CassandraRunner.CleanData();
            CassandraRunner.Start();

            Pool = new CassandraClientPoolFactory().Create();
            Client = new KeyedCassandraClientFactory(Pool, new KeyedCassandraClientFactory.Config { Timeout = 10 })
                .Make(new Endpoint("localhost", 9060));
            Keyspace = Client.GetKeyspace("Keyspace1", ConsistencyLevel.ONE, new FailoverPolicy(0) { Strategy = FailoverStrategy.FAIL_FAST });
        }
Example #3
0
        /**
         * Call this method to run the code within the {@link #execute(Keyspace)} method.
         *
         * @param host
         * @param port
         * @param keyspace
         * @return
         * @throws Exception
         */
        public sealed OUTPUT execute(Endpoint endpoint, String keyspace)
        {
            IKeyspace ks = GetPool(endpoint).Borrow().getKeyspace(keyspace);

            try
            {
                return(execute(ks));
            }
            finally
            {
                getPool().releaseClient(ks.getClient());
            }
        }
Example #4
0
        public HectorSharpFixture()
        {
            CassandraRunner.CleanData();
            CassandraRunner.Start();

            Pool   = new CassandraClientPoolFactory().Create();
            Client = new KeyedCassandraClientFactory(Pool, new KeyedCassandraClientFactory.Config {
                Timeout = 10
            })
                     .Make(new Endpoint("localhost", 9060));
            Keyspace = Client.GetKeyspace("Keyspace1", ConsistencyLevel.ONE, new FailoverPolicy(0)
            {
                Strategy = FailoverStrategy.FAIL_FAST
            });
        }
Example #5
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);
        }
Example #6
0
 public void RemoveKeyspace(IKeyspace k)
 {
     string key = BuildKeyspaceMapName(k.Name, k.ConsistencyLevel, k.FailoverPolicy);
     keyspaceMap.Remove(key);
 }
Example #7
0
        public void RemoveKeyspace(IKeyspace k)
        {
            string key = BuildKeyspaceMapName(k.Name, k.ConsistencyLevel, k.FailoverPolicy);

            keyspaceMap.Remove(key);
        }
Example #8
0
 /**
  * Implement this abstract method to operate on cassandra.
  *
  * the given keyspace is the keyspace referenced by {@link #execute(String, int, String)}.
  * The method {@link #execute(String, int, String)} calls this method internally and provides it
  * with the keyspace reference.
  *
  * @param ks
  * @return
  * @throws Exception
  */
 public abstract OUTPUT execute(IKeyspace ks);
Example #9
0
 public Void execute(IKeyspace ks) {
   ks.insert(key, createColumnPath(COLUMN_NAME), bytes(value));
   return null;
 }
Example #10
0
 public Void execute(IKeyspace ks)
 {
     ks.insert(key, createColumnPath(COLUMN_NAME), bytes(value));
     return(null);
 }