Browse Source

HADOOP-1056. Check HDFS include/exclude node lists with both IP address and hostname. Contributed by Wendy.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@513976 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 years ago
parent
commit
a79dfef783

+ 3 - 0
CHANGES.txt

@@ -192,6 +192,9 @@ Trunk (unreleased changes)
 58. HADOOP-1049.  Fix a race condition in IPC client.
     (Devaraj Das via cutting)
 
+60. HADOOP-1056.  Check HDFS include/exclude node lists with both IP
+    address and hostname.  (Wendy Chien via cutting)
+
 
 Release 0.11.2 - 2007-02-16
 

+ 10 - 2
src/java/org/apache/hadoop/dfs/FSNamesystem.java

@@ -1473,6 +1473,10 @@ class FSNamesystem implements FSConstants {
                                                String networkLocation
                                               ) throws IOException {
 
+      if (!verifyNodeRegistration(nodeReg)) {
+        throw new DisallowedDatanodeException( nodeReg );
+      }
+
       String dnAddress = Server.getRemoteAddress();
       if ( dnAddress == null ) {
         //Mostly not called inside an RPC.
@@ -3157,14 +3161,18 @@ class FSNamesystem implements FSConstants {
       Set<String> hostsList = hostsReader.getHosts();
       return (hostsList.isEmpty() || 
               hostsList.contains(node.getName()) || 
-              hostsList.contains(node.getHost()));
+              hostsList.contains(node.getHost()) ||
+              ((node instanceof DatanodeInfo) && 
+               hostsList.contains(((DatanodeInfo)node).getHostName())));
     }
 
 
     private boolean inExcludedHostsList(DatanodeID node) {
       Set<String> excludeList = hostsReader.getExcludedHosts();
       return (excludeList.contains(node.getName()) ||
-              excludeList.contains(node.getHost()));
+              excludeList.contains(node.getHost()) ||
+              ((node instanceof DatanodeInfo) && 
+               excludeList.contains(((DatanodeInfo)node).getHostName())));
     }
 
     /**

+ 0 - 3
src/java/org/apache/hadoop/dfs/NameNode.java

@@ -559,9 +559,6 @@ public class NameNode implements ClientProtocol, DatanodeProtocol, FSConstants {
     public DatanodeRegistration register( DatanodeRegistration nodeReg,
                                           String networkLocation
                                         ) throws IOException {
-      if (!namesystem.verifyNodeRegistration(nodeReg)) {
-        throw new DisallowedDatanodeException( nodeReg );
-      }
       verifyVersion( nodeReg.getVersion() );
       namesystem.registerDatanode( nodeReg, networkLocation );