How to find which nodes host a particular bucket/key?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to find which nodes host a particular bucket/key?

Jay Doane
Can anyone suggest how to determine the nodes on which a particular bucket/key are hosted in a cluster?

Thanks,
Jay



_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: How to find which nodes host a particular bucket/key?

Charlie Voiselle
You can use the following Erlang snippet in `riak attach`:

N=3,
{ok,Ring} = riak_core_ring_manager:get_my_ring(),
DocIdx = riak_core_util:chash_key({<<"my_bucket">>, <<"my_key">>}),
<<I:160/integer>> = DocIdx,
Preflist = riak_core_ring:preflist(DocIdx, Ring),
{Targets, Fallbacks} = lists:split(N, Preflist),
Targets.

Verify that `N` matches your clusters N-val. Change `my_bucket` and `my_key` as appropriate.  If all of your nodes are up and healthy, this will give you the primaries in the `Targets` variable and the fallback partitions in order of preference in `Fallbacks`.

Regards,
Charlie Voiselle
Basho Client Services


On Jan 12, 2015, at 4:28 PM, Jay Doane <[hidden email]> wrote:

Can anyone suggest how to determine the nodes on which a particular bucket/key are hosted in a cluster?

Thanks,
Jay


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com