From 704c57e3eb2d16e931d6f250e684f1d59730ac55 Mon Sep 17 00:00:00 2001 From: Tsz-Wo Nicholas Sze Date: Thu, 21 Apr 2016 15:20:12 -0700 Subject: [PATCH] HDFS-10319. Balancer should not try to pair storages with different types. --- .../apache/hadoop/hdfs/server/balancer/Balancer.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java index e3a1bebb1a3..6f01ae16020 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java @@ -520,8 +520,7 @@ C chooseCandidate(G g, Iterator candidates, Matcher matcher) { final C c = candidates.next(); if (!c.hasSpaceForScheduling()) { candidates.remove(); - } else if (matcher.match(dispatcher.getCluster(), - g.getDatanodeInfo(), c.getDatanodeInfo())) { + } else if (matchStorageGroups(c, g, matcher)) { return c; } } @@ -529,6 +528,13 @@ C chooseCandidate(G g, Iterator candidates, Matcher matcher) { return null; } + private boolean matchStorageGroups(StorageGroup left, StorageGroup right, + Matcher matcher) { + return left.getStorageType() == right.getStorageType() + && matcher.match(dispatcher.getCluster(), + left.getDatanodeInfo(), right.getDatanodeInfo()); + } + /* reset all fields in a balancer preparing for the next iteration */ void resetData(Configuration conf) { this.overUtilized.clear();