public ClusterVersionSummary getClusterSummary(Cluster cluster, AmbariMetaInfo metaInfo)
      throws AmbariException {

    Map<String, ManifestService> manifests = buildManifestByService();
    Set<String> available = getAvailableServiceNames();

    available = available.isEmpty() ? manifests.keySet() : available;

    Map<String, ServiceVersionSummary> summaries = new HashMap<>();
    for (String serviceName : available) {
      Service service = cluster.getServices().get(serviceName);
      if (null == service) {
        // !!! service is not installed
        continue;
      }

      ServiceVersionSummary summary = new ServiceVersionSummary();
      summaries.put(service.getName(), summary);

      StackId stackId = service.getDesiredRepositoryVersion().getStackId();
      StackInfo stack = metaInfo.getStack(stackId);
      StackReleaseVersion stackReleaseVersion = stack.getReleaseVersion();

      StackReleaseInfo serviceVersion = stackReleaseVersion.parse(
          service.getDesiredRepositoryVersion().getVersion());

      // !!! currently only one version is supported (unique service names)
      ManifestService manifest = manifests.get(serviceName);

      final StackReleaseInfo versionToCompare;
      final String summaryReleaseVersion;

      if (StringUtils.isEmpty(manifest.releaseVersion)) {
        versionToCompare = release.getReleaseInfo();
        summaryReleaseVersion = release.version;
      } else {
        versionToCompare = stackReleaseVersion.parse(manifest.releaseVersion);
        summaryReleaseVersion = manifest.releaseVersion;
      }

      summary.setVersions(manifest.version, summaryReleaseVersion);

      if (RepositoryType.STANDARD == release.repositoryType) {
        summary.setUpgrade(true);
      } else {
        // !!! installed service already meets the release version, then nothing to upgrade
        // !!! TODO should this be using the release compatible-with field?
        Comparator<StackReleaseInfo> comparator = stackReleaseVersion.getComparator();
        if (comparator.compare(versionToCompare, serviceVersion) > 0) {
          summary.setUpgrade(true);
        }
      }
    }

    return new ClusterVersionSummary(summaries);
  }
Gets a summary for cluster given the version information in this version.
@param cluster the cluster by which to iterate services
@return a summary instance
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java