|
@@ -356,8 +356,19 @@ public abstract class AbstractUpgradeCatalog implements UpgradeCatalog {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 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
|
|
|
|
+ */
|
|
protected void updateConfigurationPropertiesForCluster(Cluster cluster, String configType,
|
|
protected void updateConfigurationPropertiesForCluster(Cluster cluster, String configType,
|
|
- Map<String, String> properties, boolean updateIfExists, boolean createNewConfigType) throws AmbariException {
|
|
|
|
|
|
+ Map<String, String> properties, Set<String> removePropertiesList, boolean updateIfExists,
|
|
|
|
+ boolean createNewConfigType) throws AmbariException {
|
|
AmbariManagementController controller = injector.getInstance(AmbariManagementController.class);
|
|
AmbariManagementController controller = injector.getInstance(AmbariManagementController.class);
|
|
String newTag = "version" + System.currentTimeMillis();
|
|
String newTag = "version" + System.currentTimeMillis();
|
|
|
|
|
|
@@ -381,6 +392,10 @@ public abstract class AbstractUpgradeCatalog implements UpgradeCatalog {
|
|
Map<String, String> mergedProperties =
|
|
Map<String, String> mergedProperties =
|
|
mergeProperties(oldConfigProperties, properties, updateIfExists);
|
|
mergeProperties(oldConfigProperties, properties, updateIfExists);
|
|
|
|
|
|
|
|
+ if (removePropertiesList != null) {
|
|
|
|
+ mergedProperties = removeProperties(mergedProperties, removePropertiesList);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!Maps.difference(oldConfigProperties, mergedProperties).areEqual()) {
|
|
if (!Maps.difference(oldConfigProperties, mergedProperties).areEqual()) {
|
|
LOG.info("Applying configuration with tag '{}' to " +
|
|
LOG.info("Applying configuration with tag '{}' to " +
|
|
"cluster '{}'", newTag, cluster.getClusterName());
|
|
"cluster '{}'", newTag, cluster.getClusterName());
|
|
@@ -412,6 +427,11 @@ public abstract class AbstractUpgradeCatalog implements UpgradeCatalog {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ protected void updateConfigurationPropertiesForCluster(Cluster cluster, String configType,
|
|
|
|
+ Map<String, String> properties, boolean updateIfExists, boolean createNewConfigType) throws AmbariException {
|
|
|
|
+ updateConfigurationPropertiesForCluster(cluster, configType, properties, null, updateIfExists, createNewConfigType);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Create a new cluster scoped configuration with the new properties added
|
|
* Create a new cluster scoped configuration with the new properties added
|
|
* to the existing set of properties.
|
|
* to the existing set of properties.
|
|
@@ -450,6 +470,17 @@ public abstract class AbstractUpgradeCatalog implements UpgradeCatalog {
|
|
return properties;
|
|
return properties;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private Map<String, String> removeProperties(Map<String, String> originalProperties, Set<String> removeList){
|
|
|
|
+ Map<String, String> properties = new HashMap<String, String>();
|
|
|
|
+ properties.putAll(originalProperties);
|
|
|
|
+ for (String removeProperty: removeList){
|
|
|
|
+ if (originalProperties.containsKey(removeProperty)){
|
|
|
|
+ properties.remove(removeProperty);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return properties;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void upgradeSchema() throws AmbariException, SQLException {
|
|
public void upgradeSchema() throws AmbariException, SQLException {
|
|
DatabaseType databaseType = configuration.getDatabaseType();
|
|
DatabaseType databaseType = configuration.getDatabaseType();
|