private Set<ExtensionVersionResponse> getExtensionVersions(ExtensionVersionRequest request) throws AmbariException {
    Set<ExtensionVersionResponse> response;

    String extensionName = request.getExtensionName();
    String extensionVersion = request.getExtensionVersion();

    if (extensionVersion != null) {
      ExtensionInfo extensionInfo = ambariMetaInfo.getExtension(extensionName, extensionVersion);
      response = Collections.singleton(extensionInfo.convertToResponse());
    } else {
      try {
        Collection<ExtensionInfo> extensionInfos = ambariMetaInfo.getExtensions(extensionName);
        response = new HashSet<>();
        for (ExtensionInfo extensionInfo: extensionInfos) {
          response.add(extensionInfo.convertToResponse());
        }
      } catch (StackAccessException e) {
        response = Collections.emptySet();
      }
    }

    return response;
  }
Chooses a healthy host from the list of candidate hosts randomly. If there
are no healthy hosts, then this method will return {@code null}.
<p/>
The host's {@link HostState} is used to determine if a host is healthy.

@return a random healthy host, or {@code null}.
@throws AmbariException
@see {@link HostState#HEALTHY}
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java