Skip to content

Commit

Permalink
first version adding describe ring
Browse files Browse the repository at this point in the history
  • Loading branch information
axs committed Apr 4, 2011
1 parent 72c0ab2 commit 66bc7e8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
16 changes: 15 additions & 1 deletion libcassandra/cassandra.cc
Expand Up @@ -132,6 +132,11 @@ void Cassandra::insertColumn(const string& key,
col.ttl=ttl;
col.__isset.ttl=true;
}


if ((int)key.size() ==0){
level = ConsistencyLevel::QUORUM;
}
/*
* actually perform the insert
* TODO - validate the ColumnParent before the insert
Expand Down Expand Up @@ -329,7 +334,7 @@ vector<Column> Cassandra::getSliceNames(const string& key,
vector<ColumnOrSuperColumn> ret_cosc;
vector<Column> result;
/* damn you thrift! */
pred.__isset.column_names= true;
// pred.__isset.column_names= true;
thrift_client->get_slice(ret_cosc, key, col_parent, pred, level);
for (vector<ColumnOrSuperColumn>::iterator it= ret_cosc.begin();
it != ret_cosc.end();
Expand Down Expand Up @@ -609,6 +614,15 @@ int Cassandra::getPort() const
}


std::vector<org::apache::cassandra::TokenRange> Cassandra::describeRing(std::string keyspace) {

vector<org::apache::cassandra::TokenRange> ret;
thrift_client->describe_ring(ret, keyspace);
return ret;

}


bool Cassandra::findKeyspace(const string& name)
{
for (vector<KeyspaceDefinition>::iterator it= key_spaces.begin();
Expand Down
9 changes: 8 additions & 1 deletion libcassandra/cassandra.h
Expand Up @@ -345,7 +345,7 @@ class Cassandra
const int32_t count);

/**
* Return a list of slices using the given query object
* Returns a list of slices using the given query object
* @param[in] query object that encapuslates everything needed
* for a query using secondary indexes
* @return a map of row keys to column names and values
Expand Down Expand Up @@ -421,6 +421,13 @@ class Cassandra
*/
int getPort() const;

/**
* Gets the token ring; a map of ranges to host addresses. Represented as a set of TokenRange
* @param[in] keyspace the name of the keyspace
* @return token ring map
*/
std::vector<org::apache::cassandra::TokenRange> describeRing(std::string keyspace);

private:

/**
Expand Down
4 changes: 3 additions & 1 deletion libcassandra/cassandra_factory.cc
Expand Up @@ -66,14 +66,16 @@ CassandraFactory::~CassandraFactory() {}
tr1::shared_ptr<Cassandra> CassandraFactory::create()
{
CassandraClient *thrift_client= createThriftClient(host, port);
CassandraClient *thrift_client = 0;
tr1::shared_ptr<Cassandra> ret(new Cassandra(thrift_client, host, port));
return ret;
}


tr1::shared_ptr<Cassandra> CassandraFactory::create(const string& keyspace)
{
CassandraClient *thrift_client= createThriftClient(host, port);
// CassandraClient *thrift_client= createThriftClient(host, port);
CassandraClient *thrift_client = 0;
tr1::shared_ptr<Cassandra> ret(new Cassandra(thrift_client, host, port, keyspace));
return ret;
}
Expand Down

0 comments on commit 66bc7e8

Please sign in to comment.