Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2073A10AC1 for ; Wed, 2 Sep 2015 10:48:06 +0000 (UTC) Received: (qmail 72559 invoked by uid 500); 2 Sep 2015 10:48:06 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 72528 invoked by uid 500); 2 Sep 2015 10:48:06 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 72519 invoked by uid 99); 2 Sep 2015 10:48:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2015 10:48:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DC37CDFADE; Wed, 2 Sep 2015 10:48:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vbrodetskyi@apache.org To: commits@ambari.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer 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, 2 Sep 2015 10:48:05 +0000 (UTC) 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 Authored: Wed Sep 2 13:48:25 2015 +0300 Committer: Vitaly Brodetskyi 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 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 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 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 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 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(); + } }