protected void updateConfigurationPropertiesForCluster(Cluster cluster, String configType,
        Map<String, String> properties, Set<String> removePropertiesList, boolean updateIfExists,
        boolean createNewConfigType) throws AmbariException {
    AmbariManagementController controller = injector.getInstance(AmbariManagementController.class);
    String newTag = "version" + System.currentTimeMillis();

    if (properties != null) {
      Map<String, Config> all = cluster.getConfigsByType(configType);
      if (all == null || !all.containsKey(newTag) || properties.size() > 0) {
        Map<String, String> oldConfigProperties;
        Config oldConfig = cluster.getDesiredConfigByType(configType);

        if (oldConfig == null && !createNewConfigType) {
          LOG.info("Config " + configType + " not found. Assuming service not installed. " +
              "Skipping configuration properties update");
          return;
        } else if (oldConfig == null) {
          oldConfigProperties = new HashMap<>();
        } else {
          oldConfigProperties = oldConfig.getProperties();
        }

        Multimap<ConfigUpdateType, Entry<String, String>> propertiesToLog = ArrayListMultimap.create();
        String serviceName = cluster.getServiceByConfigType(configType);

        Map<String, String> mergedProperties =
          mergeProperties(oldConfigProperties, properties, updateIfExists, propertiesToLog);

        if (removePropertiesList != null) {
          mergedProperties = removeProperties(mergedProperties, removePropertiesList, propertiesToLog);
        }

        if (propertiesToLog.size() > 0) {
          try {
            configuration.writeToAmbariUpgradeConfigUpdatesFile(propertiesToLog, configType, serviceName, ambariUpgradeConfigUpdatesFileName);
          } catch(Exception e) {
            LOG.error("Write to config updates file failed:", e);
          }
        }

        if (!Maps.difference(oldConfigProperties, mergedProperties).areEqual()) {
          LOG.info("Applying configuration with tag '{}' and configType '{}' to " +
            "cluster '{}'", newTag, configType, cluster.getClusterName());

          Map<String, Map<String, String>> propertiesAttributes = null;
          if (oldConfig != null) {
            propertiesAttributes = oldConfig.getPropertiesAttributes();
          }

          // the contract of creating a configuration requires non-null
          // collections for attributes
          if (null == propertiesAttributes) {
            propertiesAttributes = Collections.emptyMap();
          }

          controller.createConfig(cluster, cluster.getDesiredStackVersion(), configType,
              mergedProperties, newTag, propertiesAttributes);

          Config baseConfig = cluster.getConfig(configType, newTag);
          if (baseConfig != null) {
            String authName = AUTHENTICATED_USER_NAME;

            String configVersionNote = String.format("Updated %s during Ambari Upgrade from %s to %s.", configType, getSourceVersion(), getTargetVersion());
            if (cluster.addDesiredConfig(authName, Collections.singleton(baseConfig), configVersionNote) != null) {
              String oldConfigString = (oldConfig != null) ? " from='" + oldConfig.getTag() + "'" : "";
              LOG.info("cluster '" + cluster.getClusterName() + "' "
                + "changed by: '" + authName + "'; "
                + "type='" + baseConfig.getType() + "' "
                + "tag='" + baseConfig.getTag() + "'"
                + oldConfigString);
            }

            ConfigHelper configHelper = injector.getInstance(ConfigHelper.class);
            configHelper.updateAgentConfigs(Collections.singleton(cluster.getClusterName()));
          }
        } else {
          LOG.info("No changes detected to config " + configType + ". Skipping configuration properties update");
        }
      }
    }
  }
Update properties for the cluster
@param cluster cluster object
@param configType config to be updated
@param properties properties to be added or updated. Couldn't be <code>null</code>, but could be empty.
@param removePropertiesList properties to be removed. Could be <code>null</code>
@param updateIfExists
@param createNewConfigType
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java