From 971a4c8e8328a4bdea65de4a0e84c82b5b2de24b Mon Sep 17 00:00:00 2001 From: Wei-Chiu Chuang Date: Fri, 16 Aug 2019 17:19:13 -0700 Subject: [PATCH] HDFS-14523. Remove excess read lock for NetworkToplogy. Contributed by Wu Weiwei. Signed-off-by: Wei-Chiu Chuang Reviewed-by: Chen Liang --- .../org/apache/hadoop/net/NetworkTopology.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java index 6fc4acc9419..9f608de515b 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java @@ -295,22 +295,12 @@ public class NetworkTopology { /** @return the total number of racks */ public int getNumOfRacks() { - netlock.readLock().lock(); - try { - return numOfRacks; - } finally { - netlock.readLock().unlock(); - } + return numOfRacks; } /** @return the total number of leaf nodes */ public int getNumOfLeaves() { - netlock.readLock().lock(); - try { - return clusterMap.getNumOfLeaves(); - } finally { - netlock.readLock().unlock(); - } + return clusterMap.getNumOfLeaves(); } /** Return the distance between two nodes