You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/01 11:11:12 UTC
[26/48] mem3 commit: updated refs/heads/windsor-merge to ff02b9a
Rely on decom:true attribute to filter decom nodes
BugzID: 24420
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/commit/d7a4f26d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/tree/d7a4f26d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/diff/d7a4f26d
Branch: refs/heads/windsor-merge
Commit: d7a4f26d4e8aa56a2a38ebfbdd46f13efde27a22
Parents: 19c3ee2
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Wed Oct 23 10:02:33 2013 -0400
Committer: Robert Newson <rn...@apache.org>
Committed: Wed Jul 23 18:46:26 2014 +0100
----------------------------------------------------------------------
src/mem3_rebalance.erl | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/d7a4f26d/src/mem3_rebalance.erl
----------------------------------------------------------------------
diff --git a/src/mem3_rebalance.erl b/src/mem3_rebalance.erl
index 4d8d069..3c06596 100644
--- a/src/mem3_rebalance.erl
+++ b/src/mem3_rebalance.erl
@@ -43,14 +43,14 @@ expand() ->
%% @doc Expands all databases in the cluster, stopping at Limit operations.
-spec expand(integer()) -> [{atom(), #shard{}, node()}].
expand(Limit) when is_integer(Limit), Limit > 0 ->
- TargetNodes = allowed_nodes(fun(Zone) -> Zone =/= <<"decom">> end),
+ TargetNodes = surviving_nodes(),
LocalBalanceFun = fun(Db, Moves) -> expand(Db, TargetNodes, Moves) end,
LocalBalanceOps = apply_to_cluster(LocalBalanceFun, Limit),
% Now apply additional operations as needed to achieve global balance.
global_expand(TargetNodes, LocalBalanceOps, Limit);
expand(DbName) when is_binary(DbName); is_list(DbName) ->
- TargetNodes = allowed_nodes(fun(Zone) -> Zone =/= <<"decom">> end),
+ TargetNodes = surviving_nodes(),
expand(DbName, TargetNodes, []).
%% @doc Computes a plan to balance the shards across the target nodes.
@@ -73,11 +73,11 @@ contract() ->
%% @doc Computes a plan to remove up to Limit shards from nodes in "decom" zone.
-spec contract(integer()) -> [{atom(), #shard{}, node()}].
contract(Limit) when is_integer(Limit), Limit > 0 ->
- TargetNodes = allowed_nodes(fun(Zone) -> Zone =/= <<"decom">> end),
+ TargetNodes = surviving_nodes(),
apply_to_cluster(fun(Db, Moves) -> contract(Db, TargetNodes, Moves) end, Limit);
contract(DbName) when is_binary(DbName); is_list(DbName) ->
- TargetNodes = allowed_nodes(fun(Zone) -> Zone =/= <<"decom">> end),
+ TargetNodes = surviving_nodes(),
contract(DbName, TargetNodes, []).
%% @doc Computes a plan to consolidate shards from a single database onto the
@@ -339,6 +339,11 @@ allowed_nodes(Fun) ->
Fun(mem3:node_info(Node, <<"zone">>))
end, mem3:nodes()).
+surviving_nodes() ->
+ lists:filter(fun(Node) ->
+ mem3:node_info(Node, <<"decom">>) =/= true
+ end, mem3:nodes()).
+
shards_by_node(Shards, Nodes) ->
% Ensure every target node is present in the orddict
ShardsByNode0 = orddict:from_list([{N,[]} || N <- Nodes]),