From 2b254dad2ea0e204b27af3a7fe098ebbc9bda513 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Thu, 26 Apr 2012 00:47:16 +0000 Subject: [PATCH] HDFS-3258. Test for HADOOP-8144 (pseudoSortByDistance in NetworkTopology for first rack local node). Contributed by Junping Du git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1330613 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../org/apache/hadoop/net/TestNetworkTopology.java | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 56e2657c4b..36d7afe968 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -403,6 +403,9 @@ Release 2.0.0 - UNRELEASED HDFS-3169. TestFsck should test multiple -move operations in a row. (Colin Patrick McCabe via eli) + HDFS-3258. Test for HADOOP-8144 (pseudoSortByDistance in + NetworkTopology for first rack local node). (Junping Du via eli) + OPTIMIZATIONS HDFS-3024. Improve performance of stringification in addStoredBlock (todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/net/TestNetworkTopology.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/net/TestNetworkTopology.java index 36c38ef4da..b412fe1ab1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/net/TestNetworkTopology.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/net/TestNetworkTopology.java @@ -123,6 +123,17 @@ public void testPseudoSortByDistance() throws Exception { assertTrue(testNodes[0] == dataNodes[1]); assertTrue(testNodes[1] == dataNodes[3]); assertTrue(testNodes[2] == dataNodes[5]); + + // array contains local rack node which happens to be in position 0 + testNodes[0] = dataNodes[1]; + testNodes[1] = dataNodes[5]; + testNodes[2] = dataNodes[3]; + cluster.pseudoSortByDistance(dataNodes[0], testNodes ); + // peudoSortByDistance does not take the "data center" layer into consideration + // and it doesn't sort by getDistance, so 1, 5, 3 is also valid here + assertTrue(testNodes[0] == dataNodes[1]); + assertTrue(testNodes[1] == dataNodes[5]); + assertTrue(testNodes[2] == dataNodes[3]); } public void testRemove() throws Exception {