You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2015/09/02 12:47:04 UTC
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)
Repository: ambari
Updated Branches:
refs/heads/branch-2.1 30072598b -> 0a624f662
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/0a624f66
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0a624f66
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0a624f66
Branch: refs/heads/branch-2.1
Commit: 0a624f66219160d86ee7bd30a117963c22c2bfc7
Parents: 3007259
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Wed Sep 2 13:47:25 2015 +0300
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Wed Sep 2 13:47: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/0a624f66/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/0a624f66/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();
+ }
}