You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by js...@apache.org on 2014/11/03 04:32:02 UTC
git commit: AMBARI-8009. Fixes issue where multiple configuration
versions were present when deploying cluster via a blueprint
Repository: ambari
Updated Branches:
refs/heads/trunk d744db13a -> b583fa9f5
AMBARI-8009. Fixes issue where multiple configuration versions were present when deploying cluster via a blueprint
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b583fa9f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b583fa9f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b583fa9f
Branch: refs/heads/trunk
Commit: b583fa9f53c29a3a3640396fc8a2e58cc1a18fe8
Parents: d744db1
Author: Robert Nettleton <rn...@hortonworks.com>
Authored: Sun Nov 2 22:29:59 2014 -0500
Committer: John Speidel <js...@hortonworks.com>
Committed: Sun Nov 2 22:29:59 2014 -0500
----------------------------------------------------------------------
.../server/controller/StackServiceResponse.java | 8 +
.../internal/ClusterResourceProvider.java | 215 +++++++++++---
.../server/controller/internal/Stack.java | 28 ++
.../internal/BlueprintResourceProviderTest.java | 4 +
.../internal/ClusterResourceProviderTest.java | 295 +++++++------------
5 files changed, 323 insertions(+), 227 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/b583fa9f/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
index 9c986b1..a8e3451 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
public class StackServiceResponse {
@@ -39,6 +40,8 @@ public class StackServiceResponse {
private List<String> customCommands;
private Map<String, Map<String, Map<String, String>>> configTypes;
+ private Set<String> excludedConfigTypes;
+
private List<String> requiredServices;
/**
@@ -54,6 +57,7 @@ public class StackServiceResponse {
comments = service.getComment();
serviceVersion = service.getVersion();
configTypes = service.getConfigTypes();
+ excludedConfigTypes = service.getExcludedConfigTypes();
requiredServices = service.getRequiredServices();
serviceCheckSupported = null != service.getCommandScript();
@@ -128,6 +132,10 @@ public class StackServiceResponse {
public Map<String, Map<String, Map<String, String>>> getConfigTypes() {
return configTypes;
}
+
+ public Set<String> getExcludedConfigTypes() {
+ return excludedConfigTypes;
+ }
public List<String> getRequiredServices() {
return requiredServices;
http://git-wip-us.apache.org/repos/asf/ambari/blob/b583fa9f/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 8dd06ec..96b4c8c 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
@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -434,7 +435,7 @@ public class ClusterResourceProvider extends BaseBlueprintProcessor {
String clusterName = (String) properties.get(CLUSTER_NAME_PROPERTY_ID);
createClusterResource(buildClusterResourceProperties(stack, clusterName));
- setConfigurationsOnCluster(clusterName);
+ setConfigurationsOnCluster(clusterName, stack, blueprintHostGroups);
Set<String> services = getServicesToDeploy(stack, blueprintHostGroups);
@@ -685,55 +686,134 @@ public class ClusterResourceProvider extends BaseBlueprintProcessor {
* Set all configurations on the cluster resource.
*
* @param clusterName cluster name
+ * @param stack Stack definition object used for this cluster
+ * @param blueprintHostGroups host groups defined in the Blueprint for this cluster
*
* @throws SystemException an unexpected exception occurred
*/
- private void setConfigurationsOnCluster(String clusterName) throws SystemException {
- for (Map.Entry<String, Map<String, String>> entry : mapClusterConfigurations.entrySet()) {
- String type = entry.getKey();
-
- Map<String, Map<String, String>> confAttributes = mapClusterAttributes.get(type);
- try {
- //todo: properly handle non system exceptions
- setConfigurationsOnCluster(clusterName, type, entry.getValue(), confAttributes);
- } catch (AmbariException e) {
- throw new SystemException("Unable to set configurations on cluster.", e);
+ private void setConfigurationsOnCluster(String clusterName, Stack stack, Map<String, HostGroupImpl> blueprintHostGroups) throws SystemException {
+ List<BlueprintServiceConfigRequest> listofConfigRequests =
+ new LinkedList<BlueprintServiceConfigRequest>();
+
+ // create a list of config requests on a per-service basis, in order
+ // to properly support the new service configuration versioning mechanism
+ // in Ambari
+ for (String service : getServicesToDeploy(stack, blueprintHostGroups)) {
+ BlueprintServiceConfigRequest blueprintConfigRequest =
+ new BlueprintServiceConfigRequest(service);
+
+ Set<String> excludedConfigTypes = stack.getExcludedConfigurationTypes(service);
+ if (excludedConfigTypes == null) {
+ excludedConfigTypes = Collections.emptySet();
}
+
+ for (String serviceConfigType : stack.getConfigurationTypes(service)) {
+ // skip config types that are considered excluded,
+ // which means that they typically belong to another service
+ if (!excludedConfigTypes.contains(serviceConfigType)) {
+ // skip handling of cluster-env here
+ if (!serviceConfigType.equals("cluster-env")) {
+ if (mapClusterConfigurations.containsKey(serviceConfigType)) {
+ blueprintConfigRequest.addConfigElement(serviceConfigType,
+ mapClusterConfigurations.get(serviceConfigType),
+ mapClusterAttributes.get(serviceConfigType));
+ }
+ }
+ }
+ }
+
+ listofConfigRequests.add(blueprintConfigRequest);
}
+
+ // since the stack returns "cluster-env" with each service's config
+ // this code needs to ensure that only one ClusterRequest occurs for
+ // the global cluster-env configuration
+ BlueprintServiceConfigRequest globalConfigRequest =
+ new BlueprintServiceConfigRequest("GLOBAL-CONFIG");
+ globalConfigRequest.addConfigElement("cluster-env",
+ mapClusterConfigurations.get("cluster-env"),
+ mapClusterAttributes.get("cluster-env"));
+ listofConfigRequests.add(globalConfigRequest);
+
+ try {
+ //todo: properly handle non system exceptions
+ setConfigurationsOnCluster(clusterName, listofConfigRequests);
+ } catch (AmbariException e) {
+ throw new SystemException("Unable to set configurations on cluster.", e);
+ }
+
}
+
/**
- * Set configuration of a specific type on the cluster resource.
+ * Creates a ClusterRequest for each service that
+ * includes any associated config types and configuration. The Blueprints
+ * implementation will now create one ClusterRequest per service, in order
+ * to comply with the ServiceConfigVersioning framework in Ambari.
*
- * @param clusterName cluster name
- * @param type configuration type that is to be set
- * @param properties properties to set
+ * This method will also send these requests to the management controller.
*
- * @throws AmbariException if an exception occurs setting the properties
+ * @param clusterName name of cluster
+ * @param listOfBlueprintConfigRequests a list of requests to send to the AmbariManagementController.
+ *
+ * @throws AmbariException upon any error that occurs during updateClusters
*/
- private void setConfigurationsOnCluster(String clusterName, String type,
- Map<String, String> properties,
- Map<String, Map<String, String>> propertiesAttributes) throws AmbariException {
+ private void setConfigurationsOnCluster(String clusterName, List<BlueprintServiceConfigRequest> listOfBlueprintConfigRequests) throws AmbariException {
+ // iterate over services to deploy
+ for (BlueprintServiceConfigRequest blueprintConfigRequest : listOfBlueprintConfigRequests) {
+ ClusterRequest clusterRequest = null;
+ // iterate over the config types associated with this service
+ List<ConfigurationRequest> requestsPerService = new LinkedList<ConfigurationRequest>();
+ for (BlueprintServiceConfigElement blueprintElement : blueprintConfigRequest.getConfigElements()) {
+ Map<String, Object> clusterProperties = new HashMap<String, Object>();
+ clusterProperties.put(CLUSTER_NAME_PROPERTY_ID, clusterName);
+ clusterProperties.put(CLUSTER_DESIRED_CONFIGS_PROPERTY_ID + "/type", blueprintElement.getTypeName());
+ clusterProperties.put(CLUSTER_DESIRED_CONFIGS_PROPERTY_ID + "/tag", "1");
+ for (Map.Entry<String, String> entry : blueprintElement.getConfiguration().entrySet()) {
+ clusterProperties.put(CLUSTER_DESIRED_CONFIGS_PROPERTY_ID +
+ "/properties/" + entry.getKey(), entry.getValue());
+ }
+ if (blueprintElement.getAttributes() != null) {
+ for (Map.Entry<String, Map<String, String>> attribute : blueprintElement.getAttributes().entrySet()) {
+ String attributeName = attribute.getKey();
+ for (Map.Entry<String, String> attributeOccurrence : attribute.getValue().entrySet()) {
+ clusterProperties.put(CLUSTER_DESIRED_CONFIGS_PROPERTY_ID + "/properties_attributes/"
+ + attributeName + "/" + attributeOccurrence.getKey(), attributeOccurrence.getValue());
+ }
+ }
+ }
- Map<String, Object> clusterProperties = new HashMap<String, Object>();
- clusterProperties.put(CLUSTER_NAME_PROPERTY_ID, clusterName);
- clusterProperties.put(CLUSTER_DESIRED_CONFIGS_PROPERTY_ID + "/type", type);
- clusterProperties.put(CLUSTER_DESIRED_CONFIGS_PROPERTY_ID + "/tag", "1");
- for (Map.Entry<String, String> entry : properties.entrySet()) {
- clusterProperties.put(CLUSTER_DESIRED_CONFIGS_PROPERTY_ID +
- "/properties/" + entry.getKey(), entry.getValue());
- }
- if (propertiesAttributes != null) {
- for (Map.Entry<String, Map<String, String>> attribute : propertiesAttributes.entrySet()) {
- String attributeName = attribute.getKey();
- for (Map.Entry<String, String> attributeOccurrence : attribute.getValue().entrySet()) {
- clusterProperties.put(CLUSTER_DESIRED_CONFIGS_PROPERTY_ID + "/properties_attributes/"
- + attributeName + "/" + attributeOccurrence.getKey(), attributeOccurrence.getValue());
+ // only create one cluster request per service, which includes
+ // all the configuration types for that service
+ if (clusterRequest == null) {
+ clusterRequest = new ClusterRequest(
+ (Long) clusterProperties.get(CLUSTER_ID_PROPERTY_ID),
+ (String) clusterProperties.get(CLUSTER_NAME_PROPERTY_ID),
+ (String) clusterProperties.get(CLUSTER_PROVISIONING_STATE_PROPERTY_ID),
+ (String) clusterProperties.get(CLUSTER_VERSION_PROPERTY_ID),
+ null);
}
+
+ List<ConfigurationRequest> listOfRequests =
+ getConfigurationRequests("Clusters", clusterProperties);
+ requestsPerService.addAll(listOfRequests);
+ }
+
+ // set total list of config requests, including all config types
+ // for this service
+ if (clusterRequest != null) {
+ clusterRequest.setDesiredConfig(requestsPerService);
+
+ LOG.info("About to send cluster config update request for service = " + blueprintConfigRequest.getServiceName());
+
+ // send the request update for this service as a whole
+ getManagementController().updateClusters(
+ Collections.singleton(clusterRequest), null);
+ } else {
+ LOG.error("ClusterRequest should not be null for service = " + blueprintConfigRequest.getServiceName());
}
+
}
- getManagementController().updateClusters(
- Collections.singleton(getRequest(clusterProperties)), null);
}
/**
@@ -1136,5 +1216,70 @@ public class ClusterResourceProvider extends BaseBlueprintProcessor {
private boolean includeCluster(String clusterName, boolean readOnly) {
return getManagementController().getClusters().checkPermission(clusterName, readOnly);
}
+
+
+ /**
+ * Internal class meant to represent the collection of configuration
+ * items and configuration attributes that are associated with a given service.
+ *
+ * This class is used to support proper configuration versioning when
+ * Ambari Blueprints is used to deploy a cluster.
+ */
+ private static class BlueprintServiceConfigRequest {
+
+ private final String serviceName;
+
+ private List<BlueprintServiceConfigElement> configElements =
+ new LinkedList<BlueprintServiceConfigElement>();
+
+ BlueprintServiceConfigRequest(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ void addConfigElement(String typeName, Map<String, String> configuration, Map<String, Map<String, String>> attributes) {
+ configElements.add(new BlueprintServiceConfigElement(typeName, configuration, attributes));
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ List<BlueprintServiceConfigElement> getConfigElements() {
+ return configElements;
+ }
+
+ }
+
+ /**
+ * Internal class that represents the configuration
+ * and attributes for a given configuration type.
+ */
+ private static class BlueprintServiceConfigElement {
+ private final String typeName;
+
+ private final Map<String, String> configuration;
+
+ private final Map<String, Map<String, String>> attributes;
+
+ BlueprintServiceConfigElement(String typeName, Map<String, String> configuration, Map<String, Map<String, String>> attributes) {
+ this.typeName = typeName;
+ this.configuration = configuration;
+ this.attributes = attributes;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public Map<String, String> getConfiguration() {
+ return configuration;
+ }
+
+ public Map<String, Map<String, String>> getAttributes() {
+ return attributes;
+ }
+
+ }
+
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b583fa9f/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
index 3ccae43..d6cfbd0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
@@ -99,6 +99,12 @@ class Stack {
private Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations =
new HashMap<String, Map<String, Map<String, ConfigProperty>>>();
+ /**
+ * Map of service to set of excluded config types
+ */
+ private Map<String, Set<String>> excludedConfigurationTypes =
+ new HashMap<String, Set<String>>();
+
/**
* Ambari Management Controller, used to obtain Stack definitions
@@ -155,6 +161,7 @@ class Stack {
for (StackServiceResponse stackService : stackServices) {
String serviceName = stackService.getServiceName();
parseComponents(serviceName);
+ parseExcludedConfigurations(stackService);
parseConfigurations(serviceName);
registerConditionalDependencies();
}
@@ -215,6 +222,18 @@ class Stack {
}
/**
+ * Get the set of excluded configuration types
+ * for this service
+ *
+ * @param service service name
+ *
+ * @return Set of names of excluded config types
+ */
+ public Set<String> getExcludedConfigurationTypes(String service) {
+ return excludedConfigurationTypes.get(service);
+ }
+
+ /**
* Get config properties for the specified service and configuration type.
*
* @param service service name
@@ -393,6 +412,15 @@ class Stack {
}
/**
+ * Obtain the excluded configuration types from the StackServiceResponse
+ *
+ * @param stackServiceResponse the response object associated with this stack service
+ */
+ private void parseExcludedConfigurations(StackServiceResponse stackServiceResponse) {
+ excludedConfigurationTypes.put(stackServiceResponse.getServiceName(), stackServiceResponse.getExcludedConfigTypes());
+ }
+
+ /**
* Parse configurations for the specified service from the stack definition.
*
* @param service service name
http://git-wip-us.apache.org/repos/asf/ambari/blob/b583fa9f/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java
index 3b3ec5f..5438654 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java
@@ -639,6 +639,7 @@ public class BlueprintResourceProviderTest {
expect(stackServiceResponse.getServiceName()).andReturn("test-service").anyTimes();
expect(stackServiceResponse.getStackName()).andReturn("test-stack-name").anyTimes();
expect(stackServiceResponse.getStackVersion()).andReturn("test-stack-version").anyTimes();
+ expect(stackServiceResponse.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet());
expect(managementController.getStackComponents(capture(serviceComponentRequestCapture))).andReturn(setServiceComponents).anyTimes();
expect(stackServiceComponentResponse.getCardinality()).andReturn("2").anyTimes();
@@ -750,6 +751,7 @@ public class BlueprintResourceProviderTest {
expect(stackServiceResponse.getServiceName()).andReturn("test-service").anyTimes();
expect(stackServiceResponse.getStackName()).andReturn("test-stack-name").anyTimes();
expect(stackServiceResponse.getStackVersion()).andReturn("test-stack-version").anyTimes();
+ expect(stackServiceResponse.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet());
expect(managementController.getStackComponents(capture(serviceComponentRequestCapture))).andReturn(setServiceComponents).anyTimes();
expect(stackServiceComponentResponse.getCardinality()).andReturn("2").anyTimes();
@@ -869,6 +871,7 @@ public class BlueprintResourceProviderTest {
expect(stackServiceResponse.getServiceName()).andReturn("test-service").anyTimes();
expect(stackServiceResponse.getStackName()).andReturn("test-stack-name").anyTimes();
expect(stackServiceResponse.getStackVersion()).andReturn("test-stack-version").anyTimes();
+ expect(stackServiceResponse.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet());
expect(managementController.getStackComponents(capture(serviceComponentRequestCapture))).andReturn(setServiceComponents).anyTimes();
expect(stackServiceComponentResponse.getCardinality()).andReturn("2").anyTimes();
@@ -977,6 +980,7 @@ public class BlueprintResourceProviderTest {
expect(stackServiceResponse.getServiceName()).andReturn("test-service").anyTimes();
expect(stackServiceResponse.getStackName()).andReturn("test-stack-name").anyTimes();
expect(stackServiceResponse.getStackVersion()).andReturn("test-stack-version").anyTimes();
+ expect(stackServiceResponse.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet());
expect(managementController.getStackComponents(capture(serviceComponentRequestCapture))).andReturn(setServiceComponents).anyTimes();
expect(stackServiceComponentResponse.getCardinality()).andReturn("2").anyTimes();
http://git-wip-us.apache.org/repos/asf/ambari/blob/b583fa9f/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
index 319d3a9..98bd017 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
@@ -194,6 +194,7 @@ public class ClusterResourceProviderTest {
StackConfigurationResponse stackConfigurationResponse4 = createNiceMock(StackConfigurationResponse.class);
StackConfigurationResponse stackConfigurationResponse5 = createNiceMock(StackConfigurationResponse.class);
StackConfigurationResponse stackConfigurationResponse6 = createNiceMock(StackConfigurationResponse.class);
+ StackConfigurationResponse stackConfigurationResponse7 = createNiceMock(StackConfigurationResponse.class);
Capture<Set<StackConfigurationRequest>> serviceConfigurationRequestCapture1 = new Capture<Set<StackConfigurationRequest>>();
Capture<Set<StackConfigurationRequest>> serviceConfigurationRequestCapture2 = new Capture<Set<StackConfigurationRequest>>();
Capture<Set<StackLevelConfigurationRequest>> serviceLevelConfigurationRequestCapture1 = new Capture<Set<StackLevelConfigurationRequest>>();
@@ -231,16 +232,6 @@ public class ClusterResourceProviderTest {
Capture<Map<String, String>> updateClusterPropertyMapCapture2 = new Capture<Map<String, String>>();
Capture<Set<ClusterRequest>> updateClusterRequestCapture3 = new Capture<Set<ClusterRequest>>();
Capture<Map<String, String>> updateClusterPropertyMapCapture3 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture4 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture4 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture5 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture5 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture6 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture6 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture7 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture7 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture8 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture8 = new Capture<Map<String, String>>();
Capture<Set<ClusterRequest>> persistUIStateRequestCapture = new Capture<Set<ClusterRequest>>();
Capture<Map<String, String>> persistUIStatePropertyMapCapture = new Capture<Map<String, String>>();
@@ -275,6 +266,7 @@ public class ClusterResourceProviderTest {
stackConfigurationResponses2.add(stackConfigurationResponse2);
stackConfigurationResponses2.add(stackConfigurationResponse3);
stackConfigurationResponses2.add(stackConfigurationResponse4);
+ stackConfigurationResponses2.add(stackConfigurationResponse7);
Set<StackConfigurationResponse> stackConfigurationResponses3 = new LinkedHashSet<StackConfigurationResponse>();
stackConfigurationResponses3.add(stackConfigurationResponse6);
@@ -401,6 +393,11 @@ public class ClusterResourceProviderTest {
expect(stackConfigurationResponse6.getPropertyName()).andReturn("rqw").anyTimes();
expect(stackConfigurationResponse6.getPropertyValue()).andReturn("aaaa").anyTimes();
+ expect(stackConfigurationResponse7.getType()).andReturn("hive-env.xml").anyTimes();
+ expect(stackConfigurationResponse7.getPropertyName()).andReturn("test-property-one");
+ expect(stackConfigurationResponse7.getPropertyValue()).andReturn("test-value-one");
+
+
expect(blueprintConfig.getBlueprintName()).andReturn("test-blueprint").anyTimes();
expect(blueprintConfig.getType()).andReturn("core-site").anyTimes();
expect(blueprintConfig.getConfigData()).andReturn(new Gson().toJson(blueprintCoreConfigProperties)).anyTimes();
@@ -441,16 +438,6 @@ public class ClusterResourceProviderTest {
capture(updateClusterPropertyMapCapture2))).andReturn(null);
expect(managementController.updateClusters(capture(updateClusterRequestCapture3),
capture(updateClusterPropertyMapCapture3))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture4),
- capture(updateClusterPropertyMapCapture4))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture5),
- capture(updateClusterPropertyMapCapture5))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture6),
- capture(updateClusterPropertyMapCapture6))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture7),
- capture(updateClusterPropertyMapCapture7))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture8),
- capture(updateClusterPropertyMapCapture8))).andReturn(null);
// set state for UI
expect(managementController.updateClusters(capture(persistUIStateRequestCapture),
@@ -470,7 +457,8 @@ public class ClusterResourceProviderTest {
replay(blueprintDAO, managementController, request, response, blueprint, stackServiceResponse1, stackServiceResponse2,
stackServiceComponentResponse1, stackServiceComponentResponse2, stackServiceComponentResponse3,
stackServiceComponentResponse4, stackConfigurationResponse1, stackConfigurationResponse2,
- stackConfigurationResponse3, stackConfigurationResponse4, stackConfigurationResponse5, stackConfigurationResponse6, blueprintConfig,
+ stackConfigurationResponse3, stackConfigurationResponse4, stackConfigurationResponse5, stackConfigurationResponse6,
+ stackConfigurationResponse7, blueprintConfig,
blueprintConfig2, blueprintConfig3, blueprintConfig4, blueprintConfig5, blueprintConfig6, hostGroup, hostGroupComponent1, hostGroupComponent2, hostGroupComponent3, hostGroupComponent4,
hostGroupConfig, serviceResourceProvider, componentResourceProvider, hostResourceProvider,
hostComponentResourceProvider, configGroupResourceProvider, metaInfo);
@@ -536,65 +524,49 @@ public class ClusterResourceProviderTest {
Set<ClusterRequest> updateClusterRequest1 = updateClusterRequestCapture.getValue();
Set<ClusterRequest> updateClusterRequest2 = updateClusterRequestCapture2.getValue();
Set<ClusterRequest> updateClusterRequest3 = updateClusterRequestCapture3.getValue();
- Set<ClusterRequest> updateClusterRequest4 = updateClusterRequestCapture4.getValue();
- Set<ClusterRequest> updateClusterRequest5 = updateClusterRequestCapture5.getValue();
- Set<ClusterRequest> updateClusterRequest6 = updateClusterRequestCapture6.getValue();
- Set<ClusterRequest> updateClusterRequest7 = updateClusterRequestCapture7.getValue();
- Set<ClusterRequest> updateClusterRequest8 = updateClusterRequestCapture8.getValue();
- Set<ClusterRequest> persistUIStateRequest = persistUIStateRequestCapture.getValue();
+ Set<ClusterRequest> updateClusterRequest4 = persistUIStateRequestCapture.getValue();
+
+
+
assertEquals(1, updateClusterRequest1.size());
assertEquals(1, updateClusterRequest2.size());
assertEquals(1, updateClusterRequest3.size());
assertEquals(1, updateClusterRequest4.size());
- assertEquals(1, updateClusterRequest5.size());
- assertEquals(1, updateClusterRequest6.size());
- assertEquals(1, updateClusterRequest7.size());
- assertEquals(1, updateClusterRequest8.size());
- assertEquals(1, persistUIStateRequest.size());
+
ClusterRequest ucr1 = updateClusterRequest1.iterator().next();
ClusterRequest ucr2 = updateClusterRequest2.iterator().next();
ClusterRequest ucr3 = updateClusterRequest3.iterator().next();
ClusterRequest ucr4 = updateClusterRequest4.iterator().next();
- ClusterRequest ucr5 = updateClusterRequest5.iterator().next();
- ClusterRequest ucr6 = updateClusterRequest6.iterator().next();
- ClusterRequest ucr7 = updateClusterRequest7.iterator().next();
- ClusterRequest ucr8 = updateClusterRequest8.iterator().next();
- ClusterRequest ucr9 = persistUIStateRequest.iterator().next();
+
assertEquals(clusterName, ucr1.getClusterName());
assertEquals(clusterName, ucr2.getClusterName());
assertEquals(clusterName, ucr3.getClusterName());
assertEquals(clusterName, ucr4.getClusterName());
- assertEquals(clusterName, ucr5.getClusterName());
- assertEquals(clusterName, ucr6.getClusterName());
- assertEquals(clusterName, ucr7.getClusterName());
- assertEquals(clusterName, ucr8.getClusterName());
- assertEquals(clusterName, ucr9.getClusterName());
- assertEquals("INSTALLED", ucr9.getProvisioningState());
+
+ assertEquals("INSTALLED", ucr4.getProvisioningState());
ConfigurationRequest cr1 = ucr1.getDesiredConfig().get(0);
ConfigurationRequest cr2 = ucr2.getDesiredConfig().get(0);
ConfigurationRequest cr3 = ucr3.getDesiredConfig().get(0);
- ConfigurationRequest cr4 = ucr4.getDesiredConfig().get(0);
- ConfigurationRequest cr5 = ucr5.getDesiredConfig().get(0);
- ConfigurationRequest cr6 = ucr6.getDesiredConfig().get(0);
- ConfigurationRequest cr7 = ucr7.getDesiredConfig().get(0);
- ConfigurationRequest cr8 = ucr8.getDesiredConfig().get(0);
+
assertEquals("1", cr1.getVersionTag());
assertEquals("1", cr2.getVersionTag());
assertEquals("1", cr3.getVersionTag());
- assertEquals("1", cr4.getVersionTag());
- assertEquals("1", cr5.getVersionTag());
- assertEquals("1", cr6.getVersionTag());
- assertEquals("1", cr7.getVersionTag());
+
Map<String, ConfigurationRequest> mapConfigRequests = new HashMap<String, ConfigurationRequest>();
- mapConfigRequests.put(cr1.getType(), cr1);
- mapConfigRequests.put(cr2.getType(), cr2);
- mapConfigRequests.put(cr3.getType(), cr3);
- mapConfigRequests.put(cr4.getType(), cr4);
- mapConfigRequests.put(cr5.getType(), cr5);
- mapConfigRequests.put(cr6.getType(), cr6);
- mapConfigRequests.put(cr7.getType(), cr7);
- mapConfigRequests.put(cr8.getType(), cr8);
- assertEquals(8, mapConfigRequests.size());
+
+ ClusterRequest[] arrayOfClusterRequests = { ucr1, ucr2, ucr3 };
+
+ // add all the associated config types to the test map
+ // with the config versioning change, there could be
+ // more than one config type associated with a ClusterRequest
+ for (ClusterRequest testClusterRequest : arrayOfClusterRequests) {
+ for (ConfigurationRequest configRequest : testClusterRequest.getDesiredConfig()) {
+ mapConfigRequests.put(configRequest.getType(), configRequest);
+ }
+ }
+
+
+ assertEquals(6, mapConfigRequests.size());
ConfigurationRequest hiveEnvConfigRequest = mapConfigRequests.get("hive-env");
assertEquals("New MySQL Database", hiveEnvConfigRequest.getProperties().get("hive_database"));
ConfigurationRequest hdfsConfigRequest = mapConfigRequests.get("hdfs-site");
@@ -622,7 +594,7 @@ public class ClusterResourceProviderTest {
assertNull(updateClusterPropertyMapCapture.getValue());
assertNull(updateClusterPropertyMapCapture2.getValue());
assertNull(updateClusterPropertyMapCapture3.getValue());
- assertNull(updateClusterPropertyMapCapture4.getValue());
+ //assertNull(updateClusterPropertyMapCapture4.getValue());
Request serviceRequest = serviceRequestCapture.getValue();
assertEquals(2, serviceRequest.getProperties().size());
@@ -674,7 +646,8 @@ public class ClusterResourceProviderTest {
verify(blueprintDAO, managementController, request, response, blueprint, stackServiceResponse1, stackServiceResponse2,
stackServiceComponentResponse1, stackServiceComponentResponse2, stackServiceComponentResponse3,
stackServiceComponentResponse4, stackConfigurationResponse1, stackConfigurationResponse2,
- stackConfigurationResponse3, stackConfigurationResponse4, stackConfigurationResponse5, stackConfigurationResponse6, blueprintConfig,
+ stackConfigurationResponse3, stackConfigurationResponse4, stackConfigurationResponse5, stackConfigurationResponse6,
+ stackConfigurationResponse7, blueprintConfig,
blueprintConfig2, hostGroup, hostGroupComponent1, hostGroupComponent2, hostGroupComponent3, hostGroupComponent4,
hostGroupConfig, serviceResourceProvider, componentResourceProvider, hostResourceProvider,
hostComponentResourceProvider, configGroupResourceProvider, metaInfo);
@@ -1560,14 +1533,7 @@ public class ClusterResourceProviderTest {
Capture<Map<String, String>> updateClusterPropertyMapCapture2 = new Capture<Map<String, String>>();
Capture<Set<ClusterRequest>> updateClusterRequestCapture3 = new Capture<Set<ClusterRequest>>();
Capture<Map<String, String>> updateClusterPropertyMapCapture3 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture4 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture4 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture5 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture5 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture6 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture6 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture7 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture7 = new Capture<Map<String, String>>();
+
Capture<Set<ClusterRequest>> persistUIStateRequestCapture = new Capture<Set<ClusterRequest>>();
Capture<Map<String, String>> persistUIStatePropertyMapCapture = new Capture<Map<String, String>>();
@@ -1734,20 +1700,14 @@ public class ClusterResourceProviderTest {
expect(hostGroupConfig.getConfigData()).andReturn(new Gson().toJson(mapGroupConfigProperties)).anyTimes();
managementController.createCluster(capture(createClusterRequestCapture));
+ // expect three ClusterRequests to be generated for configuration
expect(managementController.updateClusters(capture(updateClusterRequestCapture),
capture(updateClusterPropertyMapCapture))).andReturn(null);
expect(managementController.updateClusters(capture(updateClusterRequestCapture2),
capture(updateClusterPropertyMapCapture2))).andReturn(null);
expect(managementController.updateClusters(capture(updateClusterRequestCapture3),
capture(updateClusterPropertyMapCapture3))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture4),
- capture(updateClusterPropertyMapCapture4))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture5),
- capture(updateClusterPropertyMapCapture5))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture6),
- capture(updateClusterPropertyMapCapture6))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture7),
- capture(updateClusterPropertyMapCapture7))).andReturn(null);
+
// set state for UI
expect(managementController.updateClusters(capture(persistUIStateRequestCapture),
@@ -1834,61 +1794,43 @@ public class ClusterResourceProviderTest {
Set<ClusterRequest> updateClusterRequest1 = updateClusterRequestCapture.getValue();
Set<ClusterRequest> updateClusterRequest2 = updateClusterRequestCapture2.getValue();
Set<ClusterRequest> updateClusterRequest3 = updateClusterRequestCapture3.getValue();
- Set<ClusterRequest> updateClusterRequest4 = updateClusterRequestCapture4.getValue();
- Set<ClusterRequest> updateClusterRequest5 = updateClusterRequestCapture5.getValue();
- Set<ClusterRequest> updateClusterRequest6 = updateClusterRequestCapture6.getValue();
- Set<ClusterRequest> updateClusterRequest7 = updateClusterRequestCapture7.getValue();
Set<ClusterRequest> persistUIStateRequest = persistUIStateRequestCapture.getValue();
assertEquals(1, updateClusterRequest1.size());
assertEquals(1, updateClusterRequest2.size());
assertEquals(1, updateClusterRequest3.size());
- assertEquals(1, updateClusterRequest4.size());
- assertEquals(1, updateClusterRequest5.size());
- assertEquals(1, updateClusterRequest6.size());
- assertEquals(1, updateClusterRequest7.size());
assertEquals(1, persistUIStateRequest.size());
ClusterRequest ucr1 = updateClusterRequest1.iterator().next();
ClusterRequest ucr2 = updateClusterRequest2.iterator().next();
ClusterRequest ucr3 = updateClusterRequest3.iterator().next();
- ClusterRequest ucr4 = updateClusterRequest4.iterator().next();
- ClusterRequest ucr5 = updateClusterRequest5.iterator().next();
- ClusterRequest ucr6 = updateClusterRequest6.iterator().next();
- ClusterRequest ucr7 = updateClusterRequest7.iterator().next();
- ClusterRequest ucr8 = persistUIStateRequest.iterator().next();
+ ClusterRequest ucr4 = persistUIStateRequest.iterator().next();
assertEquals(clusterName, ucr1.getClusterName());
assertEquals(clusterName, ucr2.getClusterName());
assertEquals(clusterName, ucr3.getClusterName());
- assertEquals(clusterName, ucr4.getClusterName());
- assertEquals(clusterName, ucr5.getClusterName());
- assertEquals(clusterName, ucr6.getClusterName());
- assertEquals(clusterName, ucr7.getClusterName());
- assertEquals(clusterName, ucr8.getClusterName());
- assertEquals("INSTALLED", ucr8.getProvisioningState());
- ConfigurationRequest cr1 = ucr1.getDesiredConfig().get(0);
- ConfigurationRequest cr2 = ucr2.getDesiredConfig().get(0);
- ConfigurationRequest cr3 = ucr3.getDesiredConfig().get(0);
- ConfigurationRequest cr4 = ucr4.getDesiredConfig().get(0);
- ConfigurationRequest cr5 = ucr5.getDesiredConfig().get(0);
- ConfigurationRequest cr6 = ucr6.getDesiredConfig().get(0);
- ConfigurationRequest cr7 = ucr7.getDesiredConfig().get(0);
- assertEquals("1", cr1.getVersionTag());
- assertEquals("1", cr2.getVersionTag());
- assertEquals("1", cr3.getVersionTag());
- assertEquals("1", cr4.getVersionTag());
- assertEquals("1", cr5.getVersionTag());
- assertEquals("1", cr6.getVersionTag());
- assertEquals("1", cr7.getVersionTag());
+ assertEquals("INSTALLED", ucr4.getProvisioningState());
+
+ ClusterRequest[] arrayOfClusterRequests =
+ { ucr1, ucr2, ucr3 };
+
+ // assert that all ConfigRequests instances have version of "1"
+ for (ClusterRequest testRequest : arrayOfClusterRequests) {
+ for (ConfigurationRequest testConfigRequest : testRequest.getDesiredConfig()) {
+ assertEquals("1", testConfigRequest.getVersionTag());
+ }
+ }
Map<String, ConfigurationRequest> mapConfigRequests = new HashMap<String, ConfigurationRequest>();
- mapConfigRequests.put(cr1.getType(), cr1);
- mapConfigRequests.put(cr2.getType(), cr2);
- mapConfigRequests.put(cr3.getType(), cr3);
- mapConfigRequests.put(cr4.getType(), cr4);
- mapConfigRequests.put(cr5.getType(), cr5);
- mapConfigRequests.put(cr6.getType(), cr6);
- mapConfigRequests.put(cr7.getType(), cr7);
+
+ // add all the associated config types to the test map
+ // with the config versioning change, there could be
+ // more than one config type associated with a ClusterRequest
+ for (ClusterRequest testClusterRequest : arrayOfClusterRequests) {
+ for (ConfigurationRequest configRequest : testClusterRequest.getDesiredConfig()) {
+ mapConfigRequests.put(configRequest.getType(), configRequest);
+ }
+ }
+
assertEquals(7, mapConfigRequests.size());
ConfigurationRequest hdfsConfigRequest = mapConfigRequests.get("hdfs-site");
@@ -2268,16 +2210,6 @@ public class ClusterResourceProviderTest {
Capture<Map<String, String>> updateClusterPropertyMapCapture2 = new Capture<Map<String, String>>();
Capture<Set<ClusterRequest>> updateClusterRequestCapture3 = new Capture<Set<ClusterRequest>>();
Capture<Map<String, String>> updateClusterPropertyMapCapture3 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture4 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture4 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture5 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture5 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture6 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture6 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture7 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture7 = new Capture<Map<String, String>>();
- Capture<Set<ClusterRequest>> updateClusterRequestCapture8 = new Capture<Set<ClusterRequest>>();
- Capture<Map<String, String>> updateClusterPropertyMapCapture8 = new Capture<Map<String, String>>();
Capture<Set<ClusterRequest>> persistUIStateRequestCapture = new Capture<Set<ClusterRequest>>();
Capture<Map<String, String>> persistUIStatePropertyMapCapture = new Capture<Map<String, String>>();
@@ -2479,16 +2411,6 @@ public class ClusterResourceProviderTest {
capture(updateClusterPropertyMapCapture2))).andReturn(null);
expect(managementController.updateClusters(capture(updateClusterRequestCapture3),
capture(updateClusterPropertyMapCapture3))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture4),
- capture(updateClusterPropertyMapCapture4))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture5),
- capture(updateClusterPropertyMapCapture5))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture6),
- capture(updateClusterPropertyMapCapture6))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture7),
- capture(updateClusterPropertyMapCapture7))).andReturn(null);
- expect(managementController.updateClusters(capture(updateClusterRequestCapture8),
- capture(updateClusterPropertyMapCapture8))).andReturn(null);
// set state for UI
expect(managementController.updateClusters(capture(persistUIStateRequestCapture),
@@ -2577,65 +2499,46 @@ public class ClusterResourceProviderTest {
Set<ClusterRequest> updateClusterRequest1 = updateClusterRequestCapture.getValue();
Set<ClusterRequest> updateClusterRequest2 = updateClusterRequestCapture2.getValue();
Set<ClusterRequest> updateClusterRequest3 = updateClusterRequestCapture3.getValue();
- Set<ClusterRequest> updateClusterRequest4 = updateClusterRequestCapture4.getValue();
- Set<ClusterRequest> updateClusterRequest5 = updateClusterRequestCapture5.getValue();
- Set<ClusterRequest> updateClusterRequest6 = updateClusterRequestCapture6.getValue();
- Set<ClusterRequest> updateClusterRequest7 = updateClusterRequestCapture7.getValue();
- Set<ClusterRequest> updateClusterRequest8 = updateClusterRequestCapture8.getValue();
Set<ClusterRequest> persistUIStateRequest = persistUIStateRequestCapture.getValue();
+
assertEquals(1, updateClusterRequest1.size());
assertEquals(1, updateClusterRequest2.size());
assertEquals(1, updateClusterRequest3.size());
- assertEquals(1, updateClusterRequest4.size());
- assertEquals(1, updateClusterRequest5.size());
- assertEquals(1, updateClusterRequest6.size());
- assertEquals(1, updateClusterRequest7.size());
- assertEquals(1, updateClusterRequest8.size());
+
assertEquals(1, persistUIStateRequest.size());
+
ClusterRequest ucr1 = updateClusterRequest1.iterator().next();
ClusterRequest ucr2 = updateClusterRequest2.iterator().next();
ClusterRequest ucr3 = updateClusterRequest3.iterator().next();
- ClusterRequest ucr4 = updateClusterRequest4.iterator().next();
- ClusterRequest ucr5 = updateClusterRequest5.iterator().next();
- ClusterRequest ucr6 = updateClusterRequest6.iterator().next();
- ClusterRequest ucr7 = updateClusterRequest7.iterator().next();
- ClusterRequest ucr8 = updateClusterRequest8.iterator().next();
+
ClusterRequest ucr9 = persistUIStateRequest.iterator().next();
assertEquals(clusterName, ucr1.getClusterName());
assertEquals(clusterName, ucr2.getClusterName());
assertEquals(clusterName, ucr3.getClusterName());
- assertEquals(clusterName, ucr4.getClusterName());
- assertEquals(clusterName, ucr5.getClusterName());
- assertEquals(clusterName, ucr6.getClusterName());
- assertEquals(clusterName, ucr7.getClusterName());
- assertEquals(clusterName, ucr8.getClusterName());
assertEquals("INSTALLED", ucr9.getProvisioningState());
assertEquals(clusterName, ucr9.getClusterName());
- ConfigurationRequest cr1 = ucr1.getDesiredConfig().get(0);
- ConfigurationRequest cr2 = ucr2.getDesiredConfig().get(0);
- ConfigurationRequest cr3 = ucr3.getDesiredConfig().get(0);
- ConfigurationRequest cr4 = ucr4.getDesiredConfig().get(0);
- ConfigurationRequest cr5 = ucr5.getDesiredConfig().get(0);
- ConfigurationRequest cr6 = ucr6.getDesiredConfig().get(0);
- ConfigurationRequest cr7 = ucr7.getDesiredConfig().get(0);
- ConfigurationRequest cr8 = ucr8.getDesiredConfig().get(0);
- assertEquals("1", cr1.getVersionTag());
- assertEquals("1", cr2.getVersionTag());
- assertEquals("1", cr3.getVersionTag());
- assertEquals("1", cr4.getVersionTag());
- assertEquals("1", cr5.getVersionTag());
- assertEquals("1", cr6.getVersionTag());
- assertEquals("1", cr7.getVersionTag());
- assertEquals("1", cr8.getVersionTag());
+
+ ClusterRequest[] arrayOfClusterRequests =
+ { ucr1, ucr2, ucr3 };
+
+ // assert that all ConfigRequests instances have version of "1"
+ for (ClusterRequest testRequest : arrayOfClusterRequests) {
+ for (ConfigurationRequest testConfigRequest : testRequest.getDesiredConfig()) {
+ assertEquals("1", testConfigRequest.getVersionTag());
+ }
+ }
+
Map<String, ConfigurationRequest> mapConfigRequests = new HashMap<String, ConfigurationRequest>();
- mapConfigRequests.put(cr1.getType(), cr1);
- mapConfigRequests.put(cr2.getType(), cr2);
- mapConfigRequests.put(cr3.getType(), cr3);
- mapConfigRequests.put(cr4.getType(), cr4);
- mapConfigRequests.put(cr5.getType(), cr5);
- mapConfigRequests.put(cr6.getType(), cr6);
- mapConfigRequests.put(cr7.getType(), cr7);
- mapConfigRequests.put(cr8.getType(), cr8);
+ // add all the associated config types to the test map
+ // with the config versioning change, there could be
+ // more than one config type associated with a ClusterRequest
+ for (ClusterRequest testClusterRequest : arrayOfClusterRequests) {
+ for (ConfigurationRequest configRequest : testClusterRequest.getDesiredConfig()) {
+ mapConfigRequests.put(configRequest.getType(), configRequest);
+ }
+ }
+
+
assertEquals(8, mapConfigRequests.size());
ConfigurationRequest hiveEnvConfigRequest = mapConfigRequests.get("hive-env");
assertEquals("New MySQL Database", hiveEnvConfigRequest.getProperties().get("hive_database"));
@@ -2673,7 +2576,7 @@ public class ClusterResourceProviderTest {
assertNull(updateClusterPropertyMapCapture.getValue());
assertNull(updateClusterPropertyMapCapture2.getValue());
assertNull(updateClusterPropertyMapCapture3.getValue());
- assertNull(updateClusterPropertyMapCapture5.getValue());
+ assertNull(persistUIStatePropertyMapCapture.getValue());
Request serviceRequest = serviceRequestCapture.getValue();
assertEquals(2, serviceRequest.getProperties().size());
@@ -3052,12 +2955,13 @@ public class ClusterResourceProviderTest {
AmbariMetaInfo mockAmbariMetaInfo =
mockSupport.createMock(AmbariMetaInfo.class);
- expect(mockStackComponentResponse.getComponentName()).andReturn("OOZIE_SERVER");
+ expect(mockStackComponentResponse.getComponentName()).andReturn("OOZIE_SERVER").atLeastOnce();
expect(mockStackComponentResponse.getCardinality()).andReturn("1");
expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
- expect(mockStackServiceResponseOne.getServiceName()).andReturn("OOZIE");
+ expect(mockStackServiceResponseOne.getServiceName()).andReturn("OOZIE").atLeastOnce();
+ expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
@@ -3135,12 +3039,13 @@ public class ClusterResourceProviderTest {
AmbariMetaInfo mockAmbariMetaInfo =
mockSupport.createMock(AmbariMetaInfo.class);
- expect(mockStackComponentResponse.getComponentName()).andReturn("FALCON_SERVER");
+ expect(mockStackComponentResponse.getComponentName()).andReturn("FALCON_SERVER").atLeastOnce();
expect(mockStackComponentResponse.getCardinality()).andReturn("1");
expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
- expect(mockStackServiceResponseOne.getServiceName()).andReturn("FALCON");
+ expect(mockStackServiceResponseOne.getServiceName()).andReturn("FALCON").atLeastOnce();
+ expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
@@ -3221,7 +3126,8 @@ public class ClusterResourceProviderTest {
expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
- expect(mockStackServiceResponseOne.getServiceName()).andReturn("OOZIE");
+ expect(mockStackServiceResponseOne.getServiceName()).andReturn("OOZIE").atLeastOnce();
+ expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
@@ -3298,7 +3204,9 @@ public class ClusterResourceProviderTest {
expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
- expect(mockStackServiceResponseOne.getServiceName()).andReturn("FALCON");
+ expect(mockStackServiceResponseOne.getServiceName()).andReturn("FALCON").atLeastOnce();
+ expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
+
expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
@@ -3374,7 +3282,8 @@ public class ClusterResourceProviderTest {
expect(mockStackComponentResponse.getCardinality()).andReturn("1");
expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
- expect(mockStackServiceResponseOne.getServiceName()).andReturn("HIVE");
+ expect(mockStackServiceResponseOne.getServiceName()).andReturn("HIVE").atLeastOnce();
+ expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());
@@ -3450,7 +3359,9 @@ public class ClusterResourceProviderTest {
expect(mockStackComponentResponse.getCardinality()).andReturn("1");
expect(mockStackComponentResponse.getAutoDeploy()).andReturn(new AutoDeployInfo());
- expect(mockStackServiceResponseOne.getServiceName()).andReturn("HBASE");
+ expect(mockStackServiceResponseOne.getServiceName()).andReturn("HBASE").atLeastOnce();
+ expect(mockStackServiceResponseOne.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet()).atLeastOnce();
+
expect(mockManagementController.getStackServices(isA(Set.class))).andReturn(Collections.singleton(mockStackServiceResponseOne));
expect(mockManagementController.getStackComponents(isA(Set.class))).andReturn(Collections.singleton(mockStackComponentResponse));
expect(mockManagementController.getStackConfigurations(isA(Set.class))).andReturn(Collections.<StackConfigurationResponse>emptySet());