public class HostHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
HostHelper.OSType
Enumerates the legal values for
HostPrms.osTypes. |
| Modifier and Type | Field and Description |
|---|---|
static String |
ONLY_ON_PLATFORMS_PROP
The
onlyOnPlatforms system property |
| Constructor and Description |
|---|
HostHelper() |
| Modifier and Type | Method and Description |
|---|---|
static String |
applyRFC2732(String hostname)
Process the String form of a hostname to make it comply with Jmx URL
restrictions.
|
protected static boolean |
compareHosts(String host1,
String host2)
Returns true if the noncanonical hostname of each host is the same or
if one contains the other.
|
static String |
getCanonicalHostName()
Returns the canonical name of the local host, based on the IPv4 address.
|
static String |
getCanonicalHostName(String host)
Returns the canonical name of the given host, based on the IPv4 address.
|
static String |
getHostAddress()
Returns the address for the local host.
|
static String |
getHostAddress(InetAddress addr)
A wrapper for
InetAddress.getHostAddress() that removes the
scope_id from all IPv4 address and all global IPv6 addresses. |
static HostHelper.OSType |
getHostOS(String host)
Returns the O/S type for the specified host.
|
static InetAddress |
getIPAddress()
Returns the IP address for the local host.
|
protected static InetAddress |
getIPv4Address()
Returns the IPv4 address for the local host.
|
static InetAddress |
getIPv6Address()
Returns the IPv6 address for the local host.
|
static String |
getLocalHost()
Returns the non-canonical name of the local host, based on the IPv4
address.
|
static HostHelper.OSType |
getLocalHostOS()
Returns the OSType of the local host O/S.
|
protected static String |
getNoncanonicalHostName(String host)
Returns the non-canonical host name of the given host.
|
static boolean |
isLocalHost(String host)
Answers whether the specified host is the local host.
|
static boolean |
isWindows()
Returns true if the OSType for this JVM is "windows".
|
static boolean |
shouldRun(String onlyOnPlatforms)
Returns whether or the given value of the
onlyOnPlatforms system property applies to this
host. |
public static final String ONLY_ON_PLATFORMS_PROP
onlyOnPlatforms system propertyshouldRun(java.lang.String),
Constant Field Valuespublic static String getLocalHost()
HydraRuntimeException - if the IPv4 address is not found.public static String getCanonicalHostName()
HydraRuntimeException - if the IPv4 address is not found.protected static boolean compareHosts(String host1, String host2)
protected static String getNoncanonicalHostName(String host)
HydraRuntimeException - if no host is specified.public static String getCanonicalHostName(String host)
HydraRuntimeException - if the host is not found.public static boolean isLocalHost(String host)
public static String getHostAddress()
HydraRuntimeException - if an address of the appropriate type
cannot be found.public static String getHostAddress(InetAddress addr)
InetAddress.getHostAddress() that removes the
scope_id from all IPv4 address and all global IPv6 addresses.
We don't need to use isIPv6LinkLocalAddress(java.net.Inet6Address) because that
is for the case where the scope_id is missing.addr - public static InetAddress getIPAddress()
HydraRuntimeException - if an address of the appropriate type
cannot be found.protected static InetAddress getIPv4Address()
HydraRuntimeException - if the IPv4 address cannot be found.public static InetAddress getIPv6Address()
HydraRuntimeException - if the IPv6 address cannot be found.public static boolean isWindows()
public static HostHelper.OSType getLocalHostOS()
public static HostHelper.OSType getHostOS(String host)
public static boolean shouldRun(String onlyOnPlatforms)
onlyOnPlatforms system property applies to this
host. Note that this only applies to the host on which MasterController runs. Another mechanism must be used if you
want to restrict the platforms on which client VMs can run.onlyOnPlatforms - A comma-separated string of platforms (as determined by
the os.name Java system property) on which a test
should be run. Examples of platforms are
SunOS, Linux, and
WindowsIf null or an empty
string (""), then the test should be run on
all platforms.public static String applyRFC2732(String hostname)
hostname - the name to safeguard.Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.