private Map<ProvisionStep, List<Predicate>> createServicePredicates() {
    Preconditions.checkState(customServiceActions != null);
    Preconditions.checkState(customComponentActions != null);

    ProvisionAction requestAction = request.getRequest().getProvisionAction();
    Map<ProvisionStep, List<Predicate>> servicePredicatesByStep = new EnumMap<>(ProvisionStep.class);

    for (Map.Entry<String, Map<String, Set<String>>> serviceEntry : request.newServices().entrySet()) {
      String serviceName = serviceEntry.getKey();
      Map<String, Set<String>> hostsByComponent = serviceEntry.getValue();

      ProvisionAction serviceAction = customServiceActions.getOrDefault(serviceName, requestAction);
      Predicate serviceNamePredicate = serviceNameIs(serviceName);

      Map<String, Map<ProvisionAction, Set<String>>> customActionByComponent = customComponentActions.get(serviceName);
      if (customActionByComponent == null) {
        classifyItem(serviceAction, serviceNamePredicate, servicePredicatesByStep);
      } else {
        Map<ProvisionStep, List<Predicate>> componentPredicatesByStep =
          createComponentPredicates(serviceAction, hostsByComponent, customActionByComponent);

        applyComponentOverrides(servicePredicatesByStep, serviceNamePredicate, componentPredicatesByStep);
      }
    }
    return servicePredicatesByStep;
  }
Creates predicates for each service for each {@link ProvisionStep} as necessary.

@return step -> service predicates map
ambari-server/src/main/java/org/apache/ambari/server/topology/addservice/ProvisionActionPredicateBuilder.java