public static String getHostname(@NonNull Configuration conf, @NonNull ServerType serverType)
    throws UnknownHostException {
    String hostname;
    switch (serverType) {
      case MASTER:
        hostname = conf.get(MASTER_HOSTNAME_KEY);
        break;
      case REGIONSERVER:
        hostname = conf.get(UNSAFE_RS_HOSTNAME_KEY);
        break;
      default:
        hostname = null;
    }
    if (hostname == null || hostname.isEmpty()) {
      return Strings.domainNamePointerToHostName(
        getDefaultHost(conf.get("hbase." + serverType.getName() + ".dns.interface", "default"),
          conf.get("hbase." + serverType.getName() + ".dns.nameserver", "default")));
    } else {
      return hostname;
    }
  }
Get the configured hostname for a given ServerType. Gets the default hostname if not specified
in the configuration.
@param conf       Configuration to look up.
@param serverType ServerType to look up in the configuration for overrides.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java