You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Clint Kelly <cl...@gmail.com> on 2014/02/28 19:27:38 UTC

Any way to get a list of per-node token ranges using the DataStax Java driver?

Hi everyone,

I've been working on a rewrite of the Cassandra InputFormat for Hadoop 2
using the DataStax Java driver instead of the Thrift API.

I have a prototype working now, but there is one bit of code that I have
not been able to replace with code for the Java driver.  In the
InputFormat#getSplits method, the old code has a call like the following:

          map = client.describe_ring(ConfigHelper.getInputKeyspace(conf));

This gets a list of the distinct token ranges for the Cassandra cluster.

The rest of "getSplits" then takes these key ranges, breaks them up into
subranges (to match the user-specified input split size), and then gets the
replica nodes for the various token ranges (as the locations for the
splits).

Does anyone know how I can do the following with the native protocol?

   - Get the distinct token ranges for the C* cluster
   - Get the set of replica nodes for a given range of tokens?

I tried looking around in Cluster and Metadata, among other places, in the
API docs, but I didn't see anything that looked like it would do what I
want.

Thanks!

Best regards,
Clint

Re: Any way to get a list of per-node token ranges using the DataStax Java driver?

Posted by Tupshin Harper <tu...@tupshin.com>.
For the first question, try "select * from system.peers"

http://www.datastax.com/documentation/cql/cql_using/use_query_system_c.html?pagename=docs&version=1.2&file=cql_cli/using/query_system_tables

For the second, there is a JMX and nodetool command, but I'm not aware of
any way to get it directly through CQL.

http://www.datastax.com/documentation/cassandra/2.0/cassandra/tools/toolsGetEndPoints.html

-Tupshin


On Fri, Feb 28, 2014 at 1:27 PM, Clint Kelly <cl...@gmail.com> wrote:

> Hi everyone,
>
> I've been working on a rewrite of the Cassandra InputFormat for Hadoop 2
> using the DataStax Java driver instead of the Thrift API.
>
> I have a prototype working now, but there is one bit of code that I have
> not been able to replace with code for the Java driver.  In the
> InputFormat#getSplits method, the old code has a call like the following:
>
>           map = client.describe_ring(ConfigHelper.getInputKeyspace(conf));
>
> This gets a list of the distinct token ranges for the Cassandra cluster.
>
> The rest of "getSplits" then takes these key ranges, breaks them up into
> subranges (to match the user-specified input split size), and then gets the
> replica nodes for the various token ranges (as the locations for the
> splits).
>
> Does anyone know how I can do the following with the native protocol?
>
>    - Get the distinct token ranges for the C* cluster
>    - Get the set of replica nodes for a given range of tokens?
>
> I tried looking around in Cluster and Metadata, among other places, in the
> API docs, but I didn't see anything that looked like it would do what I
> want.
>
> Thanks!
>
> Best regards,
> Clint
>