You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Dan Kinder <dk...@turnitin.com> on 2015/03/26 21:21:39 UTC

Finding nodes that own a given token/partition key

Hey all,

In certain cases it would be useful for us to find out which node(s) have
the data for a given token/partition key.

The only solutions I'm aware of is to select from system.local and/or
system.peers to grab the host_id and tokens, do `SELECT token(thing) FROM
myks.mytable WHERE thing = 'value';`, then do the math (put the ring
together) and figure out which node has the data. I'm assuming this is what
token aware drivers are doing.

Is there a simpler way to do this?

A bit more context: we'd like to move some processing closer to data, but
for a few reasons hadoop/spark aren't good options for the moment.

Re: Finding nodes that own a given token/partition key

Posted by Dan Kinder <dk...@turnitin.com>.
Thanks guys, think both of these answer my question. Guess I had overlooked
nodetool getendpoints. Hopefully findable by future googlers now.

On Thu, Mar 26, 2015 at 2:37 PM, Adam Holmberg <ad...@datastax.com>
wrote:

> Dan,
>
> Depending on your context, many of the DataStax drivers have the token
> ring exposed client-side.
>
> For example,
> Python:
> http://datastax.github.io/python-driver/api/cassandra/metadata.html#tokens-and-ring-topology
> Java:
> http://www.datastax.com/drivers/java/2.1/com/datastax/driver/core/Metadata.html
>
> You may not have to construct this yourself.
>
> Adam Holmberg
>
> On Thu, Mar 26, 2015 at 3:53 PM, Roman Tkachenko <ro...@mailgunhq.com>
> wrote:
>
>> Hi Dan,
>>
>> Have you tried using "nodetool getendpoints"? It shows you nodes that
>> currently own the specific key.
>>
>> Roman
>>
>> On Thu, Mar 26, 2015 at 1:21 PM, Dan Kinder <dk...@turnitin.com> wrote:
>>
>>> Hey all,
>>>
>>> In certain cases it would be useful for us to find out which node(s)
>>> have the data for a given token/partition key.
>>>
>>> The only solutions I'm aware of is to select from system.local and/or
>>> system.peers to grab the host_id and tokens, do `SELECT token(thing) FROM
>>> myks.mytable WHERE thing = 'value';`, then do the math (put the ring
>>> together) and figure out which node has the data. I'm assuming this is what
>>> token aware drivers are doing.
>>>
>>> Is there a simpler way to do this?
>>>
>>> A bit more context: we'd like to move some processing closer to data,
>>> but for a few reasons hadoop/spark aren't good options for the moment.
>>>
>>
>>
>


-- 
Dan Kinder
Senior Software Engineer
Turnitin – www.turnitin.com
dkinder@turnitin.com

Re: Finding nodes that own a given token/partition key

Posted by Adam Holmberg <ad...@datastax.com>.
Dan,

Depending on your context, many of the DataStax drivers have the token ring
exposed client-side.

For example,
Python:
http://datastax.github.io/python-driver/api/cassandra/metadata.html#tokens-and-ring-topology
Java:
http://www.datastax.com/drivers/java/2.1/com/datastax/driver/core/Metadata.html

You may not have to construct this yourself.

Adam Holmberg

On Thu, Mar 26, 2015 at 3:53 PM, Roman Tkachenko <ro...@mailgunhq.com>
wrote:

> Hi Dan,
>
> Have you tried using "nodetool getendpoints"? It shows you nodes that
> currently own the specific key.
>
> Roman
>
> On Thu, Mar 26, 2015 at 1:21 PM, Dan Kinder <dk...@turnitin.com> wrote:
>
>> Hey all,
>>
>> In certain cases it would be useful for us to find out which node(s) have
>> the data for a given token/partition key.
>>
>> The only solutions I'm aware of is to select from system.local and/or
>> system.peers to grab the host_id and tokens, do `SELECT token(thing) FROM
>> myks.mytable WHERE thing = 'value';`, then do the math (put the ring
>> together) and figure out which node has the data. I'm assuming this is what
>> token aware drivers are doing.
>>
>> Is there a simpler way to do this?
>>
>> A bit more context: we'd like to move some processing closer to data, but
>> for a few reasons hadoop/spark aren't good options for the moment.
>>
>
>

Re: Finding nodes that own a given token/partition key

Posted by Roman Tkachenko <ro...@mailgunhq.com>.
Hi Dan,

Have you tried using "nodetool getendpoints"? It shows you nodes that
currently own the specific key.

Roman

On Thu, Mar 26, 2015 at 1:21 PM, Dan Kinder <dk...@turnitin.com> wrote:

> Hey all,
>
> In certain cases it would be useful for us to find out which node(s) have
> the data for a given token/partition key.
>
> The only solutions I'm aware of is to select from system.local and/or
> system.peers to grab the host_id and tokens, do `SELECT token(thing) FROM
> myks.mytable WHERE thing = 'value';`, then do the math (put the ring
> together) and figure out which node has the data. I'm assuming this is what
> token aware drivers are doing.
>
> Is there a simpler way to do this?
>
> A bit more context: we'd like to move some processing closer to data, but
> for a few reasons hadoop/spark aren't good options for the moment.
>