From 166c38bcbf1ed0fdd65518173bb543ef641568dc Mon Sep 17 00:00:00 2001 From: litao Date: Fri, 19 Nov 2021 10:37:10 +0800 Subject: [PATCH] HDFS-16326. Simplify the code for DiskBalancer (#3663) Reviewed-by: Viraj Jasani (cherry picked from commit 965e3874e90f7ca7cf6d1418893340338eb8760f) --- .../org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java index d29759b1b3..7b58d9bca5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java @@ -808,7 +808,7 @@ private boolean isLessThanNeeded(long blockSize, long bytesToCopy = item.getBytesToCopy() - item.getBytesCopied(); bytesToCopy = bytesToCopy + ((bytesToCopy * getBlockTolerancePercentage(item)) / 100); - return (blockSize <= bytesToCopy) ? true : false; + return blockSize <= bytesToCopy; } /** @@ -833,7 +833,7 @@ private long getBlockTolerancePercentage(DiskBalancerWorkItem item) { private boolean isCloseEnough(DiskBalancerWorkItem item) { long temp = item.getBytesCopied() + ((item.getBytesCopied() * getBlockTolerancePercentage(item)) / 100); - return (item.getBytesToCopy() >= temp) ? false : true; + return item.getBytesToCopy() < temp; } /**