hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kih...@apache.org
Subject hadoop git commit: HADOOP-12772. NetworkTopologyWithNodeGroup.getNodeGroup() can loop infinitely for invalid 'loc' values. Contributed by Kuhu Shukla.
Date Fri, 05 Feb 2016 21:48:45 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.8 4fb2a098f -> 150240cce


HADOOP-12772. NetworkTopologyWithNodeGroup.getNodeGroup() can loop infinitely for invalid
'loc' values. Contributed by Kuhu Shukla.

(cherry picked from commit 49e176c29f95c179c0f6b07d4d582e6a771a96bd)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/150240cc
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/150240cc
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/150240cc

Branch: refs/heads/branch-2.8
Commit: 150240cce04d7aa9445f80804b40544bebfb7fdd
Parents: 4fb2a09
Author: Kihwal Lee <kihwal@apache.org>
Authored: Fri Feb 5 15:48:32 2016 -0600
Committer: Kihwal Lee <kihwal@apache.org>
Committed: Fri Feb 5 15:48:32 2016 -0600

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt      |  3 +++
 .../hadoop/net/NetworkTopologyWithNodeGroup.java     |  7 ++++++-
 .../main/java/org/apache/hadoop/net/NodeBase.java    |  9 ++++++++-
 .../hadoop/net/TestNetworkTopologyWithNodeGroup.java | 15 ++++++++++++++-
 4 files changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/150240cc/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 53b6417..9956fde 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -1023,6 +1023,9 @@ Release 2.7.3 - UNRELEASED
 
     HADOOP-12761. incremental maven build is not really incremental (sjlee)
 
+    HADOOP-12772. NetworkTopologyWithNodeGroup.getNodeGroup() can loop
+    infinitely for invalid 'loc' values (Kuhu Shukla via kihwal)
+
 Release 2.7.2 - 2016-01-25
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/150240cc/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java
index 72031aa..8ebe846 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java
@@ -101,7 +101,12 @@ public class NetworkTopologyWithNodeGroup extends NetworkTopology {
           return null;
         } else {
           // may be a leaf node
-          return getNodeGroup(node.getNetworkLocation());
+          if(!(node.getNetworkLocation() == null ||
+              node.getNetworkLocation().isEmpty())) {
+            return getNodeGroup(node.getNetworkLocation());
+          } else {
+            return NodeBase.ROOT;
+          }
         }
       } else {
         // not in cluster map, don't handle it

http://git-wip-us.apache.org/repos/asf/hadoop/blob/150240cc/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java
index 9f40eea..b136297 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java
@@ -127,7 +127,14 @@ public class NodeBase implements Node {
    * is not {@link #PATH_SEPARATOR}
    */
   public static String normalize(String path) {
-    if (path == null || path.length() == 0) return ROOT;
+    if (path == null) {
+      throw new IllegalArgumentException(
+          "Network Location is null ");
+    }
+
+    if (path.length() == 0) {
+      return ROOT;
+    }
     
     if (path.charAt(0) != PATH_SEPARATOR) {
       throw new IllegalArgumentException(

http://git-wip-us.apache.org/repos/asf/hadoop/blob/150240cc/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java
index 15bd9fe..c2c528a 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java
@@ -178,7 +178,20 @@ public class TestNetworkTopologyWithNodeGroup {
       assertTrue(frequency.get(key) > 0 || key == dataNodes[0]);
     }
   }
-  
+
+  @Test
+  public void testNodeGroup() throws Exception {
+    String res = cluster.getNodeGroup("");
+    assertTrue("NodeGroup should be NodeBase.ROOT for empty location",
+        res.equals(NodeBase.ROOT));
+    try {
+      cluster.getNodeGroup(null);
+    } catch (IllegalArgumentException e) {
+      assertTrue("Null Network Location should throw exception!",
+          e.getMessage().contains("Network Location is null"));
+    }
+  }
+
   /**
    * This test checks that adding a node with invalid topology will be failed 
    * with an exception to show topology is invalid.


Mime
View raw message