@Test public void shouldAddConfigurationFromXml() throws AmbariException { oldProperties.put("prop1", "v1-old"); Map<String, Map<String, String>> tags = Collections.<String, Map<String, String>>emptyMap(); Map<String, String> mergedProperties = new HashMap<>(); mergedProperties.put("prop1", "v1-old"); mergedProperties.put("prop4", "v4"); expect(amc.createConfig(eq(cluster), eq("hdfs-site"), eq(mergedProperties), anyString(), eq(tags))).andReturn(null); replay(injector, configHelper, amc, cluster, clusters, serviceInfo, oldConfig); upgradeCatalog.addNewConfigurationsFromXml(); verify(configHelper, amc, cluster, clusters, serviceInfo, oldConfig); }
public void addNewConfigurationsFromXml() throws AmbariException { Clusters clusters = injector.getInstance(Clusters.class); if (clusters == null) { return; } ConfigHelper configHelper = injector.getInstance(ConfigHelper.class); Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { Map<String, Set<String>> toAddProperties = new HashMap<String, Set<String>>(); Map<String, Set<String>> toUpdateProperties = new HashMap<String, Set<String>>(); Map<String, Set<String>> toRemoveProperties = new HashMap<String, Set<String>>(); Set<PropertyInfo> stackProperties = configHelper.getStackProperties(cluster); for(String serviceName: cluster.getServices().keySet()) { Set<PropertyInfo> properties = configHelper.getServiceProperties(cluster, serviceName); if (properties == null) { continue; } properties.addAll(stackProperties); for (PropertyInfo property : properties) { String configType = ConfigHelper.fileNameToConfigType(property.getFilename()); PropertyUpgradeBehavior upgradeBehavior = property.getPropertyAmbariUpgradeBehavior(); if (property.isDeleted()) { } else if (upgradeBehavior.isDelete()) { if (!toRemoveProperties.containsKey(configType)) { toRemoveProperties.put(configType, new HashSet<String>()); } toRemoveProperties.get(configType).add(property.getName()); } else if (upgradeBehavior.isUpdate()) { if (!toUpdateProperties.containsKey(configType)) { toUpdateProperties.put(configType, new HashSet<String>()); } toUpdateProperties.get(configType).add(property.getName()); } else if (upgradeBehavior.isAdd()) { if (!toAddProperties.containsKey(configType)) { toAddProperties.put(configType, new HashSet<String>()); } toAddProperties.get(configType).add(property.getName()); } } } for (Entry<String, Set<String>> newProperty : toAddProperties.entrySet()) { String newPropertyKey = newProperty.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, newProperty.getValue(), false, true); } for (Entry<String, Set<String>> newProperty : toUpdateProperties.entrySet()) { String newPropertyKey = newProperty.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, newProperty.getValue(), true, false); } for (Entry<String, Set<String>> toRemove : toRemoveProperties.entrySet()) { String newPropertyKey = toRemove.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, Collections.<String>emptySet(), toRemove.getValue(), false, true); } } } }
AbstractUpgradeCatalog implements UpgradeCatalog { public void addNewConfigurationsFromXml() throws AmbariException { Clusters clusters = injector.getInstance(Clusters.class); if (clusters == null) { return; } ConfigHelper configHelper = injector.getInstance(ConfigHelper.class); Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { Map<String, Set<String>> toAddProperties = new HashMap<String, Set<String>>(); Map<String, Set<String>> toUpdateProperties = new HashMap<String, Set<String>>(); Map<String, Set<String>> toRemoveProperties = new HashMap<String, Set<String>>(); Set<PropertyInfo> stackProperties = configHelper.getStackProperties(cluster); for(String serviceName: cluster.getServices().keySet()) { Set<PropertyInfo> properties = configHelper.getServiceProperties(cluster, serviceName); if (properties == null) { continue; } properties.addAll(stackProperties); for (PropertyInfo property : properties) { String configType = ConfigHelper.fileNameToConfigType(property.getFilename()); PropertyUpgradeBehavior upgradeBehavior = property.getPropertyAmbariUpgradeBehavior(); if (property.isDeleted()) { } else if (upgradeBehavior.isDelete()) { if (!toRemoveProperties.containsKey(configType)) { toRemoveProperties.put(configType, new HashSet<String>()); } toRemoveProperties.get(configType).add(property.getName()); } else if (upgradeBehavior.isUpdate()) { if (!toUpdateProperties.containsKey(configType)) { toUpdateProperties.put(configType, new HashSet<String>()); } toUpdateProperties.get(configType).add(property.getName()); } else if (upgradeBehavior.isAdd()) { if (!toAddProperties.containsKey(configType)) { toAddProperties.put(configType, new HashSet<String>()); } toAddProperties.get(configType).add(property.getName()); } } } for (Entry<String, Set<String>> newProperty : toAddProperties.entrySet()) { String newPropertyKey = newProperty.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, newProperty.getValue(), false, true); } for (Entry<String, Set<String>> newProperty : toUpdateProperties.entrySet()) { String newPropertyKey = newProperty.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, newProperty.getValue(), true, false); } for (Entry<String, Set<String>> toRemove : toRemoveProperties.entrySet()) { String newPropertyKey = toRemove.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, Collections.<String>emptySet(), toRemove.getValue(), false, true); } } } } }
AbstractUpgradeCatalog implements UpgradeCatalog { public void addNewConfigurationsFromXml() throws AmbariException { Clusters clusters = injector.getInstance(Clusters.class); if (clusters == null) { return; } ConfigHelper configHelper = injector.getInstance(ConfigHelper.class); Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { Map<String, Set<String>> toAddProperties = new HashMap<String, Set<String>>(); Map<String, Set<String>> toUpdateProperties = new HashMap<String, Set<String>>(); Map<String, Set<String>> toRemoveProperties = new HashMap<String, Set<String>>(); Set<PropertyInfo> stackProperties = configHelper.getStackProperties(cluster); for(String serviceName: cluster.getServices().keySet()) { Set<PropertyInfo> properties = configHelper.getServiceProperties(cluster, serviceName); if (properties == null) { continue; } properties.addAll(stackProperties); for (PropertyInfo property : properties) { String configType = ConfigHelper.fileNameToConfigType(property.getFilename()); PropertyUpgradeBehavior upgradeBehavior = property.getPropertyAmbariUpgradeBehavior(); if (property.isDeleted()) { } else if (upgradeBehavior.isDelete()) { if (!toRemoveProperties.containsKey(configType)) { toRemoveProperties.put(configType, new HashSet<String>()); } toRemoveProperties.get(configType).add(property.getName()); } else if (upgradeBehavior.isUpdate()) { if (!toUpdateProperties.containsKey(configType)) { toUpdateProperties.put(configType, new HashSet<String>()); } toUpdateProperties.get(configType).add(property.getName()); } else if (upgradeBehavior.isAdd()) { if (!toAddProperties.containsKey(configType)) { toAddProperties.put(configType, new HashSet<String>()); } toAddProperties.get(configType).add(property.getName()); } } } for (Entry<String, Set<String>> newProperty : toAddProperties.entrySet()) { String newPropertyKey = newProperty.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, newProperty.getValue(), false, true); } for (Entry<String, Set<String>> newProperty : toUpdateProperties.entrySet()) { String newPropertyKey = newProperty.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, newProperty.getValue(), true, false); } for (Entry<String, Set<String>> toRemove : toRemoveProperties.entrySet()) { String newPropertyKey = toRemove.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, Collections.<String>emptySet(), toRemove.getValue(), false, true); } } } } @Inject  AbstractUpgradeCatalog(Injector injector); protected  AbstractUpgradeCatalog(); }
AbstractUpgradeCatalog implements UpgradeCatalog { public void addNewConfigurationsFromXml() throws AmbariException { Clusters clusters = injector.getInstance(Clusters.class); if (clusters == null) { return; } ConfigHelper configHelper = injector.getInstance(ConfigHelper.class); Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { Map<String, Set<String>> toAddProperties = new HashMap<String, Set<String>>(); Map<String, Set<String>> toUpdateProperties = new HashMap<String, Set<String>>(); Map<String, Set<String>> toRemoveProperties = new HashMap<String, Set<String>>(); Set<PropertyInfo> stackProperties = configHelper.getStackProperties(cluster); for(String serviceName: cluster.getServices().keySet()) { Set<PropertyInfo> properties = configHelper.getServiceProperties(cluster, serviceName); if (properties == null) { continue; } properties.addAll(stackProperties); for (PropertyInfo property : properties) { String configType = ConfigHelper.fileNameToConfigType(property.getFilename()); PropertyUpgradeBehavior upgradeBehavior = property.getPropertyAmbariUpgradeBehavior(); if (property.isDeleted()) { } else if (upgradeBehavior.isDelete()) { if (!toRemoveProperties.containsKey(configType)) { toRemoveProperties.put(configType, new HashSet<String>()); } toRemoveProperties.get(configType).add(property.getName()); } else if (upgradeBehavior.isUpdate()) { if (!toUpdateProperties.containsKey(configType)) { toUpdateProperties.put(configType, new HashSet<String>()); } toUpdateProperties.get(configType).add(property.getName()); } else if (upgradeBehavior.isAdd()) { if (!toAddProperties.containsKey(configType)) { toAddProperties.put(configType, new HashSet<String>()); } toAddProperties.get(configType).add(property.getName()); } } } for (Entry<String, Set<String>> newProperty : toAddProperties.entrySet()) { String newPropertyKey = newProperty.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, newProperty.getValue(), false, true); } for (Entry<String, Set<String>> newProperty : toUpdateProperties.entrySet()) { String newPropertyKey = newProperty.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, newProperty.getValue(), true, false); } for (Entry<String, Set<String>> toRemove : toRemoveProperties.entrySet()) { String newPropertyKey = toRemove.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, Collections.<String>emptySet(), toRemove.getValue(), false, true); } } } } @Inject  AbstractUpgradeCatalog(Injector injector); protected  AbstractUpgradeCatalog(); @Override String getSourceVersion(); @Transactional int updateMetaInfoVersion(String version); void addConnectionTimeoutParamForWebAndMetricAlerts(); void addNewConfigurationsFromXml(); @Override void upgradeSchema(); @Override void preUpgradeData(); @Override void setConfigUpdatesFileName(String ambariUpgradeConfigUpdatesFileName); @Override void upgradeData(); @Override final void updateDatabaseSchemaVersion(); @Override boolean isFinal(); @Override String toString(); @Override void onPostUpgrade(); }
AbstractUpgradeCatalog implements UpgradeCatalog { public void addNewConfigurationsFromXml() throws AmbariException { Clusters clusters = injector.getInstance(Clusters.class); if (clusters == null) { return; } ConfigHelper configHelper = injector.getInstance(ConfigHelper.class); Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { Map<String, Set<String>> toAddProperties = new HashMap<String, Set<String>>(); Map<String, Set<String>> toUpdateProperties = new HashMap<String, Set<String>>(); Map<String, Set<String>> toRemoveProperties = new HashMap<String, Set<String>>(); Set<PropertyInfo> stackProperties = configHelper.getStackProperties(cluster); for(String serviceName: cluster.getServices().keySet()) { Set<PropertyInfo> properties = configHelper.getServiceProperties(cluster, serviceName); if (properties == null) { continue; } properties.addAll(stackProperties); for (PropertyInfo property : properties) { String configType = ConfigHelper.fileNameToConfigType(property.getFilename()); PropertyUpgradeBehavior upgradeBehavior = property.getPropertyAmbariUpgradeBehavior(); if (property.isDeleted()) { } else if (upgradeBehavior.isDelete()) { if (!toRemoveProperties.containsKey(configType)) { toRemoveProperties.put(configType, new HashSet<String>()); } toRemoveProperties.get(configType).add(property.getName()); } else if (upgradeBehavior.isUpdate()) { if (!toUpdateProperties.containsKey(configType)) { toUpdateProperties.put(configType, new HashSet<String>()); } toUpdateProperties.get(configType).add(property.getName()); } else if (upgradeBehavior.isAdd()) { if (!toAddProperties.containsKey(configType)) { toAddProperties.put(configType, new HashSet<String>()); } toAddProperties.get(configType).add(property.getName()); } } } for (Entry<String, Set<String>> newProperty : toAddProperties.entrySet()) { String newPropertyKey = newProperty.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, newProperty.getValue(), false, true); } for (Entry<String, Set<String>> newProperty : toUpdateProperties.entrySet()) { String newPropertyKey = newProperty.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, newProperty.getValue(), true, false); } for (Entry<String, Set<String>> toRemove : toRemoveProperties.entrySet()) { String newPropertyKey = toRemove.getKey(); updateConfigurationPropertiesWithValuesFromXml(newPropertyKey, Collections.<String>emptySet(), toRemove.getValue(), false, true); } } } } @Inject  AbstractUpgradeCatalog(Injector injector); protected  AbstractUpgradeCatalog(); @Override String getSourceVersion(); @Transactional int updateMetaInfoVersion(String version); void addConnectionTimeoutParamForWebAndMetricAlerts(); void addNewConfigurationsFromXml(); @Override void upgradeSchema(); @Override void preUpgradeData(); @Override void setConfigUpdatesFileName(String ambariUpgradeConfigUpdatesFileName); @Override void upgradeData(); @Override final void updateDatabaseSchemaVersion(); @Override boolean isFinal(); @Override String toString(); @Override void onPostUpgrade(); static final String CONFIGURATION_TYPE_RANGER_HBASE_PLUGIN_PROPERTIES; static final String CONFIGURATION_TYPE_RANGER_KNOX_PLUGIN_PROPERTIES; static final String CONFIGURATION_TYPE_RANGER_HIVE_PLUGIN_PROPERTIES; static final String PROPERTY_RANGER_HBASE_PLUGIN_ENABLED; static final String PROPERTY_RANGER_KNOX_PLUGIN_ENABLED; static final String PROPERTY_RANGER_HIVE_PLUGIN_ENABLED; static final String YARN_SCHEDULER_CAPACITY_ROOT_QUEUE; static final String YARN_SCHEDULER_CAPACITY_ROOT_QUEUES; static final String QUEUES; static final String ALERT_URL_PROPERTY_CONNECTION_TIMEOUT; }