Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix issues with previous merge and cleanup some -specs

Merge of 'gh177-staged-clustering' and 'master' had a few issues.

Re-add "clear member metadata on leave" logic that was removed in merge.
Re-add riak_core_ring:cancel_transfers/1 that was removed in merge.
Perform minor code clean-up.
Fix some typespecs to make dialyzer happier (more work still needed).

This finalizes integration into 'master' for #181
  • Loading branch information...
commit 03c333385d16674c02701d4cee8ce75d701f8b51 1 parent 8480b43
@jtuple jtuple authored
Showing with 33 additions and 9 deletions.
  1. +6 −5 src/riak_core_claimant.erl
  2. +27 −4 src/riak_core_ring.erl
View
11 src/riak_core_claimant.erl
@@ -80,7 +80,7 @@ start_link() ->
%% modifications that correspond to each resulting cluster transition
%% (eg. the initial transition that applies the staged changes, and
%% any additional transitions triggered by later rebalancing).
--spec plan() -> legacy | {ok, [action()], [ring_transition()]}.
+-spec plan() -> {error, term()} | {ok, [action()], [ring_transition()]}.
plan() ->
gen_server:call(claimant(), plan, infinity).
@@ -88,7 +88,7 @@ plan() ->
%% A commit is only allowed to succeed if the ring is ready and if the
%% current set of changes matches those computed by the most recent
%% call to plan/0.
--spec commit() -> true | false.
+-spec commit() -> ok | {error, term()}.
commit() ->
gen_server:call(claimant(), commit, infinity).
@@ -669,7 +669,9 @@ maybe_remove_exiting(Node, CState) ->
Changed = (Exiting /= []),
CState2 =
lists:foldl(fun(ENode, CState0) ->
- riak_core_ring:set_member(Node, CState0, ENode,
+ ClearedCS =
+ riak_core_ring:clear_member_meta(Node, CState0, ENode),
+ riak_core_ring:set_member(Node, ClearedCS, ENode,
invalid, same_vclock)
end, CState, Exiting),
{Changed, CState2};
@@ -824,7 +826,6 @@ rebalance_ring(CNode, CState) ->
rebalance_ring(CNode, Next, CState).
rebalance_ring(_CNode, [], CState) ->
-
CState2 = riak_core_claim:claim(CState),
Owners1 = riak_core_ring:all_owners(CState),
Owners2 = riak_core_ring:all_owners(CState2),
@@ -871,7 +872,7 @@ remove_node(CState, Node, Status, Replacing, Seed, Log) ->
remove_node(CState, Node, Status, Replacing, Seed, Log, Indices).
%% @private
-remove_node(CState, _Node, _Status, _Log, _Replacing, _Seed, []) ->
+remove_node(CState, _Node, _Status, _Replacing, _Seed, _Log, []) ->
CState;
remove_node(CState, Node, Status, Replacing, Seed, Log, Indices) ->
CStateT1 = riak_core_ring:change_owners(CState,
View
31 src/riak_core_ring.erl
@@ -66,6 +66,7 @@
pretty_print/2,
all_member_status/1,
update_member_meta/5,
+ clear_member_meta/3,
get_member_meta/3,
add_member/3,
remove_member/3,
@@ -90,6 +91,7 @@
future_indices/2,
future_ring/1,
disowning_indices/2,
+ cancel_transfers/1,
pending_changes/1,
next_owner/1,
next_owner/2,
@@ -137,7 +139,7 @@
meta % dict of cluster-wide other data (primarily bucket N-value, etc)
}).
--type member_status() :: valid | invalid | leaving | exiting.
+-type member_status() :: joining | valid | invalid | leaving | exiting | down.
%% type meta_entry(). Record for each entry in #chstate.meta
-record(meta_entry, {
@@ -531,7 +533,7 @@ increment_ring_version(Node, State) ->
State?CHSTATE{rvsn=RVsn}.
%% @doc Returns the current membership status for a node in the cluster.
--spec member_status(State :: chstate(), Node :: node()) -> member_status().
+-spec member_status(chstate() | [node()], Node :: node()) -> member_status().
member_status(?CHSTATE{members=Members}, Node) ->
member_status(Members, Node);
member_status(Members, Node) ->
@@ -581,11 +583,28 @@ update_member_meta(Node, State, Member, Key, Val, same_vclock) ->
State
end.
+clear_member_meta(Node, State, Member) ->
+ Members = State?CHSTATE.members,
+ case orddict:is_key(Member, Members) of
+ true ->
+ Members2 = orddict:update(Member,
+ fun({Status, VC, _MD}) ->
+ {Status,
+ vclock:increment(Node, VC),
+ orddict:new()}
+ end,
+ Members),
+ State?CHSTATE{members=Members2};
+ false ->
+ State
+ end.
+
add_member(PNode, State, Node) ->
set_member(PNode, State, Node, joining).
remove_member(PNode, State, Node) ->
- set_member(PNode, State, Node, invalid).
+ State2 = clear_member_meta(PNode, State, Node),
+ set_member(PNode, State2, Node, invalid).
leave_member(PNode, State, Node) ->
set_member(PNode, State, Node, leaving).
@@ -823,7 +842,11 @@ pretty_print(Ring, Opts) ->
end, 1, Indices),
io:format(Out, "~n", [])
end.
-
+
+%% @doc Return a ring with all transfers cancelled - for claim sim
+cancel_transfers(Ring) ->
+ Ring?CHSTATE{next=[]}.
+
%% ===================================================================
%% Legacy reconciliation
%% ===================================================================
Please sign in to comment.
Something went wrong with that request. Please try again.