From ab511286fd2b4cd38303c7face67decb942243c4 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Tue, 2 May 2017 10:51:20 -0700 Subject: [PATCH] HADOOP-14369. NetworkTopology calls expensive toString() when logging. Contributed by Inigo Goiri. (cherry picked from commit dcc292d7ded200a4976f6d348952ecba10f01db2) (cherry picked from commit 484bab39442939e1fe8424def25d1aa4ca99a2e5) --- .../java/org/apache/hadoop/net/NetworkTopology.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 fde087b75e3..ca6a53f56d0 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 @@ -409,8 +409,8 @@ public class NetworkTopology { "Not allow to add an inner node: "+NodeBase.getPath(node)); } if ((depthOfAllLeaves != -1) && (depthOfAllLeaves != newDepth)) { - LOG.error("Error: can't add leaf node " + NodeBase.getPath(node) + - " at depth " + newDepth + " to topology:\n" + this.toString()); + LOG.error("Error: can't add leaf node {} at depth {} to topology:{}\n", + NodeBase.getPath(node), newDepth, this); throw new InvalidTopologyException("Failed to add " + NodeBase.getPath(node) + ": You cannot have a rack and a non-rack node at the same " + "level of the network topology."); @@ -432,7 +432,7 @@ public class NetworkTopology { } } } - LOG.debug("NetworkTopology became:\n{}", this.toString()); + LOG.debug("NetworkTopology became:\n{}", this); } finally { netlock.writeLock().unlock(); } @@ -505,7 +505,7 @@ public class NetworkTopology { numOfRacks--; } } - LOG.debug("NetworkTopology became:\n{}", this.toString()); + LOG.debug("NetworkTopology became:\n{}", this); } finally { netlock.writeLock().unlock(); } @@ -764,7 +764,7 @@ public class NetworkTopology { } if (numOfDatanodes == 0) { LOG.debug("Failed to find datanode (scope=\"{}\" excludedScope=\"{}\").", - String.valueOf(scope), String.valueOf(excludedScope)); + scope, excludedScope); return null; } Node ret = null; @@ -777,7 +777,7 @@ public class NetworkTopology { } LOG.debug("Choosing random from {} available nodes on node {}," + " scope={}, excludedScope={}, excludeNodes={}", availableNodes, - innerNode.toString(), scope, excludedScope, excludedNodes); + innerNode, scope, excludedScope, excludedNodes); if (availableNodes > 0) { do { int leaveIndex = r.nextInt(numOfDatanodes);