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 24ADB10F38 for ; Tue, 25 Mar 2014 19:48:31 +0000 (UTC) Received: (qmail 88682 invoked by uid 500); 25 Mar 2014 19:48:30 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 88617 invoked by uid 500); 25 Mar 2014 19:48:29 -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 88591 invoked by uid 99); 25 Mar 2014 19:48:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Mar 2014 19:48:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Mar 2014 19:48:26 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7119523889D5; Tue, 25 Mar 2014 19:48:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1581487 - in /hive/branches/branch-0.13: common/src/java/org/apache/hadoop/hive/conf/ metastore/src/java/org/apache/hadoop/hive/metastore/txn/ metastore/src/test/org/apache/hadoop/hive/metastore/txn/ Date: Tue, 25 Mar 2014 19:48:06 -0000 To: commits@hive.apache.org From: hashutosh@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140325194806.7119523889D5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: hashutosh Date: Tue Mar 25 19:48:05 2014 New Revision: 1581487 URL: http://svn.apache.org/r1581487 Log: HIVE-6606 : Stand alone metastore fails to start if new transaction values not defined in config (Alan Gates via Ashutosh Chauhan) Modified: hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java hive/branches/branch-0.13/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java Modified: hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1581487&r1=1581486&r2=1581487&view=diff ============================================================================== --- hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original) +++ hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Tue Mar 25 19:48:05 2014 @@ -125,8 +125,6 @@ public class HiveConf extends Configurat HiveConf.ConfVars.USERS_IN_ADMIN_ROLE, HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, HiveConf.ConfVars.HIVE_TXN_MANAGER, - HiveConf.ConfVars.HIVE_TXN_JDBC_DRIVER, - HiveConf.ConfVars.HIVE_TXN_JDBC_CONNECT_STRING, HiveConf.ConfVars.HIVE_TXN_TIMEOUT, HiveConf.ConfVars.HIVE_TXN_MAX_OPEN_BATCH, }; @@ -715,8 +713,6 @@ public class HiveConf extends Configurat // Transactions HIVE_TXN_MANAGER("hive.txn.manager", "org.apache.hadoop.hive.ql.lockmgr.DummyTxnManager"), - HIVE_TXN_JDBC_DRIVER("hive.txn.driver", ""), - HIVE_TXN_JDBC_CONNECT_STRING("hive.txn.connection.string", ""), // time after which transactions are declared aborted if the client has // not sent a heartbeat, in seconds. HIVE_TXN_TIMEOUT("hive.txn.timeout", 300), Modified: hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java?rev=1581487&r1=1581486&r2=1581487&view=diff ============================================================================== --- hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java (original) +++ hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java Tue Mar 25 19:48:05 2014 @@ -30,8 +30,6 @@ import java.util.Properties; * here in a separate class so it can be shared across unit tests. */ public class TxnDbUtil { - private final static String jdbcString = "jdbc:derby:;databaseName=metastore_db;create=true"; - private final static String jdbcDriver = "org.apache.derby.jdbc.EmbeddedDriver"; private final static String txnMgr = "org.apache.hadoop.hive.ql.lockmgr.DbTxnManager"; /** @@ -41,8 +39,6 @@ public class TxnDbUtil { * @param conf HiveConf to add these values to. */ public static void setConfValues(HiveConf conf) { - conf.setVar(HiveConf.ConfVars.HIVE_TXN_JDBC_DRIVER, jdbcDriver); - conf.setVar(HiveConf.ConfVars.HIVE_TXN_JDBC_CONNECT_STRING, jdbcString); conf.setVar(HiveConf.ConfVars.HIVE_TXN_MANAGER, txnMgr); conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, true); } @@ -52,8 +48,7 @@ public class TxnDbUtil { // intended for creating derby databases, and thus will inexorably get // out of date with it. I'm open to any suggestions on how to make this // read the file in a build friendly way. - Driver driver = (Driver)Class.forName(jdbcDriver).newInstance(); - Connection conn = driver.connect(jdbcString, new Properties()); + Connection conn = getConnection(); Statement s = conn.createStatement(); s.execute("CREATE TABLE TXNS (" + " TXN_ID bigint PRIMARY KEY," + @@ -115,8 +110,7 @@ public class TxnDbUtil { } public static void cleanDb() throws Exception { - Driver driver = (Driver)Class.forName(jdbcDriver).newInstance(); - Connection conn = driver.connect(jdbcString, new Properties()); + Connection conn = getConnection(); Statement s = conn.createStatement(); // We want to try these, whether they succeed or fail. try { @@ -178,8 +172,7 @@ public class TxnDbUtil { * @return number of components, or 0 if there is no lock */ public static int countLockComponents(long lockId) throws Exception { - Driver driver = (Driver)Class.forName(jdbcDriver).newInstance(); - Connection conn = driver.connect(jdbcString, new Properties()); + Connection conn = getConnection(); Statement s = conn.createStatement(); ResultSet rs = s.executeQuery("select count(*) from hive_locks where " + "hl_lock_ext_id = " + lockId); @@ -191,8 +184,7 @@ public class TxnDbUtil { } public static int findNumCurrentLocks() throws Exception { - Driver driver = (Driver)Class.forName(jdbcDriver).newInstance(); - Connection conn = driver.connect(jdbcString, new Properties()); + Connection conn = getConnection(); Statement s = conn.createStatement(); ResultSet rs = s.executeQuery("select count(*) from hive_locks"); if (!rs.next()) return 0; @@ -202,4 +194,17 @@ public class TxnDbUtil { return rc; } + private static Connection getConnection() throws Exception { + HiveConf conf = new HiveConf(); + String jdbcDriver = HiveConf.getVar(conf, HiveConf.ConfVars.METASTORE_CONNECTION_DRIVER); + Driver driver = (Driver)Class.forName(jdbcDriver).newInstance(); + Properties prop = new Properties(); + String driverUrl = HiveConf.getVar(conf, HiveConf.ConfVars.METASTORECONNECTURLKEY); + String user = HiveConf.getVar(conf, HiveConf.ConfVars.METASTORE_CONNECTION_USER_NAME); + String passwd = HiveConf.getVar(conf, HiveConf.ConfVars.METASTOREPWD); + prop.put("user", user); + prop.put("password", passwd); + return driver.connect(driverUrl, prop); + } + } Modified: hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java?rev=1581487&r1=1581486&r2=1581487&view=diff ============================================================================== --- hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java (original) +++ hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java Tue Mar 25 19:48:05 2014 @@ -75,10 +75,8 @@ public class TxnHandler { checkQFileTestHack(); // Set up the JDBC connection pool - String connString = - HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_TXN_JDBC_CONNECT_STRING); try { - setupJdbcConnectionPool(connString); + setupJdbcConnectionPool(); } catch (SQLException e) { String msg = "Unable to instantiate JDBC connection pooling, " + e.getMessage(); LOG.error(msg); @@ -1261,13 +1259,19 @@ public class TxnHandler { } } - private synchronized void setupJdbcConnectionPool(String driverUrl) throws SQLException { + private synchronized void setupJdbcConnectionPool() throws SQLException { if (connPool != null) return; + String driverUrl = HiveConf.getVar(conf, HiveConf.ConfVars.METASTORECONNECTURLKEY); + String user = HiveConf.getVar(conf, HiveConf.ConfVars.METASTORE_CONNECTION_USER_NAME); + String passwd = HiveConf.getVar(conf, HiveConf.ConfVars.METASTOREPWD); + BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl(driverUrl); config.setMaxConnectionsPerPartition(10); config.setPartitionCount(1); + config.setUser(user); + config.setPassword(passwd); connPool = new BoneCP(config); } Modified: hive/branches/branch-0.13/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java?rev=1581487&r1=1581486&r2=1581487&view=diff ============================================================================== --- hive/branches/branch-0.13/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java (original) +++ hive/branches/branch-0.13/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java Tue Mar 25 19:48:05 2014 @@ -920,25 +920,6 @@ public class TestTxnHandler { } } - @Ignore // This test breaks the others when it unsets the value - @Test - public void testNoJDBCDriver() throws Exception { - HiveConf confCopy = new HiveConf(conf); - confCopy.unset(HiveConf.ConfVars.HIVE_TXN_JDBC_DRIVER.varname); - boolean sawException = false; - try { - TxnHandler tt = new TxnHandler(confCopy); - } catch (Exception e) { - if (e instanceof RuntimeException && e.getMessage().contains("JDBC " + - "driver for transaction db not set")) { - sawException = true; - } else { - throw e; - } - } - assertTrue(sawException); - } - @Test public void testCompactMajorWithPartition() throws Exception { CompactionRequest rqst = new CompactionRequest("foo", "bar", CompactionType.MAJOR);