protected Set<InfoTuple> validateComponentVersions(UpgradeContext upgradeContext)
      throws AmbariException {

    Set<InfoTuple> errors = new TreeSet<>();

    Cluster cluster = upgradeContext.getCluster();
    Set<String> servicesParticipating = upgradeContext.getSupportedServices();
    for (String serviceName : servicesParticipating) {
      Service service = cluster.getService(serviceName);
      RepositoryVersionEntity repositoryVersionEntity = upgradeContext.getTargetRepositoryVersion(serviceName);
      StackId targetStackId = repositoryVersionEntity.getStackId();
      String targetVersion = repositoryVersionEntity.getVersion();

      for (ServiceComponent serviceComponent : service.getServiceComponents().values()) {
        ComponentInfo componentInfo = ambariMetaInfo.getComponent(targetStackId.getStackName(),
            targetStackId.getStackVersion(), service.getName(), serviceComponent.getName());

        if (!componentInfo.isVersionAdvertised()) {
          continue;
        }

        for (ServiceComponentHost serviceComponentHost : serviceComponent.getServiceComponentHosts().values()) {
          if (!StringUtils.equals(targetVersion, serviceComponentHost.getVersion())) {
            errors.add(new InfoTuple(service.getName(), serviceComponent.getName(),
                serviceComponentHost.getHostName(), serviceComponentHost.getVersion(),
                targetVersion));
          }
        }
      }
    }


    return errors;
  }
Gets any host components which have not been propertly upgraded or
downgraded.

@param upgradeContext
         the upgrade context (not {@code null}).
@return a list of {@link InfoTuple} representing components which should
        have been upgraded but did not.
ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java