public Collection<String> verifyComponentCardinalityCount(String component,
                                                            Cardinality cardinality,
                                                            AutoDeployInfo autoDeploy) {

    Map<String, Map<String, String>> configProperties = blueprint.getConfiguration().getProperties();
    Collection<String> cardinalityFailures = new HashSet<>();
    //todo: don't hard code this HA logic here
    if (ClusterTopologyImpl.isNameNodeHAEnabled(configProperties) &&
        (component.equals("SECONDARY_NAMENODE"))) {
      // override the cardinality for this component in an HA deployment,
      // since the SECONDARY_NAMENODE should not be started in this scenario
      cardinality = new Cardinality("0");
    }

    int actualCount = blueprint.getHostGroupsForComponent(component).size();
    if (! cardinality.isValidCount(actualCount)) {
      boolean validated = ! isDependencyManaged(stack, component, configProperties);
      if (! validated && autoDeploy != null && autoDeploy.isEnabled() && cardinality.supportsAutoDeploy()) {
        String coLocateName = autoDeploy.getCoLocate();
        if (coLocateName != null && ! coLocateName.isEmpty()) {
          Collection<HostGroup> coLocateHostGroups = blueprint.getHostGroupsForComponent(coLocateName.split("/")[1]);
          if (! coLocateHostGroups.isEmpty()) {
            validated = true;
            HostGroup group = coLocateHostGroups.iterator().next();
            group.addComponent(component);

          }
        }
      }
      if (! validated) {
        cardinalityFailures.add(component + "(actual=" + actualCount + ", required=" +
            cardinality.getValue() + ")");
      }
    }
    return cardinalityFailures;
  }
Verify that a component meets cardinality requirements.  For components that are
auto-install enabled, will add component to topology if needed.

@param component    component to validate
@param cardinality  required cardinality
@param autoDeploy   auto-deploy information for component

@return collection of missing component information
ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java