code: public String getClusterName(Configuration conf) {
      // ResourceManager address in Hadoop2
      String clusterIdentifier = conf.get("yarn.resourcemanager.address");
      clusterIdentifier = getClusterName(clusterIdentifier);
  
      // If job is running outside of Hadoop (Standalone) use hostname
      // If clusterIdentifier is localhost or 0.0.0.0 use hostname
      if (clusterIdentifier == null || StringUtils.startsWithIgnoreCase(clusterIdentifier, "localhost")
          || StringUtils.startsWithIgnoreCase(clusterIdentifier, "0.0.0.0")) {
        try {
          clusterIdentifier = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
          // Do nothing. Tag will not be generated
        }
      }
  
      return clusterIdentifier;
    }
docs: Returns the cluster name on which the application is running. Uses Hadoop configuration passed in to get the
  url of the resourceManager or jobtracker. The URL is then translated into a human readable cluster name using
  {@link #getClusterName(String)}
  
  <p>
  <b>MapReduce mode</b> Uses the value for "yarn.resourcemanager.address" from {@link Configuration} excluding the
  port number.
  </p>
  
  <p>
  <b>Standalone mode (outside of hadoop)</b> Uses the Hostname of {@link InetAddress#getLocalHost()}
  </p>
  
  <p>
  Use {@link #getClusterName(String)} if you already have the cluster URL
  </p>
  
  @see #getClusterName()
  @param conf Hadoop configuration to use to get resourceManager or jobTracker URLs