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 a7600e00913..3169faf6a85 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 @@ -525,8 +525,7 @@ public class Balancer { 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; } } @@ -534,6 +533,13 @@ public class Balancer { 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();