@Override
  public boolean addComponent(String component, ProvisionAction provisionAction) {
    boolean added;
    if (!components.containsKey(component)) {
      components.put(component, new Component(component, provisionAction));
      added = true;
    } else {
      added = false;
    }

    if (stack.isMasterComponent(component)) {
      containsMasterComponent = true;
    }
    if (added) {
      String service = stack.getServiceForComponent(component);
      if (service != null) {
        // an example of a component without a service in the stack is AMBARI_SERVER
        Set<String> serviceComponents = componentsForService.get(service);
        if (serviceComponents == null) {
          serviceComponents = new HashSet<>();
          componentsForService.put(service, serviceComponents);
        }
        serviceComponents.add(component);
      }
    }
    return added;
  }
Add a component with the specified provision action to the
  host group.

@param component  component name
@param provisionAction provision action for this component

@return true if component was added; false if component already existed
ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java