hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmcc...@apache.org
Subject svn commit: r1493233 - /hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java
Date Fri, 14 Jun 2013 20:17:42 GMT
Author: cmccabe
Date: Fri Jun 14 20:17:41 2013
New Revision: 1493233

URL: http://svn.apache.org/r1493233
Log:
HDFS-3934. duplicative dfs_hosts entries handled wrong (all files) (cmccabe)


Modified:
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java?rev=1493233&r1=1493232&r2=1493233&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java
Fri Jun 14 20:17:41 2013
@@ -48,7 +48,8 @@ public class HostsFileReader {
     refresh();
   }
 
-  private void readFileToSet(String filename, Set<String> set) throws IOException {
+  public static void readFileToSet(String type,
+      String filename, Set<String> set) throws IOException {
     File file = new File(filename);
     FileInputStream fis = new FileInputStream(file);
     BufferedReader reader = null;
@@ -63,9 +64,10 @@ public class HostsFileReader {
               // Everything from now on is a comment
               break;
             }
-            if (!nodes[i].equals("")) {
-              LOG.info("Adding " + nodes[i] + " to the list of hosts from " + filename);
-              set.add(nodes[i]);  // might need to add canonical name
+            if (!nodes[i].isEmpty()) {
+              LOG.info("Adding " + nodes[i] + " to the list of " + type +
+                  " hosts from " + filename);
+              set.add(nodes[i]);
             }
           }
         }
@@ -82,13 +84,13 @@ public class HostsFileReader {
     LOG.info("Refreshing hosts (include/exclude) list");
     if (!includesFile.equals("")) {
       Set<String> newIncludes = new HashSet<String>();
-      readFileToSet(includesFile, newIncludes);
+      readFileToSet("included", includesFile, newIncludes);
       // switch the new hosts that are to be included
       includes = newIncludes;
     }
     if (!excludesFile.equals("")) {
       Set<String> newExcludes = new HashSet<String>();
-      readFileToSet(excludesFile, newExcludes);
+      readFileToSet("excluded", excludesFile, newExcludes);
       // switch the excluded hosts
       excludes = newExcludes;
     }



Mime
View raw message