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 1F597D7AB for ; Thu, 5 Jul 2012 01:32:22 +0000 (UTC) Received: (qmail 59259 invoked by uid 500); 5 Jul 2012 01:32:22 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 59222 invoked by uid 500); 5 Jul 2012 01:32:22 -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 59215 invoked by uid 99); 5 Jul 2012 01:32:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jul 2012 01:32:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jul 2012 01:32:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8DBD923888FE; Thu, 5 Jul 2012 01:31:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1357442 - in /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net: NetworkTopology.java NetworkTopologyWithNodeGroup.java Date: Thu, 05 Jul 2012 01:31:58 -0000 To: common-commits@hadoop.apache.org From: szetszwo@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120705013158.8DBD923888FE@eris.apache.org> Author: szetszwo Date: Thu Jul 5 01:31:57 2012 New Revision: 1357442 URL: http://svn.apache.org/viewvc?rev=1357442&view=rev Log: HDFS-3601. Add BlockPlacementPolicyWithNodeGroup to support block placement with 4-layer network topology. Contributed by Junping Du Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java?rev=1357442&r1=1357441&r2=1357442&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java (original) +++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java Thu Jul 5 01:31:57 2012 @@ -170,8 +170,7 @@ public class NetworkTopology { } if (parentNode == null) { // create a new InnerNode - parentNode = new InnerNode(parentName, getPath(this), - this, this.getLevel()+1); + parentNode = createParentNode(parentName); children.add(parentNode); } // add n to the subtree of the next ancestor node @@ -288,7 +287,7 @@ public class NetworkTopology { // calculate the total number of excluded leaf nodes int numOfExcludedLeaves = isLeaf ? 1 : ((InnerNode)excludedNode).getNumOfLeaves(); - if (isRack()) { // children are leaves + if (isLeafParent()) { // children are leaves if (isLeaf) { // excluded node is a leaf node int excludedIndex = children.indexOf(excludedNode); if (excludedIndex != -1 && leafIndex >= 0) { @@ -326,6 +325,10 @@ public class NetworkTopology { } } + protected boolean isLeafParent() { + return isRack(); + } + /** * Determine if children a leaves, default implementation calls {@link #isRack()} *

To be overridden in subclasses for specific InnerNode implementations, @@ -752,6 +755,30 @@ public class NetworkTopology { } return tree.toString(); } + + /** + * Divide networklocation string into two parts by last separator, and get + * the first part here. + * + * @param networkLocation + * @return + */ + public static String getFirstHalf(String networkLocation) { + int index = networkLocation.lastIndexOf(NodeBase.PATH_SEPARATOR_STR); + return networkLocation.substring(0, index); + } + + /** + * Divide networklocation string into two parts by last separator, and get + * the second part here. + * + * @param networkLocation + * @return + */ + public static String getLastHalf(String networkLocation) { + int index = networkLocation.lastIndexOf(NodeBase.PATH_SEPARATOR_STR); + return networkLocation.substring(index); + } /** swap two array items */ static protected void swap(Node[] nodes, int i, int j) { Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java?rev=1357442&r1=1357441&r2=1357442&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java (original) +++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java Thu Jul 5 01:31:57 2012 @@ -49,7 +49,7 @@ public class NetworkTopologyWithNodeGrou } Node nodeGroup = getNode(node.getNetworkLocation()); if (nodeGroup == null) { - nodeGroup = new InnerNode(node.getNetworkLocation()); + nodeGroup = new InnerNodeWithNodeGroup(node.getNetworkLocation()); } return getNode(nodeGroup.getNetworkLocation()); } @@ -383,6 +383,11 @@ public class NetworkTopologyWithNodeGrou } return true; } + + @Override + protected boolean isLeafParent() { + return isNodeGroup(); + } @Override protected InnerNode createParentNode(String parentName) {