ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jspei...@apache.org
Subject git commit: AMBARI-5723. IllegalStateException when provisioning cluster via blueprint during password validation
Date Mon, 12 May 2014 01:16:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 88e42ff33 -> e5fb45aec


AMBARI-5723.  IllegalStateException when provisioning cluster via blueprint during password
validation


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e5fb45ae
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e5fb45ae
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e5fb45ae

Branch: refs/heads/trunk
Commit: e5fb45aecaffae02c529b00569c6e08cf6406ab3
Parents: 88e42ff
Author: John Speidel <jspeidel@hortonworks.com>
Authored: Fri May 9 17:35:04 2014 -0400
Committer: John Speidel <jspeidel@hortonworks.com>
Committed: Sun May 11 21:16:24 2014 -0400

----------------------------------------------------------------------
 .../internal/ClusterResourceProvider.java       | 36 +++++++++++---------
 .../internal/ClusterResourceProviderTest.java   |  4 ++-
 2 files changed, 23 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e5fb45ae/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 1d05b46..8b6c39a 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
@@ -313,6 +313,7 @@ public class ClusterResourceProvider extends AbstractControllerResourceProvider
    * @throws UnsupportedPropertyException   if an invalid property is specified in the request
    * @throws NoSuchParentResourceException  if a necessary parent resource doesn't exist
    */
+  @SuppressWarnings("unchecked")
   private RequestStatusResponse processBlueprintCreate(Map<String, Object> properties)
       throws ResourceAlreadyExistsException, SystemException, UnsupportedPropertyException,
       NoSuchParentResourceException {
@@ -368,26 +369,29 @@ public class ClusterResourceProvider extends AbstractControllerResourceProvider
     for(iter = missingPasswords.entrySet().iterator(); iter.hasNext(); ) {
       Map.Entry<String, Map<String, Collection<String>>> entry = iter.next();
       Map<String, Collection<String>> missingProps = entry.getValue();
-      Iterator<Map.Entry<String, Collection<String>>> propIter;
-      for (propIter = missingProps.entrySet().iterator(); propIter.hasNext(); ) {
-        Map.Entry<String, Collection<String>> propEntry = propIter.next();
-        String configType = propEntry.getKey();
-        Collection<String> propertySet = propEntry.getValue();
-
-        for (String property : propertySet) {
-          if (setDefaultPassword(defaultPassword, configType, property)) {
-            propIter.remove();
-          } else if (isPropertyInConfiguration(mapClusterConfigurations.get(configType),
property)){
+      Iterator<Map.Entry<String, Collection<String>>> hostGroupIter;
+
+      for (hostGroupIter = missingProps.entrySet().iterator(); hostGroupIter.hasNext(); )
{
+        Map.Entry<String, Collection<String>> hgEntry = hostGroupIter.next();
+        String configType = hgEntry.getKey();
+        Collection<String> propertySet = hgEntry.getValue();
+
+        for (Iterator<String> propIter = propertySet.iterator(); propIter.hasNext();
) {
+          String property = propIter.next();
+          if (isPropertyInConfiguration(mapClusterConfigurations.get(configType), property)){
               propIter.remove();
           } else {
-            HostGroup hostgroup = hostGroups.get(entry.getKey());
-            if (hostgroup != null) {
-              if (isPropertyInConfiguration(hostgroup.getConfigurations().get(configType),
property)) {
-                propIter.remove();
-              }
+            HostGroup hg = hostGroups.get(entry.getKey());
+            if (hg != null && isPropertyInConfiguration(hg.getConfigurations().get(configType),
property)) {
+              propIter.remove();
+            }  else if (setDefaultPassword(defaultPassword, configType, property)) {
+              propIter.remove();
             }
           }
         }
+        if (propertySet.isEmpty()) {
+          hostGroupIter.remove();
+        }
       }
       if (entry.getValue().isEmpty()) {
         iter.remove();
@@ -673,6 +677,7 @@ public class ClusterResourceProvider extends AbstractControllerResourceProvider
    *
    * @throws IllegalArgumentException a host_group in the request doesn't match a host-group
in the blueprint
    */
+  @SuppressWarnings("unchecked")
   private void applyRequestInfoToHostGroups(Map<String, Object> properties,
                                             Map<String, HostGroup> blueprintHostGroups)
                                             throws IllegalArgumentException {
@@ -703,7 +708,6 @@ public class ClusterResourceProvider extends AbstractControllerResourceProvider
         throw new IllegalArgumentException("Host group '" + name + "' must contain a 'hosts'
element");
       }
       for (Object oHost : hosts) {
-        @SuppressWarnings("unchecked")
         Map<String, String> mapHostProperties = (Map<String, String>) oHost;
         //add host information to host group
         String fqdn = mapHostProperties.get("fqdn");

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5fb45ae/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 616df5b..f8bb351 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
@@ -1333,6 +1333,7 @@ public class ClusterResourceProviderTest {
     Map<String, Collection<String>> missingHGPasswords = new HashMap<String,
Collection<String>>();
     Collection<String> missingPasswords = new ArrayList<String>();
     missingPasswords.add("my.missing.password");
+    missingPasswords.add("my.missing.password2");
     missingHGPasswords.put("core-site", missingPasswords);
     allMissingPasswords.put("group1", missingHGPasswords);
 
@@ -1509,13 +1510,14 @@ public class ClusterResourceProviderTest {
     assertEquals(1, hdfsConfigRequest.getProperties().size());
     assertEquals("value2", hdfsConfigRequest.getProperties().get("property2"));
     ConfigurationRequest coreConfigRequest = mapConfigRequests.get("core-site");
-    assertEquals(6, coreConfigRequest.getProperties().size());
+    assertEquals(7, coreConfigRequest.getProperties().size());
     assertEquals("value2", coreConfigRequest.getProperties().get("property1"));
     assertEquals("value3", coreConfigRequest.getProperties().get("property3"));
     assertEquals("*", coreConfigRequest.getProperties().get("hadoop.proxyuser.oozie.hosts"));
     assertEquals("users", coreConfigRequest.getProperties().get("hadoop.proxyuser.oozie.groups"));
     assertEquals("new.property.value", coreConfigRequest.getProperties().get("new.property"));
     assertEquals("foo", coreConfigRequest.getProperties().get("my.missing.password"));
+    assertEquals("foo", coreConfigRequest.getProperties().get("my.missing.password2"));
     assertNull(updateClusterPropertyMapCapture.getValue());
     assertNull(updateClusterPropertyMapCapture2.getValue());
     assertNull(updateClusterPropertyMapCapture3.getValue());


Mime
View raw message