Skip to content

Commit

Permalink
Revert "Refactor few bits"
Browse files Browse the repository at this point in the history
This reverts commit 17e05c0.
  • Loading branch information
loucash committed Mar 16, 2015
1 parent 17e05c0 commit 891c7a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
22 changes: 12 additions & 10 deletions src/riak_governor_ensemble_master.erl
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,18 @@ ensure_ensemble_started([_]) ->
% do not create an ensemble for group of one
ok;
ensure_ensemble_started(Nodes) ->
Fns = [
fun() -> is_local_ensemble(Nodes) end,
fun() -> ensemble_started(Nodes) end,
fun() -> start_ensemble(Nodes) end,
fun() -> add_ensemble_to_index(Nodes) end
],
riak_governor_util:whileok(Fns).
ShouldStart = ordsets:is_element(node(), Nodes),
AlreadyStarted = ensemble_started(Nodes),
case ShouldStart andalso not AlreadyStarted of
true ->
case start_ensemble(Nodes) of
ok ->
add_ensemble_to_index(Nodes),
ok;
Other -> Other
end;
false -> ok
end.

%% Determine the set of ensembles. Currently, there is one ensemble of each
%% unique set of preflist owning nodes.
Expand All @@ -125,9 +130,6 @@ add_ensemble_to_index(Nodes) ->
ensemble_started(Nodes) ->
ets:lookup(?MODULE, Nodes) =/= [].

is_local_ensemble(Nodes) ->
ordsets:is_element(node(), Nodes).

start_ensemble(Nodes) ->
EnsembleName = riak_governor_util:ensemble_name(Nodes),
Peers = lists:map(fun(Node) -> {EnsembleName, Node} end, Nodes),
Expand Down
15 changes: 0 additions & 15 deletions src/riak_governor_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
-export([get_ensemble_size/0, get_ensemble_provider/0, ensemble_name/1]).
-export([get_primary_apl/1]).
-export([get_cluster_nodes/0]).
-export([whileok/1]).

get_ensemble_size() ->
riak_governor:get_env(ensemble_size, ?DEFAULT_ENSEMBLE_SIZE).
Expand All @@ -26,17 +25,3 @@ get_primary_apl(DocIdx) ->
get_cluster_nodes() ->
{ok, Ring} = riak_core_ring_manager:get_raw_ring(),
lists:usort(riak_core_ring:all_members(Ring)).

whileok([]) ->
ok;
whileok([Fn|Fns]) ->
case Fn() of
ok ->
whileok(Fns);
true ->
whileok(Fns);
{ok, _} ->
whileok(Fns);
Other ->
Other
end.

0 comments on commit 891c7a6

Please sign in to comment.