Java Code Examples for org.apache.hadoop.security.SecurityUtil#getByName()

The following examples show how to use org.apache.hadoop.security.SecurityUtil#getByName() . 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: NetUtils.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if {@code host} is a local host name and return {@link InetAddress}
 * corresponding to that address.
 * 
 * @param host the specified host
 * @return a valid local {@link InetAddress} or null
 * @throws SocketException if an I/O error occurs
 */
public static InetAddress getLocalInetAddress(String host)
    throws SocketException {
  if (host == null) {
    return null;
  }
  InetAddress addr = null;
  try {
    addr = SecurityUtil.getByName(host);
    if (NetworkInterface.getByInetAddress(addr) == null) {
      addr = null; // Not a local address
    }
  } catch (UnknownHostException ignore) { }
  return addr;
}
 
Example 2
Source File: NetUtils.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if {@code host} is a local host name and return {@link InetAddress}
 * corresponding to that address.
 * 
 * @param host the specified host
 * @return a valid local {@link InetAddress} or null
 * @throws SocketException if an I/O error occurs
 */
public static InetAddress getLocalInetAddress(String host)
    throws SocketException {
  if (host == null) {
    return null;
  }
  InetAddress addr = null;
  try {
    addr = SecurityUtil.getByName(host);
    if (NetworkInterface.getByInetAddress(addr) == null) {
      addr = null; // Not a local address
    }
  } catch (UnknownHostException ignore) { }
  return addr;
}