Repository: ambari Updated Branches: refs/heads/trunk 2dc55f08f -> 926acf4fc
AMBARI-7019. sqoop-env and other configs exists for unavailable services(after upgrade from ambari 1.6.1 -> 1.7.0).(vbrodetskyi) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/926acf4f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/926acf4f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/926acf4f Branch: refs/heads/trunk Commit: 926acf4fc681e01f1568f6c3bdbf4ab254040b07 Parents: 2dc55f0 Author: Vitaly Brodetskyi <[email protected]> Authored: Wed Aug 27 13:29:39 2014 +0300 Committer: Vitaly Brodetskyi <[email protected]> Committed: Wed Aug 27 13:29:39 2014 +0300 ---------------------------------------------------------------------- .../controller/AmbariManagementControllerImpl.java | 2 +- .../controller/internal/ClusterResourceProvider.java | 6 +++--- .../org/apache/ambari/server/state/ConfigHelper.java | 12 ++++++------ .../apache/ambari/server/upgrade/UpgradeCatalog170.java | 6 ++++-- .../controller/AmbariManagementControllerTest.java | 4 +++- .../ambari/server/upgrade/UpgradeCatalog170Test.java | 9 +++++---- 6 files changed, 22 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/926acf4f/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java index f7f2f2d..c6b2f9f 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java @@ -657,7 +657,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle if(request.getType().equals(Configuration.GLOBAL_CONFIG_TAG)) { Map<String, Map<String, String>> configTypes = new HashMap<String, Map<String, String>>(); configTypes.put(Configuration.GLOBAL_CONFIG_TAG, request.getProperties()); - configHelper.moveDeprecatedGlobals(cluster.getCurrentStackVersion(), configTypes); + configHelper.moveDeprecatedGlobals(cluster.getCurrentStackVersion(), configTypes, cluster.getClusterName()); for(Map.Entry<String, Map<String, String>> configType : configTypes.entrySet()) { String configTypeName = configType.getKey(); http://git-wip-us.apache.org/repos/asf/ambari/blob/926acf4f/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java index 113e7b8..eeee694 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java @@ -870,9 +870,9 @@ public class ClusterResourceProvider extends BaseBlueprintProcessor { * @param blueprintConfigurations map of blueprint configurations keyed by type */ private void handleGlobalsBackwardsCompability(Stack stack, - Map<String, Map<String, String>> blueprintConfigurations) { + Map<String, Map<String, String>> blueprintConfigurations, String clusterName) { StackId stackId = new StackId(stack.getName(), stack.getVersion()); - configHelper.moveDeprecatedGlobals(stackId, blueprintConfigurations); + configHelper.moveDeprecatedGlobals(stackId, blueprintConfigurations, clusterName); } /** @@ -1051,7 +1051,7 @@ public class ClusterResourceProvider extends BaseBlueprintProcessor { HostGroupEntity entity = group.getEntity(); Map<String, Map<String, Config>> groupConfigs = new HashMap<String, Map<String, Config>>(); - handleGlobalsBackwardsCompability(stack, group.getConfigurationProperties()); + handleGlobalsBackwardsCompability(stack, group.getConfigurationProperties(), clusterName); for (Map.Entry<String, Map<String, String>> entry: group.getConfigurationProperties().entrySet()) { String type = entry.getKey(); String service = stack.getServiceForConfigType(type); http://git-wip-us.apache.org/repos/asf/ambari/blob/926acf4f/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java index a0d9e6e..43838d7 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java @@ -414,14 +414,14 @@ public class ConfigHelper { * @param stackId * @param propertyName */ - public Set<String> findConfigTypesByPropertyName(StackId stackId, String propertyName) throws AmbariException { + public Set<String> findConfigTypesByPropertyName(StackId stackId, String propertyName, String clusterName) throws AmbariException { StackInfo stack = ambariMetaInfo.getStackInfo(stackId.getStackName(), stackId.getStackVersion()); Set<String> result = new HashSet<String>(); - - for(ServiceInfo serviceInfo:stack.getServices()) { - Set<PropertyInfo> stackProperties = ambariMetaInfo.getProperties(stack.getName(), stack.getVersion(), serviceInfo.getName()); + + for(Service service : clusters.getCluster(clusterName).getServices().values()) { + Set<PropertyInfo> stackProperties = ambariMetaInfo.getProperties(stack.getName(), stack.getVersion(), service.getName()); for (PropertyInfo stackProperty : stackProperties) { if(stackProperty.getName().equals(propertyName)) { @@ -488,7 +488,7 @@ public class ConfigHelper { * * @param configurations map of configurations keyed by type */ - public void moveDeprecatedGlobals(StackId stackId, Map<String, Map<String, String>> configurations) { + public void moveDeprecatedGlobals(StackId stackId, Map<String, Map<String, String>> configurations, String clusterName) { Map<String, String> globalConfigurations = new HashMap<String, String>(); if(configurations.get(Configuration.GLOBAL_CONFIG_TAG) == null || @@ -508,7 +508,7 @@ public class ConfigHelper { Set<String> newConfigTypes = null; try{ - newConfigTypes = this.findConfigTypesByPropertyName(stackId, propertyName); + newConfigTypes = this.findConfigTypesByPropertyName(stackId, propertyName, clusterName); } catch(AmbariException e) { LOG.error("Exception while getting configurations from the stacks", e); return; http://git-wip-us.apache.org/repos/asf/ambari/blob/926acf4f/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java index 864c084..0ac9da7 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java @@ -812,7 +812,8 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog { if (clusterMap != null && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { - Set<String> configTypes = configHelper.findConfigTypesByPropertyName(cluster.getCurrentStackVersion(), CONTENT_FIELD_NAME); + Set<String> configTypes = configHelper.findConfigTypesByPropertyName(cluster.getCurrentStackVersion(), + CONTENT_FIELD_NAME, cluster.getClusterName()); for(String configType:configTypes) { if(!configType.endsWith(ENV_CONFIGS_POSTFIX)) { @@ -853,7 +854,8 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog { String propertyName = property.getKey(); String propertyValue = property.getValue(); - Set<String> newConfigTypes = configHelper.findConfigTypesByPropertyName(cluster.getCurrentStackVersion(), propertyName); + Set<String> newConfigTypes = configHelper.findConfigTypesByPropertyName(cluster.getCurrentStackVersion(), + propertyName, cluster.getClusterName()); // if it's custom user service global.xml can be still there. newConfigTypes.remove(Configuration.GLOBAL_CONFIG_TAG); http://git-wip-us.apache.org/repos/asf/ambari/blob/926acf4f/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java index cf2bcbb..1bfc25a 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java @@ -8936,6 +8936,7 @@ public class AmbariManagementControllerTest { Set<ServiceRequest> serviceRequests = new HashSet<ServiceRequest>(); serviceRequests.add(new ServiceRequest("c1", "HDFS", null)); + serviceRequests.add(new ServiceRequest("c1", "HIVE", null)); ServiceResourceProviderTest.createServices(amc, serviceRequests); @@ -9144,9 +9145,10 @@ public class AmbariManagementControllerTest { ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps, true, false); serviceRequests.clear(); serviceRequests.add(new ServiceRequest("c1", null, null)); - org.junit.Assert.assertEquals(1, ServiceResourceProviderTest.getServices(amc, serviceRequests).size()); + org.junit.Assert.assertEquals(2, ServiceResourceProviderTest.getServices(amc, serviceRequests).size()); serviceRequests.clear(); serviceRequests.add(new ServiceRequest("c1", "HDFS", null)); + serviceRequests.add(new ServiceRequest("c1", "HIVE", null)); ServiceResourceProviderTest.deleteServices(amc, serviceRequests); serviceRequests.clear(); serviceRequests.add(new ServiceRequest("c1", null, null)); http://git-wip-us.apache.org/repos/asf/ambari/blob/926acf4f/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java index 5210add..e2ce75e 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java @@ -224,7 +224,7 @@ public class UpgradeCatalog170Test { Injector injector = createNiceMock(Injector.class); ConfigHelper configHelper = createNiceMock(ConfigHelper.class); AmbariManagementController amc = createNiceMock(AmbariManagementController.class); - Cluster cluster = createStrictMock(Cluster.class); + Cluster cluster = createNiceMock(Cluster.class); Clusters clusters = createStrictMock(Clusters.class); Config config = createStrictMock(Config.class); Config pigConfig = createStrictMock(Config.class); @@ -323,9 +323,10 @@ public class UpgradeCatalog170Test { expect(cluster.getDesiredConfigByType("global")).andReturn(config).anyTimes(); expect(config.getProperties()).andReturn(globalConfigs).anyTimes(); expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.1")).anyTimes(); - expect(configHelper.findConfigTypesByPropertyName(new StackId("HDP", "2.1"), "prop1")).andReturn(envDicts).once(); - expect(configHelper.findConfigTypesByPropertyName(new StackId("HDP", "2.1"), "smokeuser_keytab")).andReturn(new HashSet<String>()).once(); - expect(configHelper.findConfigTypesByPropertyName(new StackId("HDP", "2.1"), "content")).andReturn(envDicts).once(); + expect(cluster.getClusterName()).andReturn("c1").anyTimes(); + expect(configHelper.findConfigTypesByPropertyName(new StackId("HDP", "2.1"), "prop1", "c1")).andReturn(envDicts).once(); + expect(configHelper.findConfigTypesByPropertyName(new StackId("HDP", "2.1"), "smokeuser_keytab", "c1")).andReturn(new HashSet<String>()).once(); + expect(configHelper.findConfigTypesByPropertyName(new StackId("HDP", "2.1"), "content", "c1")).andReturn(envDicts).once(); expect(configHelper.getPropertyValueFromStackDefenitions(cluster, "hadoop-env", "content")).andReturn("env file contents").once(); expect(injector.getInstance(UserDAO.class)).andReturn(userDAO).anyTimes();
