PHOENIX-2399 Server is sometimes unable to find Phoenix driver
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b07f669a Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b07f669a Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b07f669a Branch: refs/heads/txn Commit: b07f669a84681c63bf6dba1ed99c3a0f408bd585 Parents: 645f74a Author: James Taylor <[email protected]> Authored: Tue Nov 10 23:47:11 2015 -0800 Committer: James Taylor <[email protected]> Committed: Tue Nov 10 23:47:11 2015 -0800 ---------------------------------------------------------------------- .../phoenix/mapreduce/CsvBulkLoadToolIT.java | 18 ++++++++---------- .../org/apache/phoenix/mapreduce/IndexToolIT.java | 5 +++++ .../java/org/apache/phoenix/util/QueryUtil.java | 3 +++ 3 files changed, 16 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/b07f669a/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/CsvBulkLoadToolIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/CsvBulkLoadToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/CsvBulkLoadToolIT.java index a787113..0e74d7b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/CsvBulkLoadToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/CsvBulkLoadToolIT.java @@ -17,7 +17,6 @@ */ package org.apache.phoenix.mapreduce; -import static org.apache.phoenix.query.BaseTest.initAndRegisterDriver; import static org.apache.phoenix.query.BaseTest.setUpConfigForMiniCluster; import static org.apache.phoenix.query.QueryServices.DATE_FORMAT_ATTRIB; import static org.junit.Assert.assertArrayEquals; @@ -43,8 +42,6 @@ import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.query.QueryServicesOptions; import org.apache.phoenix.util.DateUtil; import org.apache.phoenix.util.PhoenixRuntime; -import org.apache.phoenix.util.ReadOnlyProps; -import org.apache.phoenix.util.TestUtil; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -63,16 +60,17 @@ public class CsvBulkLoadToolIT { hbaseTestUtil = new HBaseTestingUtility(); Configuration conf = hbaseTestUtil.getConfiguration(); setUpConfigForMiniCluster(conf); + // Since we're using the real PhoenixDriver in this test, remove the + // extra JDBC argument that causes the test driver to be used. + conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); hbaseTestUtil.startMiniCluster(); hbaseTestUtil.startMiniMapReduceCluster(); - zkQuorum = TestUtil.LOCALHOST + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + hbaseTestUtil.getZkCluster().getClientPort(); - String url = PhoenixRuntime.JDBC_PROTOCOL + - PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum + - PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR + - conf.get(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); - initAndRegisterDriver(url, ReadOnlyProps.EMPTY_PROPS); - conn = DriverManager.getConnection(url); + Class.forName(PhoenixDriver.class.getName()); + DriverManager.registerDriver(PhoenixDriver.INSTANCE); + zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); + conn = DriverManager.getConnection(PhoenixRuntime.JDBC_PROTOCOL + + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum); } @AfterClass http://git-wip-us.apache.org/repos/asf/phoenix/blob/b07f669a/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/IndexToolIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/IndexToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/IndexToolIT.java index 30cae36..c88a5f4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/IndexToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/IndexToolIT.java @@ -37,6 +37,8 @@ import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest; import org.apache.phoenix.jdbc.PhoenixDriver; import org.apache.phoenix.mapreduce.index.IndexTool; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.query.QueryServicesOptions; import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; @@ -63,6 +65,9 @@ public class IndexToolIT { hbaseTestUtil = new HBaseTestingUtility(); Configuration conf = hbaseTestUtil.getConfiguration(); conf.setBoolean("hbase.defaults.for.version.skip", true); + // Since we're using the real PhoenixDriver in this test, remove the + // extra JDBC argument that causes the test driver to be used. + conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); setUpConfigForMiniCluster(conf); hbaseTestUtil.startMiniCluster(); hbaseTestUtil.startMiniMapReduceCluster(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/b07f669a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java index d444644..51c03fd 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java @@ -305,6 +305,9 @@ public final class QueryUtil { throws ClassNotFoundException, SQLException { // TODO: props is ignored! // make sure we load the phoenix driver + // TODO: remove this - it doesn't belong here + // The driver should be loaded outside of this call as we might + // be using the test driver. Class.forName(PhoenixDriver.class.getName()); // read the hbase properties from the configuration
