Parcourir la source

AMBARI-12400. Blueprint config processor should retain property hbase.coprocessor.master.classes with default value (smohanty)

Sumit Mohanty il y a 10 ans
Parent
commit
461ce541a3

+ 20 - 1
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java

@@ -24,6 +24,7 @@ import org.apache.ambari.server.topology.Cardinality;
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.Configuration;
 import org.apache.ambari.server.topology.HostGroupInfo;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -64,6 +65,8 @@ public class BlueprintConfigurationProcessor {
 
   private final static String CLUSTER_ENV_CONFIG_TYPE_NAME = "cluster-env";
 
+  private final static String HBASE_SITE_HBASE_COPROCESSOR_MASTER_CLASSES = "hbase.coprocessor.master.classes";
+
   /**
    * Single host topology updaters
    */
@@ -256,6 +259,20 @@ public class BlueprintConfigurationProcessor {
     setMissingConfigurations(clusterConfig);
   }
 
+  /**
+   * Returns true if property should be retained with default value instead of deleting
+   * TODO: This is a temporary work-around till BP integrates with stack advisor
+   * @param propertyName
+   * @return
+   */
+  private static boolean shouldPropertyBeStoredWithDefault(String propertyName) {
+    if (!StringUtils.isBlank(propertyName) && HBASE_SITE_HBASE_COPROCESSOR_MASTER_CLASSES.equals(propertyName)) {
+      return true;
+    }
+
+    return false;
+  }
+
   /**
    * Update properties for blueprint export.
    * This involves converting concrete topology information to host groups.
@@ -740,7 +757,9 @@ public class BlueprintConfigurationProcessor {
     for(PropertyFilter filter : clusterUpdatePropertyFilters) {
       try {
         if (!filter.isPropertyIncluded(propertyName, propertyValue, propertyType, topology)) {
-          return true;
+          if (!shouldPropertyBeStoredWithDefault(propertyName)) {
+            return true;
+          }
         }
       } catch (Throwable throwable) {
         // if any error occurs during a filter execution, just log it

+ 15 - 2
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java

@@ -4026,12 +4026,13 @@ public class BlueprintConfigurationProcessorTest {
     // setup properties for HBase to simulate the case of authorization being off
     hbaseSiteProperties.put("hbase.security.authorization", "false");
     hbaseSiteProperties.put("hbase.coprocessor.regionserver.classes", " ");
+    hbaseSiteProperties.put("hbase.coprocessor.master.classes", "");
 
     Map<String, Stack.ConfigProperty> mapOfMetadata =
       new HashMap<String, Stack.ConfigProperty>();
 
     // simulate the stack dependencies for these Hive properties, that are dependent upon
-    // hive.server2.authorization being enabled
+    // hbase.security.authorization being enabled
     Stack.ConfigProperty configProperty1 =
       new Stack.ConfigProperty("hbase-site", "hbase.coprocessor.regionserver.classes", " ") {
         @Override
@@ -4041,7 +4042,17 @@ public class BlueprintConfigurationProcessorTest {
         }
       };
 
+    Stack.ConfigProperty configProperty2 =
+        new Stack.ConfigProperty("hbase-site", "hbase.coprocessor.master.classes", "") {
+          @Override
+          Set<PropertyDependencyInfo> getDependsOnProperties() {
+            PropertyDependencyInfo dependencyInfo = new PropertyDependencyInfo("hbase-site", "hbase.security.authorization");
+            return Collections.singleton(dependencyInfo);
+          }
+        };
+
     mapOfMetadata.put("hbase.coprocessor.regionserver.classes", configProperty1);
+    mapOfMetadata.put("hbase.coprocessor.master.classes", configProperty2);
 
     // defaults from init() method that we need
     expect(stack.getName()).andReturn("testStack").anyTimes();
@@ -4071,7 +4082,9 @@ public class BlueprintConfigurationProcessorTest {
     updater.doUpdateForClusterCreate();
 
     assertFalse("hbase.coprocessor.regionserver.classes should have been filtered out of configuration",
-        hbaseSiteProperties.containsKey("hbase.coprocessor.regionserver.classes"));
+                hbaseSiteProperties.containsKey("hbase.coprocessor.regionserver.classes"));
+    assertTrue("hbase.coprocessor.master.classes should not have been filtered out of configuration",
+               hbaseSiteProperties.containsKey("hbase.coprocessor.master.classes"));
 
   }