public static boolean isValidHostname(String hostname) {
    return (hostname != null) && REGEX_VALID_HOSTNAME.matcher(hostname).matches();
  }
Validates a hostname to ensure it meets the specifications described in RFC 1123.
<p>
Note: this does not validate whether the host exists or if the name is a valid DNS name.
For example,  host.example.anything is a valid host name however may be an invalid DNS name
since "anything" may not be a valid top-level domain.

@param hostname a hostname
@return true if the hostname is valid; false otherwise
ambari-server/src/main/java/org/apache/ambari/server/utils/HostUtils.java