Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add chash API to `riak_core_ring`

Repair needs to get at the hash ring to build it's key filter.
  • Loading branch information...
commit bfc5f5fab16dbbf6335a4e05a0b642505dbea79f 1 parent c5b9e1d
@rzezeski rzezeski authored
Showing with 8 additions and 2 deletions.
  1. +7 −1 src/riak_core_ring.erl
  2. +1 −1  src/riak_core_vnode_manager.erl
View
8 src/riak_core_ring.erl
@@ -106,7 +106,8 @@
set_cluster_name/2,
reconcile_names/2,
reconcile_members/2,
- is_primary/2]).
+ is_primary/2,
+ chash/1]).
-export_type([riak_core_ring/0]).
@@ -248,6 +249,11 @@ is_primary(Ring, IdxNode) ->
Owners = all_owners(Ring),
lists:member(IdxNode, Owners).
+%% @doc Return the `CHash' of the ring.
+-spec chash(chstate()) -> CHash::chash:chash().
+chash(?CHSTATE{chring=CHash}) ->
+ CHash.
+
%% @doc Produce a list of all nodes that are members of the cluster
-spec all_members(State :: chstate()) -> [Node :: term()].
all_members(?CHSTATE{members=Members}) ->
View
2  src/riak_core_vnode_manager.erl
@@ -755,7 +755,7 @@ check_up(Pairs, UpNodes) ->
[{Partition::non_neg_integer(), Owner::node()}].
repair_pairs(Ring, Partition) ->
Owner = riak_core_ring:index_owner(Ring, Partition),
- CH = element(4, Ring),
+ CH = riak_core_ring:chash(Ring),
[_, Before] = chash:predecessors(<<Partition:160/integer>>, CH, 2),
[After] = chash:successors(<<Partition:160/integer>>, CH, 1),
[Before, {Partition, Owner}, After].
Please sign in to comment.
Something went wrong with that request. Please try again.