Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 7542bc391 -> 2b24cde43


AMBARI-21520. Ambari server logs NPE with no additional stack trace on any host 
component start/stop command.(vbrodetskyi)


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

Branch: refs/heads/branch-2.5
Commit: 2b24cde4315212a782caa88294d98e3338c86ce4
Parents: 7542bc3
Author: Vitaly Brodetskyi <[email protected]>
Authored: Wed Jul 19 16:38:13 2017 +0300
Committer: Vitaly Brodetskyi <[email protected]>
Committed: Wed Jul 19 16:38:13 2017 +0300

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         |  4 +++
 .../ambari/server/state/ConfigHelper.java       | 29 ++++++++++++++++++--
 2 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2b24cde4/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index b80ee98..cccb4b2 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -2727,6 +2727,10 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
       return requestStages;
     }
 
+    // check all stack configs are present in desired configs
+    configHelper.checkAllStageConfigsPresentInDesiredConfigs(cluster);
+
+
     // caching effective cluster version
     ClusterVersionEntity effectiveClusterVersion = 
cluster.getEffectiveClusterVersion();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/2b24cde4/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
index a4c5511..6e60890 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
@@ -698,7 +698,9 @@ public class ConfigHelper {
     for (PropertyInfo stackProperty : stackProperties) {
       if (stackProperty.getPropertyTypes().contains(propertyType)) {
         String stackPropertyConfigType = 
fileNameToConfigType(stackProperty.getFilename());
-        result.put(stackProperty, 
actualConfigs.get(stackPropertyConfigType).getProperties().get(stackProperty.getName()));
+        if (actualConfigs.containsKey(stackPropertyConfigType)) {
+          result.put(stackProperty, 
actualConfigs.get(stackPropertyConfigType).getProperties().get(stackProperty.getName()));
+        }
       }
     }
 
@@ -764,13 +766,36 @@ public class ConfigHelper {
     for (PropertyInfo stackProperty : stackProperties) {
       if (stackProperty.getPropertyTypes().contains(propertyType)) {
         String stackPropertyConfigType = 
fileNameToConfigType(stackProperty.getFilename());
-        
result.add(actualConfigs.get(stackPropertyConfigType).getProperties().get(stackProperty.getName()));
+        if (actualConfigs.containsKey(stackPropertyConfigType)) {
+          
result.add(actualConfigs.get(stackPropertyConfigType).getProperties().get(stackProperty.getName()));
+        }
       }
     }
 
     return result;
   }
 
+  public void checkAllStageConfigsPresentInDesiredConfigs(Cluster cluster) 
throws AmbariException {
+    StackId stackId = cluster.getDesiredStackVersion();
+    Set<String> stackConfigTypes = 
ambariMetaInfo.getStack(stackId.getStackName(),
+            stackId.getStackVersion()).getConfigTypeAttributes().keySet();
+    Map<String, Config> actualConfigs = new HashMap<>();
+    Map<String, DesiredConfig> desiredConfigs = cluster.getDesiredConfigs();
+
+    for (Map.Entry<String, DesiredConfig> desiredConfigEntry : 
desiredConfigs.entrySet()) {
+      String configType = desiredConfigEntry.getKey();
+      DesiredConfig desiredConfig = desiredConfigEntry.getValue();
+      actualConfigs.put(configType, cluster.getConfig(configType, 
desiredConfig.getTag()));
+    }
+
+    for (String stackConfigType : stackConfigTypes) {
+      if (!actualConfigs.containsKey(stackConfigType)) {
+        LOG.error(String.format("Unable to find stack configuration %s in 
ambari configs!", stackConfigType));
+      }
+    }
+
+  }
+
   /***
    * Fetch all the config values of a given PropertyType. For eg: Fetch all 
stack configs that are of type "user"
    * @param cluster

Reply via email to