Browse Source

HADOOP-7878 Regression: HADOOP-7777 switch changes break HDFS tests when the isSingleSwitch() predicate is used

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1213263 13f79535-47bb-0310-9956-ffa450edef68
Steve Loughran 13 năm trước cách đây
mục cha
commit
0f70398292

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -197,6 +197,9 @@ Release 0.23.1 - Unreleased
 
    HADOOP-7898. Fix javadoc warnings in AuthenticationToken.java. (suresh)
 
+   HADOOP-7878  Regression: HADOOP-7777 switch changes break HDFS tests when the
+   isSingleSwitch() predicate is used. (stevel)
+
 Release 0.23.0 - 2011-11-01 
 
   INCOMPATIBLE CHANGES

+ 8 - 8
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/StaticMapping.java

@@ -38,9 +38,11 @@ import java.util.Map;
 public class StaticMapping extends AbstractDNSToSwitchMapping  {
 
   /**
-   * key to define the node mapping as a comma-delimited list of host=rack
+   * Key to define the node mapping as a comma-delimited list of host=rack
    * mappings, e.g. <code>host1=r1,host2=r1,host3=r2</code>.
-   * </p>
+   * <p/>
+   * Value: {@value}
+   * <p/>
    * <b>Important: </b>spaces not trimmed and are considered significant.
    */
   public static final String KEY_HADOOP_CONFIGURED_NODE_MAPPING =
@@ -107,18 +109,16 @@ public class StaticMapping extends AbstractDNSToSwitchMapping  {
   }
 
   /**
-   * This mapping is only single switch if the map is empty
-   * @return the current switching status
+   * Declare that this mapping is always multi-switch
+   * @return false, always
    */
   @Override
   public boolean isSingleSwitch() {
-    synchronized (nameToRackMap) {
-      return nameToRackMap.isEmpty();
-    }
+    return false;
   }
 
   /**
-   * Clear the map and revert to being a single switch
+   * Clear the map
    */
   public static void resetMap() {
     synchronized (nameToRackMap) {

+ 6 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestStaticMapping.java

@@ -44,7 +44,8 @@ public class TestStaticMapping extends Assert {
   @Test
   public void testStaticIsSingleSwitch() throws Throwable {
     StaticMapping mapping = newInstance();
-    assertTrue("Empty maps are not single switch", mapping.isSingleSwitch());
+    assertFalse("Empty maps should not be not single switch",
+                mapping.isSingleSwitch());
   }
 
 
@@ -53,10 +54,8 @@ public class TestStaticMapping extends Assert {
     StaticMapping staticMapping = newInstance();
     CachedDNSToSwitchMapping mapping =
         new CachedDNSToSwitchMapping(staticMapping);
-    assertTrue("Expected single switch", mapping.isSingleSwitch());
     StaticMapping.addNodeToRack("n1", "r1");
-    assertFalse("Expected to be multi switch",
-                mapping.isSingleSwitch());
+    assertFalse("Expected multi switch", mapping.isSingleSwitch());
   }
 
   @Test
@@ -96,8 +95,9 @@ public class TestStaticMapping extends Assert {
   public void testNullConfiguration() throws Throwable {
     StaticMapping mapping = newInstance();
     mapping.setConf(null);
-    assertTrue("Null maps is not single switch", mapping.isSingleSwitch());
-    assertTrue("Expected to be single switch",
+    assertFalse("Null maps are expected to be multi switch",
+                mapping.isSingleSwitch());
+    assertFalse("Expected to be multi switch",
                AbstractDNSToSwitchMapping.isMappingSingleSwitch(mapping));
   }
 }