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 1BED319B13 for ; Fri, 15 Apr 2016 13:43:36 +0000 (UTC) Received: (qmail 24704 invoked by uid 500); 15 Apr 2016 13:43:36 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 24662 invoked by uid 500); 15 Apr 2016 13:43:36 -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 24651 invoked by uid 99); 15 Apr 2016 13:43:35 -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, 15 Apr 2016 13:43:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CBB90DFD43; Fri, 15 Apr 2016 13:43:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aihuaxu@apache.org To: commits@hive.apache.org Message-Id: <5bb272cc530c46eca9fc3ac81d6a8a61@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hive git commit: Revert "HIVE-13149: Remove some unnecessary HMS connections from HS2 (Reviewed by Szehon Ho, Chaoyu Tang)" Date: Fri, 15 Apr 2016 13:43:35 +0000 (UTC) Repository: hive Updated Branches: refs/heads/master 6a776f599 -> 58c4e1215 Revert "HIVE-13149: Remove some unnecessary HMS connections from HS2 (Reviewed by Szehon Ho, Chaoyu Tang)" This reverts commit 37e6e1bf56d7d2fd557730380b147c745fc051ce. Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/58c4e121 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/58c4e121 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/58c4e121 Branch: refs/heads/master Commit: 58c4e1215ec059b37fd4899a71c1789619ef5dba Parents: 6a776f5 Author: Aihua Xu Authored: Fri Apr 15 09:43:19 2016 -0400 Committer: Aihua Xu Committed: Fri Apr 15 09:43:19 2016 -0400 ---------------------------------------------------------------------- .../hadoop/hive/metastore/TestMetastoreVersion.java | 7 +++---- .../metastore/hbase/TestHBaseMetastoreMetrics.java | 4 +++- .../org/apache/hadoop/hive/hbase/HBaseQTestUtil.java | 10 +--------- .../org/apache/hadoop/hive/hbase/HBaseTestSetup.java | 3 +++ .../java/org/apache/hadoop/hive/ql/QTestUtil.java | 14 ++++---------- .../hadoop/hive/metastore/HiveMetaStoreClient.java | 10 ++++------ .../apache/hadoop/hive/ql/session/SessionState.java | 8 ++++++++ 7 files changed, 26 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/58c4e121/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java ---------------------------------------------------------------------- diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java index 5ceb3d2..53f0d0e 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java @@ -19,6 +19,7 @@ package org.apache.hadoop.hive.metastore; import java.io.File; import java.lang.reflect.Field; +import java.util.Random; import junit.framework.TestCase; @@ -31,7 +32,6 @@ import org.apache.hive.common.util.HiveStringUtils; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.ObjectStore; import org.apache.hadoop.hive.ql.Driver; -import org.apache.hadoop.hive.ql.metadata.Hive; import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse; import org.apache.hadoop.hive.ql.session.SessionState; @@ -96,9 +96,8 @@ public class TestMetastoreVersion extends TestCase { // session creation should fail since the schema didn't get created try { SessionState.start(new CliSessionState(hiveConf)); - Hive.get(hiveConf).getMSC(); - fail("An exception is expected since schema is not created."); - } catch (Exception re) { + fail("Expected exception"); + } catch (RuntimeException re) { LOG.info("Exception in testVersionRestriction: " + re, re); String msg = HiveStringUtils.stringifyException(re); assertTrue("Expected 'Version information not found in metastore' in: " + msg, msg http://git-wip-us.apache.org/repos/asf/hive/blob/58c4e121/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseMetastoreMetrics.java ---------------------------------------------------------------------- diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseMetastoreMetrics.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseMetastoreMetrics.java index aefafe0..3ed88f2 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseMetastoreMetrics.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseMetastoreMetrics.java @@ -41,6 +41,8 @@ import java.io.IOException; */ public class TestHBaseMetastoreMetrics extends HBaseIntegrationTests { + private CodahaleMetrics metrics; + @BeforeClass public static void startup() throws Exception { HBaseIntegrationTests.startMiniCluster(); @@ -64,6 +66,7 @@ public class TestHBaseMetastoreMetrics extends HBaseIntegrationTests { conf.setVar(HiveConf.ConfVars.HIVE_METRICS_REPORTER, MetricsReporting.JSON_FILE.name() + "," + MetricsReporting.JMX.name()); SessionState.start(new CliSessionState(conf)); driver = new Driver(conf); + metrics = (CodahaleMetrics) MetricsFactory.getInstance(); } @Test @@ -104,7 +107,6 @@ public class TestHBaseMetastoreMetrics extends HBaseIntegrationTests { driver.run("use default"); driver.run("drop database tempdb cascade"); - CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance(); String json = metrics.dumpJson(); MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_DATABASES, 2); MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_TABLES, 7); http://git-wip-us.apache.org/repos/asf/hive/blob/58c4e121/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseQTestUtil.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseQTestUtil.java b/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseQTestUtil.java index 70c0b13..3ff5742 100644 --- a/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseQTestUtil.java +++ b/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseQTestUtil.java @@ -39,14 +39,12 @@ public class HBaseQTestUtil extends QTestUtil { /** A handle to this harness's cluster */ private final HConnection conn; - private HBaseTestSetup setup; - public HBaseQTestUtil( String outDir, String logDir, MiniClusterType miniMr, HBaseTestSetup setup, String initScript, String cleanupScript) throws Exception { + super(outDir, logDir, miniMr, null, "0.20", initScript, cleanupScript, false, false); - this.setup = setup; setup.preTest(conf); this.conn = setup.getConnection(); super.init(); @@ -71,12 +69,6 @@ public class HBaseQTestUtil extends QTestUtil { } @Override - protected void initConfFromSetup() throws Exception { - super.initConfFromSetup(); - setup.preTest(conf); - } - - @Override public void createSources(String tname) throws Exception { super.createSources(tname); http://git-wip-us.apache.org/repos/asf/hive/blob/58c4e121/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseTestSetup.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseTestSetup.java b/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseTestSetup.java index cee7158..e6383dc 100644 --- a/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseTestSetup.java +++ b/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseTestSetup.java @@ -22,6 +22,9 @@ import java.io.IOException; import java.net.ServerSocket; import java.util.Arrays; +import junit.extensions.TestSetup; +import junit.framework.Test; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; http://git-wip-us.apache.org/repos/asf/hive/blob/58c4e121/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java b/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java index 2f109ab..8473436 100644 --- a/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java +++ b/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java @@ -510,7 +510,6 @@ public class QTestUtil { dfs.shutdown(); dfs = null; } - Hive.closeCurrent(); } public String readEntireFileIntoString(File queryFile) throws IOException { @@ -732,9 +731,8 @@ public class QTestUtil { return; } - conf.set("hive.metastore.filter.hook", + db.getConf().set("hive.metastore.filter.hook", "org.apache.hadoop.hive.metastore.DefaultMetaStoreFilterHookImpl"); - db = Hive.get(conf); // Delete any tables other than the source tables // and any databases other than the default database. for (String dbName : db.getAllDatabases()) { @@ -802,20 +800,16 @@ public class QTestUtil { return; } + clearTablesCreatedDuringTests(); + clearKeysCreatedInTests(); + // allocate and initialize a new conf since a test can // modify conf by using 'set' commands conf = new HiveConf(Driver.class); initConf(); - initConfFromSetup(); - // renew the metastore since the cluster type is unencrypted db = Hive.get(conf); // propagate new conf to meta store - clearTablesCreatedDuringTests(); - clearKeysCreatedInTests(); - } - - protected void initConfFromSetup() throws Exception { setup.preTest(conf); } http://git-wip-us.apache.org/repos/asf/hive/blob/58c4e121/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java ---------------------------------------------------------------------- diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index 64a26ac..cdd12ab 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -178,7 +178,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient { private boolean isConnected = false; private URI metastoreUris[]; private final HiveMetaHookLoader hookLoader; - protected final HiveConf conf; // Keep a copy of HiveConf so if Session conf changes, we may need to get a new HMS client. + protected final HiveConf conf; protected boolean fastpath = false; private String tokenStrForm; private final boolean localMetaStore; @@ -205,10 +205,8 @@ public class HiveMetaStoreClient implements IMetaStoreClient { this.hookLoader = hookLoader; if (conf == null) { conf = new HiveConf(HiveMetaStoreClient.class); - this.conf = conf; - } else { - this.conf = new HiveConf(conf); } + this.conf = conf; filterHook = loadFilterHooks(); fileMetadataBatchSize = HiveConf.getIntVar( conf, HiveConf.ConfVars.METASTORE_BATCH_RETRIEVE_OBJECTS_MAX); @@ -223,10 +221,10 @@ public class HiveMetaStoreClient implements IMetaStoreClient { // instantiate the metastore server handler directly instead of connecting // through the network if (conf.getBoolVar(ConfVars.METASTORE_FASTPATH)) { - client = new HiveMetaStore.HMSHandler("hive client", this.conf, true); + client = new HiveMetaStore.HMSHandler("hive client", conf, true); fastpath = true; } else { - client = HiveMetaStore.newRetryingHMSHandler("hive client", this.conf, true); + client = HiveMetaStore.newRetryingHMSHandler("hive client", conf, true); } isConnected = true; snapshotActiveConf(); http://git-wip-us.apache.org/repos/asf/hive/blob/58c4e121/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java index 2b15c23..8c6c46f 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java @@ -554,6 +554,10 @@ public class SessionState { // Get the following out of the way when you start the session these take a // while and should be done when we start up. try { + // Hive object instance should be created with a copy of the conf object. If the conf is + // shared with SessionState, other parts of the code might update the config, but + // Hive.get(HiveConf) would not recognize the case when it needs refreshing + Hive.get(new HiveConf(startSs.conf)).getMSC(); UserGroupInformation sessionUGI = Utils.getUGI(); FileSystem.get(startSs.conf); @@ -579,6 +583,10 @@ public class SessionState { } } catch (RuntimeException e) { throw e; + } catch (Hive.SchemaException e) { + RuntimeException ex = new RuntimeException(e.getMessage()); + ex.setStackTrace(new StackTraceElement[0]); + throw ex; } catch (Exception e) { // Catch-all due to some exec time dependencies on session state // that would cause ClassNoFoundException otherwise