Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-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 AF2C318834 for ; Fri, 29 Apr 2016 10:37:45 +0000 (UTC) Received: (qmail 13733 invoked by uid 500); 29 Apr 2016 10:37:45 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 13699 invoked by uid 500); 29 Apr 2016 10:37:45 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 13682 invoked by uid 99); 29 Apr 2016 10:37:45 -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; Fri, 29 Apr 2016 10:37:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3B064DFE04; Fri, 29 Apr 2016 10:37:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: hashutosh@apache.org To: commits@hive.apache.org Message-Id: <2ebaf21491334ff081b8ca224e6fba6a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: =?utf-8?q?hive_git_commit=3A_HIVE-13510_=3A__Dynamic_partitioning_?= =?utf-8?q?doesn=E2=80=99t_work_when_remote_metastore_is_used_=28Illya_Yalov?= =?utf-8?q?yy_via_Ashutosh_Chauhan=29?= Date: Fri, 29 Apr 2016 10:37:45 +0000 (UTC) Repository: hive Updated Branches: refs/heads/master 347a5a558 -> 134b6cccb HIVE-13510 : Dynamic partitioning doesn’t work when remote metastore is used (Illya Yalovyy via Ashutosh Chauhan) Signed-off-by: Ashutosh Chauhan Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/134b6ccc Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/134b6ccc Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/134b6ccc Branch: refs/heads/master Commit: 134b6cccbd7237901f7f7594626796863ca0150a Parents: 347a5a5 Author: Illya Yalovyy Authored: Tue Apr 26 12:18:00 2016 -0700 Committer: Ashutosh Chauhan Committed: Fri Apr 29 03:36:36 2016 -0700 ---------------------------------------------------------------------- .../hadoop/hive/metastore/HiveMetaStore.java | 2 +- .../metastore/TestHiveMetaStoreGetMetaConf.java | 151 +++++++++++++++++++ 2 files changed, 152 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/134b6ccc/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java ---------------------------------------------------------------------- diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index ed2057a..4ada9c1 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -527,7 +527,7 @@ public class HiveMetaStore extends ThriftHiveMetastore { if (confVar == null) { throw new MetaException("Invalid configuration key " + key); } - return getConf().get(key); + return getConf().get(key, confVar.getDefaultValue()); } /** http://git-wip-us.apache.org/repos/asf/hive/blob/134b6ccc/metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveMetaStoreGetMetaConf.java ---------------------------------------------------------------------- diff --git a/metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveMetaStoreGetMetaConf.java b/metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveMetaStoreGetMetaConf.java new file mode 100644 index 0000000..3f4561c --- /dev/null +++ b/metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveMetaStoreGetMetaConf.java @@ -0,0 +1,151 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hive.metastore; + +import java.security.Permission; +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.thrift.TException; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.Rule; +import org.junit.rules.ExpectedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.Assert.*; +import org.junit.Before; + +public class TestHiveMetaStoreGetMetaConf { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private static final Logger LOG = LoggerFactory.getLogger(TestHiveMetaStoreGetMetaConf.class); + private static final String msPort = "20103"; + private static HiveConf hiveConf; + private static SecurityManager securityManager; + + private HiveMetaStoreClient hmsc; + + public static class NoExitSecurityManager extends SecurityManager { + + @Override + public void checkPermission(Permission perm) { + // allow anything. + } + + @Override + public void checkPermission(Permission perm, Object context) { + // allow anything. + } + + @Override + public void checkExit(int status) { + super.checkExit(status); + throw new RuntimeException("System.exit() was called. Raising exception."); + } + } + + private static class RunMS implements Runnable { + + @Override + public void run() { + try { + HiveMetaStore.main(new String[]{"-v", "-p", msPort, "--hiveconf", + "hive.metastore.expression.proxy=" + MockPartitionExpressionForMetastore.class.getCanonicalName(), + "--hiveconf", "hive.metastore.try.direct.sql.ddl=false"}); + } catch (Throwable t) { + LOG.error("Exiting. Got exception from metastore: ", t); + } + } + } + + @AfterClass + public static void tearDown() throws Exception { + LOG.info("Shutting down metastore."); + System.setSecurityManager(securityManager); + } + + @BeforeClass + public static void startMetaStoreServer() throws Exception { + + securityManager = System.getSecurityManager(); + System.setSecurityManager(new NoExitSecurityManager()); + + hiveConf = new HiveConf(TestHiveMetaStoreGetMetaConf.class); + hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + + msPort); + hiveConf.setVar(HiveConf.ConfVars.PREEXECHOOKS, ""); + hiveConf.setVar(HiveConf.ConfVars.POSTEXECHOOKS, ""); + hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false); + hiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 10); + + System.setProperty(HiveConf.ConfVars.PREEXECHOOKS.varname, " "); + System.setProperty(HiveConf.ConfVars.POSTEXECHOOKS.varname, " "); + + new Thread(new RunMS()).start(); + } + + @Before + public void setup() throws MetaException { + hmsc = new HiveMetaStoreClient(hiveConf); + } + + @After + public void closeClient() { + if (hmsc != null) { + hmsc.close(); + } + } + + @Test + public void testGetMetaConfDefault() throws MetaException, TException { + HiveConf.ConfVars metaConfVar = HiveConf.ConfVars.METASTORE_TRY_DIRECT_SQL; + String expected = metaConfVar.getDefaultValue(); + String actual = hmsc.getMetaConf(metaConfVar.toString()); + assertEquals(expected, actual); + } + + @Test + public void testGetMetaConfDefaultEmptyString() throws MetaException, TException { + HiveConf.ConfVars metaConfVar = HiveConf.ConfVars.METASTORE_PARTITION_NAME_WHITELIST_PATTERN; + String expected = ""; + String actual = hmsc.getMetaConf(metaConfVar.toString()); + assertEquals(expected, actual); + } + + @Test + public void testGetMetaConfOverridden() throws MetaException, TException { + HiveConf.ConfVars metaConfVar = HiveConf.ConfVars.METASTORE_TRY_DIRECT_SQL_DDL; + String expected = "false"; + String actual = hmsc.getMetaConf(metaConfVar.toString()); + assertEquals(expected, actual); + } + + @Test + public void testGetMetaConfUnknownPreperty() throws MetaException, TException { + String unknownPropertyName = "hive.meta.foo.bar"; + thrown.expect(MetaException.class); + thrown.expectMessage("Invalid configuration key " + unknownPropertyName); + hmsc.getMetaConf(unknownPropertyName); + } +}