private void changeConfigurations(Cluster cluster,
      List<ConfigurationChanges> configurationChanges, UpgradeContext upgradeContext)
      throws AmbariException {
    if (null == configurationChanges) {
      return;
    }

    for (ConfigurationChanges configTypeChanges : configurationChanges) {
      String configType = configTypeChanges.getConfigType();

      // the configuration could be null, so try to figure out if we're creating
      // it by checking all of the changes being made
      Config config = cluster.getDesiredConfigByType(configType);
      if (null == config) {
        // no additions/updates, so just skip it entirely
        if (configTypeChanges.isOnlyRemovals()) {
          continue;
        }

        Direction direction = upgradeContext.getDirection();
        String serviceVersionNote = String.format("%s %s %s", direction.getText(true),
            direction.getPreposition(), upgradeContext.getRepositoryVersion().getVersion());

        m_configHelper.createConfigType(cluster, upgradeContext.getRepositoryVersion().getStackId(),
            m_amc, configType, new HashMap<>(), m_amc.getAuthName(), serviceVersionNote);

        config = cluster.getDesiredConfigByType(configType);
        if (null == config) {
          throw new AmbariException(
              String.format("Unable to create the % configuration type", configType));
        }
      }

      List<PropertyChange> propertyChanges = configTypeChanges.getPropertyChanges();
      for (PropertyChange propertyChange : propertyChanges) {
        ChangeType changeType = propertyChange.getChangeType();
        switch (changeType) {
          case REMOVE:
            config.deleteProperties(Collections.singletonList(propertyChange.getPropertyName()));
            break;
          case SET:
            Map<String, String> propertyMap = new HashMap<>();
            propertyMap.put(propertyChange.getPropertyName(), propertyChange.getPropertyValue());
            config.updateProperties(propertyMap);
            break;
          default:
            LOG.error("Unknown configuration action type {}", changeType);
            throw new AmbariException(
                "Unable to update configurations because " + changeType + " is an unknown type");
        }
      }

      config.save();
    }
  }
Updates configurations in the cluster. This will create new configuration
types if changes are required for one which does not exist.

@param cluster
         the cluster used to retrieve the configurations.
@param configurationChanges
         the changes to make.
@param upgradeContext
         upgrade information for the current upgrade or downgrade.
@throws AmbariException
          if there was a problem determining what change to make or while
          making changes.
ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/PluginUpgradeServerAction.java