Skip to content

Instantly share code, notes, and snippets.

@bsparrow435
Created July 31, 2013 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bsparrow435/6125903 to your computer and use it in GitHub Desktop.
Save bsparrow435/6125903 to your computer and use it in GitHub Desktop.
This will identify the node/partitions that own a given bucket/key.
Bucket = <<"d">>,
Key = <<"e0c97a4cde6c">>,
BKey = {Bucket,Key},
{ok, Ring} = riak_core_ring_manager:get_my_ring(),
DocIdx = riak_core_util:chash_key(BKey),
BucketProps = riak_core_bucket:get_bucket(Bucket, Ring),
[NValue] = [Y || {X1, Y} <- BucketProps, n_val == X1],
UpNodes = riak_core_node_watcher:nodes(riak_kv),
Preflist2 = riak_core_apl:get_apl_ann(DocIdx, NValue, Ring, UpNodes),
Preflist = [{IndexNode, Type} || {IndexNode, Type} <- Preflist2].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment