Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 62A221870E for ; Thu, 13 Aug 2015 16:56:11 +0000 (UTC) Received: (qmail 94325 invoked by uid 500); 13 Aug 2015 16:56:08 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 94140 invoked by uid 500); 13 Aug 2015 16:56:08 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 93710 invoked by uid 99); 13 Aug 2015 16:56:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Aug 2015 16:56:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 41952E713C; Thu, 13 Aug 2015 16:56:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: zhz@apache.org To: common-commits@hadoop.apache.org Date: Thu, 13 Aug 2015 16:56:14 -0000 Message-Id: <76d8cd48ef1c4de498f06343a18b6f01@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [07/28] hadoop git commit: HADOOP-12295. Improve NetworkTopology#InnerNode#remove logic. (yliu) HADOOP-12295. Improve NetworkTopology#InnerNode#remove logic. (yliu) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/53bef9c5 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/53bef9c5 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/53bef9c5 Branch: refs/heads/HDFS-7285-merge Commit: 53bef9c5b98dee87d4ffaf35415bc38e2f876ed8 Parents: 40f8151 Author: yliu Authored: Thu Aug 13 16:45:20 2015 +0800 Committer: yliu Committed: Thu Aug 13 16:45:20 2015 +0800 ---------------------------------------------------------------------- hadoop-common-project/hadoop-common/CHANGES.txt | 2 ++ .../org/apache/hadoop/net/NetworkTopology.java | 38 ++++++++++---------- .../apache/hadoop/net/TestNetworkTopology.java | 1 + 3 files changed, 21 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/53bef9c5/hadoop-common-project/hadoop-common/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 78f12e4..c80be05 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -749,6 +749,8 @@ Release 2.8.0 - UNRELEASED HADOOP-12318. Expose underlying LDAP exceptions in SaslPlainServer. (Mike Yoder via atm) + HADOOP-12295. Improve NetworkTopology#InnerNode#remove logic. (yliu) + OPTIMIZATIONS HADOOP-11785. Reduce the number of listStatus operation in distcp http://git-wip-us.apache.org/repos/asf/hadoop/blob/53bef9c5/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java ---------------------------------------------------------------------- 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 970ad40..fe6e439 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 @@ -166,10 +166,11 @@ public class NetworkTopology { * @return true if the node is added; false otherwise */ boolean add(Node n) { - if (!isAncestor(n)) - throw new IllegalArgumentException(n.getName()+", which is located at " - +n.getNetworkLocation()+", is not a decendent of " - +getPath(this)); + if (!isAncestor(n)) { + throw new IllegalArgumentException(n.getName() + + ", which is located at " + n.getNetworkLocation() + + ", is not a descendent of " + getPath(this)); + } if (isParent(n)) { // this node is the parent of n; add n directly n.setParent(this); @@ -227,12 +228,11 @@ public class NetworkTopology { * @return true if the node is deleted; false otherwise */ boolean remove(Node n) { - String parent = n.getNetworkLocation(); - String currentPath = getPath(this); - if (!isAncestor(n)) + if (!isAncestor(n)) { throw new IllegalArgumentException(n.getName() - +", which is located at " - +parent+", is not a descendent of "+currentPath); + + ", which is located at " + n.getNetworkLocation() + + ", is not a descendent of " + getPath(this)); + } if (isParent(n)) { // this node is the parent of n; remove n directly if (childrenMap.containsKey(n.getName())) { @@ -250,15 +250,8 @@ public class NetworkTopology { } else { // find the next ancestor node: the parent node String parentName = getNextAncestorName(n); - InnerNode parentNode = null; - int i; - for(i=0; i