ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-12940. SQLA: add property validation check for BP oozie/hive, about SQLA should be available only for stack 2.3+.(vbrodetskyi)
Date Wed, 02 Sep 2015 10:48:05 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 205e45d53 -> ac06e6d83


AMBARI-12940. SQLA: add property validation check for BP oozie/hive, about SQLA should be
available only for stack 2.3+.(vbrodetskyi)


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

Branch: refs/heads/trunk
Commit: ac06e6d839009d802357a5fcdf45dd493d782906
Parents: 205e45d
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Wed Sep 2 13:48:25 2015 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Wed Sep 2 13:48:25 2015 +0300

----------------------------------------------------------------------
 .../server/topology/BlueprintValidatorImpl.java | 25 ++++++++++-
 .../topology/BlueprintValidatorImplTest.java    | 46 ++++++++++++++++++++
 2 files changed, 70 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ac06e6d8/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
index 70d1907..1b3a910 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
@@ -21,6 +21,7 @@ package org.apache.ambari.server.topology;
 import org.apache.ambari.server.controller.internal.Stack;
 import org.apache.ambari.server.state.AutoDeployInfo;
 import org.apache.ambari.server.state.DependencyInfo;
+import org.apache.ambari.server.utils.VersionUtils;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -94,11 +95,33 @@ public class BlueprintValidatorImpl implements BlueprintValidator {
           Map<String, String> hiveEnvConfig = clusterConfigurations.get("hive-env");
           if (hiveEnvConfig != null && !hiveEnvConfig.isEmpty() && hiveEnvConfig.get("hive_database")
!= null
               && hiveEnvConfig.get("hive_database").startsWith("Existing")) {
-            throw new IllegalArgumentException("Incorrect configuration: MYSQL_SERVER component
is available but hive" +
+            throw new InvalidTopologyException("Incorrect configuration: MYSQL_SERVER component
is available but hive" +
                 " using existing db!");
           }
         }
 
+        if (component.equals("HIVE_METASTORE")) {
+          Map<String, String> hiveEnvConfig = clusterConfigurations.get("hive-env");
+          if (hiveEnvConfig != null && !hiveEnvConfig.isEmpty() && hiveEnvConfig.get("hive_database")
!=null
+                  && hiveEnvConfig.get("hive_database").equals("Existing SQLA Database")
+                  && VersionUtils.compareVersions(stack.getVersion(), "2.3.0.0")
< 0
+                  && stack.getName().equalsIgnoreCase("HDP")) {
+            throw new InvalidTopologyException("Incorrect configuration: SQLA db is available
only for stack HDP-2.3+ " +
+                    "and repo version 2.3.2+!");
+          }
+        }
+
+        if (component.equals("OOZIE_SERVER")) {
+          Map<String, String> oozieEnvConfig = clusterConfigurations.get("oozie-env");
+          if (oozieEnvConfig != null && !oozieEnvConfig.isEmpty() && oozieEnvConfig.get("oozie_database")
!=null
+                  && oozieEnvConfig.get("oozie_database").equals("Existing SQLA Database")
+                  && VersionUtils.compareVersions(stack.getVersion(), "2.3.0.0")
< 0
+                  && stack.getName().equalsIgnoreCase("HDP")) {
+            throw new InvalidTopologyException("Incorrect configuration: SQLA db is available
only for stack HDP-2.3+ " +
+                    "and repo version 2.3.2+!");
+          }
+        }
+
         //for now, AMBARI is not recognized as a service in Stacks
         if (! component.equals("AMBARI_SERVER")) {
           String serviceName = stack.getServiceForComponent(component);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ac06e6d8/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintValidatorImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintValidatorImplTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintValidatorImplTest.java
index 0b1573b..cc2b189 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintValidatorImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintValidatorImplTest.java
@@ -178,4 +178,50 @@ public class BlueprintValidatorImplTest{
 
     verify(group1);
   }
+
+  @Test(expected=InvalidTopologyException.class)
+  public void testValidateRequiredProperties_SqlaInHiveStackHdp22() throws Exception {
+    Map<String, String> hiveEnvConfig = new HashMap<>();
+    hiveEnvConfig.put("hive_database","Existing SQLA Database");
+    configProperties.put("hive-env", hiveEnvConfig);
+
+    group1Components.add("HIVE_METASTORE");
+
+    services.addAll(Arrays.asList("HIVE"));
+
+    expect(group1.getConfiguration()).andReturn(new Configuration(new HashMap(), new HashMap())).anyTimes();
+
+    expect(stack.getComponents("HIVE")).andReturn(Collections.singleton("HIVE_METASTORE")).anyTimes();
+    expect(stack.getVersion()).andReturn("2.2").once();
+    expect(stack.getName()).andReturn("HDP").once();
+
+    expect(blueprint.getHostGroupsForComponent("HIVE_METASTORE")).andReturn(Collections.singleton(group1)).anyTimes();
+
+    replay(blueprint, stack, group1, group2, dependency1);
+    BlueprintValidator validator = new BlueprintValidatorImpl(blueprint);
+    validator.validateRequiredProperties();
+  }
+
+  @Test(expected=InvalidTopologyException.class)
+  public void testValidateRequiredProperties_SqlaInOozieStackHdp22() throws Exception {
+    Map<String, String> hiveEnvConfig = new HashMap<>();
+    hiveEnvConfig.put("oozie_database","Existing SQLA Database");
+    configProperties.put("oozie-env", hiveEnvConfig);
+
+    group1Components.add("OOZIE_SERVER");
+
+    services.addAll(Arrays.asList("OOZIE"));
+
+    expect(group1.getConfiguration()).andReturn(new Configuration(new HashMap(), new HashMap())).anyTimes();
+
+    expect(stack.getComponents("OOZIE")).andReturn(Collections.singleton("OOZIE_SERVER")).anyTimes();
+    expect(stack.getVersion()).andReturn("2.2").once();
+    expect(stack.getName()).andReturn("HDP").once();
+
+    expect(blueprint.getHostGroupsForComponent("OOZIE_SERVER")).andReturn(Collections.singleton(group1)).anyTimes();
+
+    replay(blueprint, stack, group1, group2, dependency1);
+    BlueprintValidator validator = new BlueprintValidatorImpl(blueprint);
+    validator.validateRequiredProperties();
+  }
 }


Mime
View raw message