org.elasticsearch.util.network
Class NetworkUtils
java.lang.Object
org.elasticsearch.util.network.NetworkUtils
public abstract class NetworkUtils
- extends java.lang.Object
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IPv4_SETTING
public static final java.lang.String IPv4_SETTING
- See Also:
- Constant Field Values
IPv6_SETTING
public static final java.lang.String IPv6_SETTING
- See Also:
- Constant Field Values
NON_LOOPBACK_ADDRESS
public static final java.lang.String NON_LOOPBACK_ADDRESS
- See Also:
- Constant Field Values
defaultReuseAddress
public static java.lang.Boolean defaultReuseAddress()
isIPv4
public static boolean isIPv4()
getIPv4Localhost
public static java.net.InetAddress getIPv4Localhost()
throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
getIPv6Localhost
public static java.net.InetAddress getIPv6Localhost()
throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
getLocalAddress
public static java.net.InetAddress getLocalAddress()
getLocalhost
public static java.net.InetAddress getLocalhost(NetworkUtils.StackType ip_version)
throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
getFirstNonLoopbackAddress
public static java.net.InetAddress getFirstNonLoopbackAddress(NetworkUtils.StackType ip_version)
throws java.net.SocketException
- Returns the first non-loopback address on any interface on the current host.
- Parameters:
ip_version
- Constraint on IP version of address to be returned, 4 or 6
- Throws:
java.net.SocketException
getFirstNonLoopbackAddress
public static java.net.InetAddress getFirstNonLoopbackAddress(java.net.NetworkInterface intf,
NetworkUtils.StackType ipVersion)
throws java.net.SocketException
- Returns the first non-loopback address on the given interface on the current host.
- Parameters:
intf
- the interface to be checkedipVersion
- Constraint on IP version of address to be returned, 4 or 6
- Throws:
java.net.SocketException
interfaceHasIPAddresses
public static boolean interfaceHasIPAddresses(java.net.NetworkInterface intf,
NetworkUtils.StackType ipVersion)
throws java.net.SocketException,
java.net.UnknownHostException
- A function to check if an interface supports an IP version (i.e has addresses
defined for that IP version).
- Parameters:
intf
-
- Returns:
-
- Throws:
java.net.SocketException
java.net.UnknownHostException
getIpStackType
public static NetworkUtils.StackType getIpStackType()
- Tries to determine the type of IP stack from the available interfaces and their addresses and from the
system properties (java.net.preferIPv4Stack and java.net.preferIPv6Addresses)
- Returns:
- StackType.IPv4 for an IPv4 only stack, StackYTypeIPv6 for an IPv6 only stack, and StackType.Unknown
if the type cannot be detected
isStackAvailable
public static boolean isStackAvailable(boolean ipv4)
getAllAvailableInterfaces
public static java.util.List<java.net.NetworkInterface> getAllAvailableInterfaces()
throws java.net.SocketException
- Throws:
java.net.SocketException
getAllAvailableAddresses
public static java.util.Collection<java.net.InetAddress> getAllAvailableAddresses()