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:10:53 UTC

[07/48] mem3 commit: updated refs/heads/windsor-merge to ff02b9a

Support balancing across a subset of nodes

mem3_balance implicitly assumed the set of nodes over which the DB is
hosted is expanding.  We need to make a couple of small changes in the
case of cluster contraction.

BugzID: 20742


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/commit/e30659b6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/tree/e30659b6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/diff/e30659b6

Branch: refs/heads/windsor-merge
Commit: e30659b6fd5a788b17297f4312740d46ef63e204
Parents: c9292bb
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Tue Jul 2 14:30:09 2013 -0400
Committer: Robert Newson <rn...@apache.org>
Committed: Wed Jul 23 18:46:25 2014 +0100

----------------------------------------------------------------------
 src/mem3_rebalance.erl | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/e30659b6/src/mem3_rebalance.erl
----------------------------------------------------------------------
diff --git a/src/mem3_rebalance.erl b/src/mem3_rebalance.erl
index ca3c4a7..8f5872a 100644
--- a/src/mem3_rebalance.erl
+++ b/src/mem3_rebalance.erl
@@ -47,13 +47,14 @@ rebalance2(TargetLevel, Shards, Nodes, [Node | Rest], Moves) ->
 
 victim(TargetLevel, Shards, Nodes, TargetNode) ->
     TargetZone = mem3:node_info(TargetNode, <<"zone">>),
-    CandidateNodes = lists:usort([Node || Node <- Nodes,
+    CandidateNodes = lists:usort([Node || Node <- mem3:nodes(),
                                      Node =/= TargetNode,
                                      mem3:node_info(Node, <<"zone">>) =:= TargetZone]),
     %% make {Node, ShardsInNode} list
     GroupedByNode0 = [{Node, [S || S <- Shards, S#shard.node =:= Node]} || Node <- CandidateNodes],
-    %% don't take from a node below target level
-    GroupedByNode1 = [{N, SS} || {N, SS} <- GroupedByNode0, length(SS) > TargetLevel],
+    %% don't take from a balancing node below target level
+    GroupedByNode1 = [{N, SS} || {N, SS} <- GroupedByNode0,
+        (length(SS) > TargetLevel) orelse (not lists:member(N, Nodes))],
     %% prefer to take from a node with more shards than others
     GroupedByNode2 = lists:sort(fun largest_first/2, GroupedByNode1),
     %% don't take a shard for a range the target already has