You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cm...@apache.org on 2013/06/14 22:25:13 UTC
svn commit: r1493234 -
/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java
Author: cmccabe
Date: Fri Jun 14 20:25:12 2013
New Revision: 1493234
URL: http://svn.apache.org/r1493234
Log:
HDFS-3934. duplicative dfs_hosts entries handled wrong (all files) (cmccabe)
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java
Modified: hadoop/common/branches/branch-2/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/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java?rev=1493234&r1=1493233&r2=1493234&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HostsFileReader.java Fri Jun 14 20:25:12 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;
}