private void processComponentAdvertisedVersion(Cluster cluster, ServiceComponent sc,
      ServiceComponentHost sch, String newVersion) throws AmbariException {
    if (StringUtils.isBlank(newVersion)) {
      return;
    }

    String previousVersion = sch.getVersion();
    String desiredVersion = sc.getDesiredVersion();
    UpgradeState upgradeState = sch.getUpgradeState();

    boolean versionIsCorrect = StringUtils.equals(desiredVersion, newVersion);

    // update the SCH to the new version reported only if it changed
    if (!StringUtils.equals(previousVersion, newVersion)) {
      sch.setVersion(newVersion);
    }

    if (previousVersion == null || StringUtils.equalsIgnoreCase(UNKNOWN_VERSION, previousVersion)) {
      // value may be "UNKNOWN" when upgrading from older Ambari versions
      // or if host component reports it's version for the first time
      sch.setUpgradeState(UpgradeState.NONE);
      sch.recalculateHostVersionState();
    } else {
      if (versionIsCorrect) {
        boolean isUpgradeInProgressForThisComponent = null != cluster.getUpgradeInProgress()
            && upgradeState != UpgradeState.NONE;

        if (isUpgradeInProgressForThisComponent) {
          setUpgradeStateAndRecalculateHostVersions(sch, UpgradeState.COMPLETE);
        } else {
          // no upgrade in progress for this component, then this should always
          // be NONE
          setUpgradeStateAndRecalculateHostVersions(sch, UpgradeState.NONE);
        }
      } else {
        // if the versions don't match for any reason, regardless of upgrade
        // state, then VERSION_MISMATCH it
        setUpgradeStateAndRecalculateHostVersions(sch, UpgradeState.VERSION_MISMATCH);
      }
    }

    sc.updateRepositoryState(newVersion);
  }
Updates the version and {@link UpgradeState} for the specified
{@link ServiceComponentHost} if necessary. If the version or the upgrade
state changes, then this method will call
{@link ServiceComponentHost#recalculateHostVersionState()} in order to
ensure that the host version state is properly updated.
<p/>


@param cluster
@param sc
@param sch
@param newVersion
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java