Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5268011C46 for ; Thu, 28 Aug 2014 12:22:23 +0000 (UTC) Received: (qmail 40975 invoked by uid 500); 28 Aug 2014 12:22:22 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 40730 invoked by uid 500); 28 Aug 2014 12:22:22 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 40402 invoked by uid 99); 28 Aug 2014 12:22:22 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Aug 2014 12:22:22 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B67B5A02DA9; Thu, 28 Aug 2014 12:22:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Date: Thu, 28 Aug 2014 12:22:26 -0000 Message-Id: In-Reply-To: <29bb38a445e2454d9b33ebc655e7f389@git.apache.org> References: <29bb38a445e2454d9b33ebc655e7f389@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [06/50] mem3 commit: updated refs/heads/master to 64c0c74 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/master Commit: e30659b6fd5a788b17297f4312740d46ef63e204 Parents: c9292bb Author: Adam Kocoloski Authored: Tue Jul 2 14:30:09 2013 -0400 Committer: Robert Newson 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