public RequestStageContainer doUpdateResources(final RequestStageContainer stages, final Request request,
                                                  Predicate predicate, boolean performQueryEvaluation,
                                                  boolean useGeneratedConfigs, boolean useClusterHostInfo)
                                                  throws UnsupportedPropertyException,
                                                         SystemException,
                                                         NoSuchResourceException,
                                                         NoSuchParentResourceException {

    final Set<ServiceComponentHostRequest> requests = new HashSet<>();

    final boolean runSmokeTest = "true".equals(getQueryParameterValue(
        QUERY_PARAMETERS_RUN_SMOKE_TEST_ID, predicate));

    Set<String> queryIds = Collections.singleton(COMPONENT_NAME);

    Request queryRequest = PropertyHelper.getReadRequest(queryIds);
    // will take care of 404 exception

    Set<Resource> matchingResources = getResourcesForUpdate(queryRequest, predicate);

    for (Resource queryResource : matchingResources) {
      //todo: predicate evaluation was removed for BUG-28737 and the removal of this breaks
      //todo: the new "add hosts" api.  BUG-4818 is the root cause and needs to be addressed
      //todo: and then this predicate evaluation should always be performed and the
      //todo: temporary performQueryEvaluation flag hack should be removed.
      if (! performQueryEvaluation || predicate.evaluate(queryResource)) {
        Map<String, Object> updateRequestProperties = new HashMap<>();

        // add props from query resource
        updateRequestProperties.putAll(PropertyHelper.getProperties(queryResource));

        // add properties from update request
        //todo: should we flag value size > 1?
        if (request.getProperties() != null && request.getProperties().size() != 0) {
          updateRequestProperties.putAll(request.getProperties().iterator().next());
        }
        requests.add(changeRequest(updateRequestProperties));
      }
    }

    if (requests.isEmpty()) {
      String msg = String.format("Skipping updating hosts: no matching requests for %s", predicate);
      LOG.info(msg);
      throw new NoSuchResourceException(msg);
    }

    RequestStageContainer requestStages = modifyResources(new Command<RequestStageContainer>() {
      @Override
      public RequestStageContainer invoke() throws AmbariException {
        RequestStageContainer stageContainer = null;
        try {
          stageContainer = updateHostComponents(stages, requests, request.getRequestInfoProperties(),
              runSmokeTest, useGeneratedConfigs, useClusterHostInfo);
        } catch (Exception e) {
          LOG.info("Caught an exception while updating host components, will not try again: {}", e.getMessage(), e);
          // !!! IllegalArgumentException results in a 400 response, RuntimeException results in 500.
          if (e instanceof IllegalArgumentException) {
            throw (IllegalArgumentException) e;
          } else {
            throw new RuntimeException("Update Host request submission failed: " + e, e);
          }
        }

        return stageContainer;
      }
    });
    notifyUpdate(Resource.Type.HostComponent, request, predicate);
    return requestStages;
  }
Update resources.

@param stages                  request stage container
@param request                 request
@param predicate               request predicate
@param performQueryEvaluation  should query be evaluated for matching resource set
@param useGeneratedConfigs     should update request contains actual configs
@param useClusterHostInfo      should update request contain cluster topology info
@return
@throws UnsupportedPropertyException   an unsupported property was specified in the request
@throws SystemException                an unknown exception occurred
@throws NoSuchResourceException        the query didn't match any resources
@throws NoSuchParentResourceException  a specified parent resource doesn't exist
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java