From 268e35d3ae75f901c47ac5c5e115ca7c039b3a61 Mon Sep 17 00:00:00 2001 From: Wei-Chiu Chuang Date: Mon, 24 Feb 2020 13:37:11 -0800 Subject: [PATCH] HDFS-15174. Optimize ReplicaCachingGetSpaceUsed by reducing unnecessary io operations. Contributed by Lisheng Sun. (cherry picked from commit cb4daeaad95470125c59ccb80b988261ae83d534) (cherry picked from commit f9437b1817e09c5a3ee7b378a0f4faee9b853315) --- .../datanode/fsdataset/impl/ReplicaCachingGetSpaceUsed.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ReplicaCachingGetSpaceUsed.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ReplicaCachingGetSpaceUsed.java index 477e0501a2b..2c1c16e5dd2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ReplicaCachingGetSpaceUsed.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ReplicaCachingGetSpaceUsed.java @@ -85,7 +85,7 @@ public class ReplicaCachingGetSpaceUsed extends FSCachingGetSpaceUsed { for (ReplicaInfo replicaInfo : replicaInfos) { if (Objects.equals(replicaInfo.getVolume().getStorageID(), volume.getStorageID())) { - dfsUsed += replicaInfo.getBlockDataLength(); + dfsUsed += replicaInfo.getBytesOnDisk(); dfsUsed += replicaInfo.getMetadataLength(); count++; }