Java Code Examples for org.apache.hadoop.util.HostsFileReader#readFileToSet()

The following examples show how to use org.apache.hadoop.util.HostsFileReader#readFileToSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Dispatcher.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Read set of host names from a file
 * 
 * @return set of host names
 */
static Set<String> getHostListFromFile(String fileName, String type) {
  Set<String> nodes = new HashSet<String>();
  try {
    HostsFileReader.readFileToSet(type, fileName, nodes);
    return StringUtils.getTrimmedStrings(nodes);
  } catch (IOException e) {
    throw new IllegalArgumentException(
        "Failed to read host list from file: " + fileName);
  }
}
 
Example 2
Source File: HostFileManager.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static HostSet readFile(String type, String filename)
        throws IOException {
  HostSet res = new HostSet();
  if (!filename.isEmpty()) {
    HashSet<String> entrySet = new HashSet<String>();
    HostsFileReader.readFileToSet(type, filename, entrySet);
    for (String str : entrySet) {
      InetSocketAddress addr = parseEntry(type, filename, str);
      if (addr != null) {
        res.add(addr);
      }
    }
  }
  return res;
}
 
Example 3
Source File: Dispatcher.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Read set of host names from a file
 * 
 * @return set of host names
 */
static Set<String> getHostListFromFile(String fileName, String type) {
  Set<String> nodes = new HashSet<String>();
  try {
    HostsFileReader.readFileToSet(type, fileName, nodes);
    return StringUtils.getTrimmedStrings(nodes);
  } catch (IOException e) {
    throw new IllegalArgumentException(
        "Failed to read host list from file: " + fileName);
  }
}
 
Example 4
Source File: HostFileManager.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static HostSet readFile(String type, String filename)
        throws IOException {
  HostSet res = new HostSet();
  if (!filename.isEmpty()) {
    HashSet<String> entrySet = new HashSet<String>();
    HostsFileReader.readFileToSet(type, filename, entrySet);
    for (String str : entrySet) {
      InetSocketAddress addr = parseEntry(type, filename, str);
      if (addr != null) {
        res.add(addr);
      }
    }
  }
  return res;
}