Repository: ambari Updated Branches: refs/heads/trunk aeb11c93f -> 80e247731
AMBARI-11266. Blueprint API: Move 'host_count' and 'host_predicate' up one level Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/80e24773 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/80e24773 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/80e24773 Branch: refs/heads/trunk Commit: 80e2477317b2f11b3635872014604a258044288c Parents: aeb11c9 Author: John Speidel <jspei...@hortonworks.com> Authored: Wed May 20 09:57:42 2015 -0400 Committer: John Speidel <jspei...@hortonworks.com> Committed: Wed May 20 16:44:25 2015 -0400 ---------------------------------------------------------------------- .../internal/ExportBlueprintRequest.java | 2 +- .../internal/ProvisionClusterRequest.java | 191 +++++++++++++------ .../internal/ScaleClusterRequest.java | 2 +- .../ambari/server/topology/LogicalRequest.java | 4 +- .../server/topology/PersistedStateImpl.java | 4 +- .../ambari/server/topology/TopologyRequest.java | 53 ++++- .../internal/ProvisionClusterRequestTest.java | 40 ++-- .../internal/ScaleClusterRequestTest.java | 12 +- .../topology/ClusterTopologyImplTest.java | 2 +- .../server/topology/TopologyManagerTest.java | 2 +- 10 files changed, 209 insertions(+), 103 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/80e24773/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java index 1e71094..8b13826 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java @@ -111,7 +111,7 @@ public class ExportBlueprintRequest implements TopologyRequest { } @Override - public String getCommandDescription() { + public String getDescription() { return String.format("Export Command For Cluster '%s'", clusterName); } http://git-wip-us.apache.org/repos/asf/ambari/blob/80e24773/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java index 1a4520e..5dd25fd 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java @@ -15,9 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -//todo: in which package does this belong? For now it is co-located with resource providers because -//todo: it needs to understand the syntax of the associated resource provider request package org.apache.ambari.server.controller.internal; import org.apache.ambari.server.api.predicate.InvalidQueryException; @@ -38,7 +35,47 @@ import java.util.Map; /** * Request for provisioning a cluster. */ +@SuppressWarnings("unchecked") public class ProvisionClusterRequest extends BaseClusterRequest { + /** + * host groups property name + */ + public static final String HOSTGROUPS_PROPERTY = "host_groups"; + + /** + * host group name property name + */ + public static final String HOSTGROUP_NAME_PROPERTY = "name"; + + /** + * host group host count property name + */ + public static final String HOSTGROUP_HOST_COUNT_PROPERTY = "host_count"; + + /** + * host group host predicate property name + */ + public static final String HOSTGROUP_HOST_PREDICATE_PROPERTY = "host_predicate"; + + /** + * host group host fqdn property name + */ + public static final String HOSTGROUP_HOST_FQDN_PROPERTY = "fqdn"; + + /** + * host group hosts property name + */ + public static final String HOSTGROUP_HOSTS_PROPERTY = "hosts"; + + /** + * configurations property name + */ + public static final String CONFIGURATIONS_PROPERTY = "configurations"; + + /** + * default password property name + */ + public static final String DEFAULT_PASSWORD_PROPERTY = "default_password"; /** * configuration factory @@ -50,7 +87,6 @@ public class ProvisionClusterRequest extends BaseClusterRequest { */ private String defaultPassword; - @SuppressWarnings("unchecked") /** * Constructor. * @@ -60,9 +96,8 @@ public class ProvisionClusterRequest extends BaseClusterRequest { setClusterName(String.valueOf(properties.get( ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID))); - //todo: constant - if (properties.containsKey("default_password")) { - defaultPassword = String.valueOf(properties.get("default_password")); + if (properties.containsKey(DEFAULT_PASSWORD_PROPERTY)) { + defaultPassword = String.valueOf(properties.get(DEFAULT_PASSWORD_PROPERTY)); } try { @@ -74,7 +109,7 @@ public class ProvisionClusterRequest extends BaseClusterRequest { } Configuration configuration = configurationFactory.getConfiguration( - (Collection<Map<String, String>>) properties.get("configurations")); + (Collection<Map<String, String>>) properties.get(CONFIGURATIONS_PROPERTY)); configuration.setParentConfiguration(blueprint.getConfiguration()); setConfiguration(configuration); @@ -92,7 +127,7 @@ public class ProvisionClusterRequest extends BaseClusterRequest { } @Override - public String getCommandDescription() { + public String getDescription() { return String.format("Provision Cluster '%s'", clusterName); } @@ -118,73 +153,115 @@ public class ProvisionClusterRequest extends BaseClusterRequest { * Parse host group information. * * @param properties request properties + * * @throws InvalidTopologyTemplateException if any validation checks on properties fail */ - @SuppressWarnings("unchecked") private void parseHostGroupInfo(Map<String, Object> properties) throws InvalidTopologyTemplateException { Collection<Map<String, Object>> hostGroups = - (Collection<Map<String, Object>>) properties.get("host_groups"); + (Collection<Map<String, Object>>) properties.get(HOSTGROUPS_PROPERTY); if (hostGroups == null || hostGroups.isEmpty()) { throw new InvalidTopologyTemplateException("'host_groups' element must be included in cluster create body"); } - // iterate over host groups provided in request body for (Map<String, Object> hostGroupProperties : hostGroups) { - String name = String.valueOf(hostGroupProperties.get("name")); - // String.valueOf() converts null to "null" - if (name.equals("null") || name.isEmpty()) { - throw new InvalidTopologyTemplateException("All host groups must contain a 'name' element"); - } + processHostGroup(hostGroupProperties); + } + } - Collection hosts = (Collection) hostGroupProperties.get("hosts"); - if (hosts == null || hosts.isEmpty()) { - throw new InvalidTopologyTemplateException("Host group '" + name + "' must contain a 'hosts' element"); + /** + * Process host group properties. + * + * @param hostGroupProperties host group properties + * + * @throws InvalidTopologyTemplateException if any validation checks on properties fail + */ + private void processHostGroup(Map<String, Object> hostGroupProperties) throws InvalidTopologyTemplateException { + String name = String.valueOf(hostGroupProperties.get(HOSTGROUP_NAME_PROPERTY)); + // String.valueOf() converts null to "null" + if (name == null || name.equals("null") || name.isEmpty()) { + throw new InvalidTopologyTemplateException("All host groups must contain a 'name' element"); + } + + HostGroupInfo hostGroupInfo = new HostGroupInfo(name); + getHostGroupInfo().put(name, hostGroupInfo); + + processHostCountAndPredicate(hostGroupProperties, hostGroupInfo); + processGroupHosts(name, (Collection<Map<String, String>>) + hostGroupProperties.get(HOSTGROUP_HOSTS_PROPERTY), hostGroupInfo); + + // don't set the parent configuration + hostGroupInfo.setConfiguration(configurationFactory.getConfiguration( + (Collection<Map<String, String>>) hostGroupProperties.get(CONFIGURATIONS_PROPERTY))); + } + + /** + * Process host count and host predicate for a host group. + * + * @param hostGroupProperties host group properties + * @param hostGroupInfo associated host group info instance + * + * @throws InvalidTopologyTemplateException specified host group properties fail validation + */ + private void processHostCountAndPredicate(Map<String, Object> hostGroupProperties, HostGroupInfo hostGroupInfo) + throws InvalidTopologyTemplateException { + + if (hostGroupProperties.containsKey(HOSTGROUP_HOST_COUNT_PROPERTY)) { + hostGroupInfo.setRequestedCount(Integer.valueOf(String.valueOf( + hostGroupProperties.get(HOSTGROUP_HOST_COUNT_PROPERTY)))); + } + + if (hostGroupProperties.containsKey(HOSTGROUP_HOST_PREDICATE_PROPERTY)) { + if (hostGroupInfo.getRequestedHostCount() == 0) { + throw new InvalidTopologyTemplateException(String.format( + "Host group '%s' must not specify 'host_predicate' without 'host_count'", + hostGroupInfo.getHostGroupName())); } - HostGroupInfo hostGroupInfo = new HostGroupInfo(name); - getHostGroupInfo().put(name, hostGroupInfo); + String hostPredicate = String.valueOf(hostGroupProperties.get(HOSTGROUP_HOST_PREDICATE_PROPERTY)); + validateHostPredicateProperties(hostPredicate); + try { + hostGroupInfo.setPredicate(hostPredicate); + } catch (InvalidQueryException e) { + throw new InvalidTopologyTemplateException( + String.format("Unable to compile host predicate '%s': %s", hostPredicate, e), e); + } + } + } - for (Object oHost : hosts) { - Map<String, String> hostProperties = (Map<String, String>) oHost; + /** + * Process host group hosts. + * + * @param name host group name + * @param hosts collection of host group host properties + * @param hostGroupInfo associated host group info instance + * + * @throws InvalidTopologyTemplateException specified host group properties fail validation + */ + private void processGroupHosts(String name, Collection<Map<String, String>> hosts, HostGroupInfo hostGroupInfo) + throws InvalidTopologyTemplateException { - String hostName = hostProperties.get("fqdn"); - boolean containsHostCount = hostProperties.containsKey("host_count"); - boolean containsHostPredicate = hostProperties.containsKey("host_predicate"); + if (hosts != null) { + if (hostGroupInfo.getRequestedHostCount() != 0) { + throw new InvalidTopologyTemplateException(String.format( + "Host group '%s' must not contain both a 'hosts' element and a 'host_count' value", name)); + } - if (hostName != null && (containsHostCount || containsHostPredicate)) { - throw new InvalidTopologyTemplateException( - "Can't specify host_count or host_predicate if host_name is specified in hostgroup: " + name); - } + if (hostGroupInfo.getPredicate() != null) { + throw new InvalidTopologyTemplateException(String.format( + "Host group '%s' must not contain both a 'hosts' element and a 'host_predicate' value", name)); + } - //add host information to host group - if (hostName == null || hostName.isEmpty()) { - //todo: validate the host_name and host_predicate are not both specified for same group - String predicate = hostProperties.get("host_predicate"); - if (predicate != null && ! predicate.isEmpty()) { - validateHostPredicateProperties(predicate); - try { - hostGroupInfo.setPredicate(predicate); - } catch (InvalidQueryException e) { - throw new InvalidTopologyTemplateException( - String.format("Unable to compile host predicate '%s': %s", predicate, e), e); - } - } - - if (containsHostCount) { - hostGroupInfo.setRequestedCount(Integer.valueOf(hostProperties.get("host_count"))); - } else { - throw new InvalidTopologyTemplateException( - "Host group '" + name + "' hosts element must include at least one fqdn" + - " or a host_count must be specified"); - } - } else { - hostGroupInfo.addHost(hostName); + for (Map<String, String> hostProperties : hosts) { + if (hostProperties.containsKey(HOSTGROUP_HOST_FQDN_PROPERTY)) { + hostGroupInfo.addHost(hostProperties.get(HOSTGROUP_HOST_FQDN_PROPERTY)); } } - // don't set the parent configuration - hostGroupInfo.setConfiguration(configurationFactory.getConfiguration( - (Collection<Map<String, String>>) hostGroupProperties.get("configurations"))); + } + + if (hostGroupInfo.getRequestedHostCount() == 0) { + throw new InvalidTopologyTemplateException(String.format( + "Host group '%s' must contain at least one 'hosts/fqdn' or a 'host_count' value", name)); } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/80e24773/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java index b9a4173..a6995ed 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java @@ -69,7 +69,7 @@ public class ScaleClusterRequest extends BaseClusterRequest { } @Override - public String getCommandDescription() { + public String getDescription() { return String.format("Scale Cluster '%s' (+%s hosts)", clusterName, getTotalRequestedHostCount()); } http://git-wip-us.apache.org/repos/asf/ambari/blob/80e24773/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java index 88c791b..423c503 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java @@ -68,7 +68,7 @@ public class LogicalRequest extends Request { super(id, getController().getClusters().getCluster( request.getClusterName()).getClusterId(), getController().getClusters()); - setRequestContext(String.format("Logical Request: %s", request.getCommandDescription())); + setRequestContext(String.format("Logical Request: %s", request.getDescription())); this.topology = topology; createHostRequests(request, topology); @@ -81,7 +81,7 @@ public class LogicalRequest extends Request { super(id, getController().getClusters().getCluster( request.getClusterName()).getClusterId(), getController().getClusters()); - setRequestContext(String.format("Logical Request: %s", request.getCommandDescription())); + setRequestContext(String.format("Logical Request: %s", request.getDescription())); this.topology = topology; createHostRequests(topology, requestEntity); http://git-wip-us.apache.org/repos/asf/ambari/blob/80e24773/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java index 4101d67..894bc6d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java @@ -185,7 +185,7 @@ public class PersistedStateImpl implements PersistedState { entity.setClusterAttributes(attributesAsString(request.getConfiguration().getAttributes())); entity.setClusterName(request.getClusterName()); entity.setClusterProperties(propertiesAsString(request.getConfiguration().getProperties())); - entity.setDescription(request.getCommandDescription()); + entity.setDescription(request.getDescription()); // host groups Collection<TopologyHostGroupEntity> hostGroupEntities = new ArrayList<TopologyHostGroupEntity>(); @@ -353,7 +353,7 @@ public class PersistedStateImpl implements PersistedState { } @Override - public String getCommandDescription() { + public String getDescription() { return description; } http://git-wip-us.apache.org/repos/asf/ambari/blob/80e24773/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyRequest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyRequest.java index c4dcfb0..d102c21 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyRequest.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyRequest.java @@ -24,21 +24,62 @@ import java.util.Map; /** * A request which is used to create or modify a cluster topology. */ -//todo: naming public interface TopologyRequest { - + /** + * Request types. + */ public enum Type { PROVISION, SCALE, EXPORT } + /** + * Get the cluster name associated with the request. + * + * @return associated cluster name + */ public String getClusterName(); + + /** + * Get the request type. + * + * @return the type of request + */ public Type getType(); + //todo: only a single BP may be specified so all host groups have the same bp. - //todo: There is no reason really that we couldn't allow hostgroups from different blueprints assuming that - //todo: the stack matches across the groups. For scaling operations, we allow different blueprints (rather arbitrary) - //todo: so BP really needs to get associated with the HostGroupInfo, even for create which will have a single BP + //todo: BP really needs to be associated with the HostGroupInfo, even for create which will have a single BP //todo: for all HG's. + + /** + * Get the blueprint instance associated with the request. + * + * @return associated blueprint instance + */ public Blueprint getBlueprint(); + + /** + * Get the cluster scoped configuration for the request. + * + * @return cluster scoped configuration + */ public Configuration getConfiguration(); + + /** + * Get host group info. + * + * @return map of host group name to group info + */ public Map<String, HostGroupInfo> getHostGroupInfo(); + + /** + * Get request topology validators. + * + * @return list of topology validators + */ public List<TopologyValidator> getTopologyValidators(); - public String getCommandDescription(); + + /** + * Get request description. + * + * @return string description of the request + */ + public String getDescription(); } http://git-wip-us.apache.org/repos/asf/ambari/blob/80e24773/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java index 82dd705..6864519 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java @@ -71,6 +71,7 @@ public class ProvisionClusterRequestTest { @Before public void setUp() throws Exception { + reset(blueprintFactory, blueprint, hostResourceProvider); ProvisionClusterRequest.init(blueprintFactory); // set host resource provider field Class clazz = BaseClusterRequest.class; @@ -89,7 +90,6 @@ public class ProvisionClusterRequestTest { @After public void tearDown() { verify(blueprintFactory, blueprint, hostResourceProvider); - reset(blueprintFactory, blueprint, hostResourceProvider); } @Test @@ -103,7 +103,7 @@ public class ProvisionClusterRequestTest { assertEquals(CLUSTER_NAME, provisionClusterRequest.getClusterName()); assertEquals(TopologyRequest.Type.PROVISION, provisionClusterRequest.getType()); - assertEquals(String.format("Provision Cluster '%s'", CLUSTER_NAME) , provisionClusterRequest.getCommandDescription()); + assertEquals(String.format("Provision Cluster '%s'", CLUSTER_NAME) , provisionClusterRequest.getDescription()); assertSame(blueprint, provisionClusterRequest.getBlueprint()); Map<String, HostGroupInfo> hostGroupInfo = provisionClusterRequest.getHostGroupInfo(); assertEquals(1, hostGroupInfo.size()); @@ -155,7 +155,7 @@ public class ProvisionClusterRequestTest { assertEquals(CLUSTER_NAME, provisionClusterRequest.getClusterName()); assertEquals(TopologyRequest.Type.PROVISION, provisionClusterRequest.getType()); - assertEquals(String.format("Provision Cluster '%s'", CLUSTER_NAME) , provisionClusterRequest.getCommandDescription()); + assertEquals(String.format("Provision Cluster '%s'", CLUSTER_NAME) , provisionClusterRequest.getDescription()); assertSame(blueprint, provisionClusterRequest.getBlueprint()); Map<String, HostGroupInfo> hostGroupInfo = provisionClusterRequest.getHostGroupInfo(); assertEquals(1, hostGroupInfo.size()); @@ -207,7 +207,7 @@ public class ProvisionClusterRequestTest { assertEquals(CLUSTER_NAME, provisionClusterRequest.getClusterName()); assertEquals(TopologyRequest.Type.PROVISION, provisionClusterRequest.getType()); - assertEquals(String.format("Provision Cluster '%s'", CLUSTER_NAME) , provisionClusterRequest.getCommandDescription()); + assertEquals(String.format("Provision Cluster '%s'", CLUSTER_NAME) , provisionClusterRequest.getDescription()); assertSame(blueprint, provisionClusterRequest.getBlueprint()); Map<String, HostGroupInfo> hostGroupInfo = provisionClusterRequest.getHostGroupInfo(); assertEquals(2, hostGroupInfo.size()); @@ -373,27 +373,21 @@ public class ProvisionClusterRequestTest { replay(hostResourceProvider); Map<String, Object> properties = createBlueprintRequestPropertiesNameOnly(CLUSTER_NAME, BLUEPRINT_NAME); - List hostGroups = (List) properties.get("host_groups"); - Map hostGroup = (Map) hostGroups.iterator().next(); - List hostInfo = (List) hostGroup.get("hosts"); - ((Map) hostInfo.iterator().next()).put("host_count", "5"); + ((Map) ((List) properties.get("host_groups")).iterator().next()).put("host_count", "5"); // should result in an exception due to both host name and host count being specified - TopologyRequest provisionClusterRequest = new ProvisionClusterRequest(properties); + new ProvisionClusterRequest(properties); } @Test(expected = InvalidTopologyTemplateException.class) - public void testNeitherHostNameOrCountSpecified() throws Exception { + public void testHostNameAndPredicateSpecified() throws Exception { // reset host resource provider expectations to none since we are not specifying a host predicate reset(hostResourceProvider); replay(hostResourceProvider); Map<String, Object> properties = createBlueprintRequestPropertiesNameOnly(CLUSTER_NAME, BLUEPRINT_NAME); - List hostGroups = (List) properties.get("host_groups"); - Map hostGroup = (Map) hostGroups.iterator().next(); - List hostInfo = (List) hostGroup.get("hosts"); - ((Map) hostInfo.iterator().next()).remove("fqdn"); + ((Map) ((List) properties.get("host_groups")).iterator().next()).put("host_predicate", "Hosts/host_name=myTestHost"); // should result in an exception due to both host name and host count being specified - TopologyRequest provisionClusterRequest = new ProvisionClusterRequest(properties); + new ProvisionClusterRequest(properties); } public static Map<String, Object> createBlueprintRequestProperties(String clusterName, String blueprintName) { @@ -427,12 +421,9 @@ public class ProvisionClusterRequestTest { Map<String, Object> hostGroup2Properties = new HashMap<String, Object>(); hostGroups.add(hostGroup2Properties); hostGroup2Properties.put("name", "group2"); - Collection<Map<String, String>> hostGroup2Hosts = new ArrayList<Map<String, String>>(); - hostGroup2Properties.put("hosts", hostGroup2Hosts); - Map<String, String> hostGroup2HostProperties = new HashMap<String, String>(); - hostGroup2HostProperties.put("host_count", "5"); - hostGroup2HostProperties.put("host_predicate", "Hosts/host_name=myTestHost"); - hostGroup2Hosts.add(hostGroup2HostProperties); + hostGroup2Properties.put("host_count", "5"); + hostGroup2Properties.put("host_predicate", "Hosts/host_name=myTestHost"); + // host group 2 scoped configuration // version 2 configuration syntax Collection<Map<String, String>> hostGroup2Configurations = new ArrayList<Map<String, String>>(); @@ -506,12 +497,9 @@ public class ProvisionClusterRequestTest { Map<String, Object> hostGroup2Properties = new HashMap<String, Object>(); hostGroups.add(hostGroup2Properties); hostGroup2Properties.put("name", "group2"); - Collection<Map<String, String>> hostGroup2Hosts = new ArrayList<Map<String, String>>(); - hostGroup2Properties.put("hosts", hostGroup2Hosts); - Map<String, String> hostGroup2HostProperties = new HashMap<String, String>(); // count with no predicate - hostGroup2HostProperties.put("host_count", "5"); - hostGroup2Hosts.add(hostGroup2HostProperties); + hostGroup2Properties.put("host_count", "5"); + // host group 2 scoped configuration // version 2 configuration syntax Collection<Map<String, String>> hostGroup2Configurations = new ArrayList<Map<String, String>>(); http://git-wip-us.apache.org/repos/asf/ambari/blob/80e24773/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java index 91b6c6f..42938a4 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java @@ -111,7 +111,7 @@ public class ScaleClusterRequestTest { assertEquals(TopologyRequest.Type.SCALE, scaleClusterRequest.getType()); assertEquals(String.format("Scale Cluster '%s' (+%s hosts)", CLUSTER_NAME, "1"), - scaleClusterRequest.getCommandDescription()); + scaleClusterRequest.getDescription()); assertEquals(CLUSTER_NAME, scaleClusterRequest.getClusterName()); assertSame(blueprint, scaleClusterRequest.getBlueprint()); Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo(); @@ -142,7 +142,7 @@ public class ScaleClusterRequestTest { assertEquals(TopologyRequest.Type.SCALE, scaleClusterRequest.getType()); assertEquals(String.format("Scale Cluster '%s' (+%s hosts)", CLUSTER_NAME, "2"), - scaleClusterRequest.getCommandDescription()); + scaleClusterRequest.getDescription()); assertEquals(CLUSTER_NAME, scaleClusterRequest.getClusterName()); assertSame(blueprint, scaleClusterRequest.getBlueprint()); Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo(); @@ -171,7 +171,7 @@ public class ScaleClusterRequestTest { assertEquals(TopologyRequest.Type.SCALE, scaleClusterRequest.getType()); assertEquals(String.format("Scale Cluster '%s' (+%s hosts)", CLUSTER_NAME, "1"), - scaleClusterRequest.getCommandDescription()); + scaleClusterRequest.getDescription()); assertEquals(CLUSTER_NAME, scaleClusterRequest.getClusterName()); assertSame(blueprint, scaleClusterRequest.getBlueprint()); Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo(); @@ -198,7 +198,7 @@ public class ScaleClusterRequestTest { assertEquals(TopologyRequest.Type.SCALE, scaleClusterRequest.getType()); assertEquals(String.format("Scale Cluster '%s' (+%s hosts)", CLUSTER_NAME, "2"), - scaleClusterRequest.getCommandDescription()); + scaleClusterRequest.getDescription()); assertEquals(CLUSTER_NAME, scaleClusterRequest.getClusterName()); assertSame(blueprint, scaleClusterRequest.getBlueprint()); Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo(); @@ -221,7 +221,7 @@ public class ScaleClusterRequestTest { assertEquals(TopologyRequest.Type.SCALE, scaleClusterRequest.getType()); assertEquals(String.format("Scale Cluster '%s' (+%s hosts)", CLUSTER_NAME, "1"), - scaleClusterRequest.getCommandDescription()); + scaleClusterRequest.getDescription()); assertEquals(CLUSTER_NAME, scaleClusterRequest.getClusterName()); assertSame(blueprint, scaleClusterRequest.getBlueprint()); Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo(); @@ -248,7 +248,7 @@ public class ScaleClusterRequestTest { assertEquals(TopologyRequest.Type.SCALE, scaleClusterRequest.getType()); assertEquals(String.format("Scale Cluster '%s' (+%s hosts)", CLUSTER_NAME, "3"), - scaleClusterRequest.getCommandDescription()); + scaleClusterRequest.getDescription()); assertEquals(CLUSTER_NAME, scaleClusterRequest.getClusterName()); assertSame(blueprint, scaleClusterRequest.getBlueprint()); Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo(); http://git-wip-us.apache.org/repos/asf/ambari/blob/80e24773/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java index eac269b..bbea96c 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java @@ -219,7 +219,7 @@ public class ClusterTopologyImplTest { } @Override - public String getCommandDescription() { + public String getDescription() { return "Test Request"; } } http://git-wip-us.apache.org/repos/asf/ambari/blob/80e24773/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java index 8d72d79..64dfb28 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java @@ -195,7 +195,7 @@ public class TopologyManagerTest { expect(request.getBlueprint()).andReturn(blueprint).anyTimes(); expect(request.getClusterName()).andReturn(CLUSTER_NAME).anyTimes(); - expect(request.getCommandDescription()).andReturn("Provision Cluster Test").anyTimes(); + expect(request.getDescription()).andReturn("Provision Cluster Test").anyTimes(); expect(request.getConfiguration()).andReturn(topoConfiguration).anyTimes(); expect(request.getHostGroupInfo()).andReturn(groupInfoMap).anyTimes(); expect(request.getTopologyValidators()).andReturn(topologyValidators).anyTimes();