private boolean isActiveUrl(String url) {
    InputStream inputStream = null;
    try {
      inputStream = context.getURLStreamProvider()
        .readFrom(url + RM_INFO_API_ENDPOINT, "GET", (String) null, new HashMap<String, String>());
      String response = IOUtils.toString(inputStream);
      String haState = getHAStateFromRMResponse(response);

      if (StringUtils.isNotEmpty(haState) && "ACTIVE".equals(haState))
        return true;

    } catch (IOException e) {
      LOG.error("Resource Manager : %s is not accessible. This cannot be a active RM. Returning false.");
    } finally {
      if (inputStream != null) {
        try {
          inputStream.close();
        } catch (IOException e) { /* Noting to do */ }
      }
    }
    return false;
  }
Queries RM API to check the haState.
@param url Resource Manager root url
@return true if haState returned is ACTIVE else false
contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java