Skip to content

Instantly share code, notes, and snippets.

@dizzyd
Created September 3, 2010 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dizzyd/564501 to your computer and use it in GitHub Desktop.
Save dizzyd/564501 to your computer and use it in GitHub Desktop.
-module(riakringer).
-compile(export_all).
assign(Partition, ToNode) ->
F = fun(Ring, _) ->
{new_ring, riak_core_ring:transfer_node(Partition, ToNode, Ring)}
end,
{ok, _} = riak_core_ring_manager:ring_trans(F, undefined),
ok.
check_ring() ->
{ok, R} = riak_core_ring_manager:get_my_ring(),
check_ring(R).
check_ring(Ring) ->
{ok, Props} = application:get_env(riak_core, default_bucket_props),
{n_val, Nval} = lists:keyfind(n_val, 1, Props),
Preflists = riak_core_ring:all_preflists(Ring, Nval),
lists:foldl(fun(PL,Acc) ->
PLNodes = lists:usort([Node || {_,Node} <- PL]),
case length(PLNodes) of
Nval ->
Acc;
_ ->
ordsets:add_element(PL, Acc)
end
end, [], Preflists).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment