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/a68cc4e3
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a68cc4e3
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a68cc4e3

Branch: refs/heads/txn
Commit: a68cc4e305210e52eb0f5ab3db75fb903cc6e7d3
Parents: 26369f7
Author: James Taylor <[email protected]>
Authored: Tue Nov 10 18:15:08 2015 -0800
Committer: James Taylor <[email protected]>
Committed: Tue Nov 10 18:15:08 2015 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/phoenix/query/QueryServices.java |  1 +
 .../org/apache/phoenix/query/QueryServicesOptions.java    |  7 +++++++
 .../src/main/java/org/apache/phoenix/util/QueryUtil.java  | 10 ++++++++--
 .../org/apache/phoenix/query/QueryServicesTestImpl.java   |  6 +++++-
 4 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a68cc4e3/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
index 2e143a6..3a71f23 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
@@ -170,6 +170,7 @@ public interface QueryServices extends SQLCloseable {
     public static final String COLLECT_REQUEST_LEVEL_METRICS = 
"phoenix.query.request.metrics.enabled";
     public static final String ALLOW_VIEWS_ADD_NEW_CF_BASE_TABLE = 
"phoenix.view.allowNewColumnFamily";
     public static final String RETURN_SEQUENCE_VALUES_ATTRIB = 
"phoenix.sequence.returnValues";
+    public static final String EXTRA_JDBC_ARGUMENTS_ATTRIB = 
"phoenix.jdbc.extra.arguments";
     
 
     /**

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a68cc4e3/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index d003f36..fddf4c7 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -27,6 +27,7 @@ import static 
org.apache.phoenix.query.QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB
 import static 
org.apache.phoenix.query.QueryServices.DELAY_FOR_SCHEMA_UPDATE_CHECK;
 import static org.apache.phoenix.query.QueryServices.DROP_METADATA_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServices.EXPLAIN_CHUNK_COUNT_ATTRIB;
+import static 
org.apache.phoenix.query.QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB;
 import static org.apache.phoenix.query.QueryServices.GLOBAL_METRICS_ENABLED;
 import static 
org.apache.phoenix.query.QueryServices.GROUPBY_MAX_CACHE_SIZE_ATTRIB;
@@ -201,6 +202,7 @@ public class QueryServicesOptions {
     public static final boolean DEFAULT_ALLOW_VIEWS_ADD_NEW_CF_BASE_TABLE = 
true;
     
     public static final boolean DEFAULT_RETURN_SEQUENCE_VALUES = false;
+    public static final String DEFAULT_EXTRA_JDBC_ARGUMENTS = "";
 
     private final Configuration config;
 
@@ -546,4 +548,9 @@ public class QueryServicesOptions {
         config.setBoolean(FORCE_ROW_KEY_ORDER_ATTRIB, forceRowKeyOrder);
         return this;
     }
+    
+    public QueryServicesOptions setExtraJDBCArguments(String extraArgs) {
+        config.set(EXTRA_JDBC_ARGUMENTS_ATTRIB, extraArgs);
+        return this;
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a68cc4e3/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 3b9a910..d444644 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
@@ -45,6 +45,7 @@ import org.apache.phoenix.parse.HintNode;
 import org.apache.phoenix.parse.HintNode.Hint;
 import org.apache.phoenix.parse.WildcardParseNode;
 import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.query.QueryServicesOptions;
 
 import com.google.common.base.Function;
 import com.google.common.base.Joiner;
@@ -340,8 +341,13 @@ public final class QueryUtil {
         server = Joiner.on(',').join(servers);
         String znodeParent = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
                 HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
-
-        return getUrl(server, port, znodeParent);
+        String url = getUrl(server, port, znodeParent);
+        // Mainly for testing to tack on the test=true part to ensure driver 
is found on server
+        String extraArgs = conf.get(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, 
QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
+        if (extraArgs.length() > 0) {
+            url += extraArgs + PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
+        }
+        return url;
     }
     
     public static String getViewStatement(String schemaName, String tableName, 
String where) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a68cc4e3/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
 
b/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
index 9fee78f..5289ab9 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
@@ -21,6 +21,7 @@ import static 
org.apache.phoenix.query.QueryServicesOptions.DEFAULT_SPOOL_DIRECT
 import static org.apache.phoenix.query.QueryServicesOptions.withDefaults;
 
 import org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec;
+import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.ReadOnlyProps;
 
 
@@ -53,6 +54,8 @@ public final class QueryServicesTestImpl extends 
BaseQueryServicesImpl {
     public static final long DEFAULT_MAX_CLIENT_METADATA_CACHE_SIZE =  
1024L*1024L*2L; // 2 Mb
     public static final int DEFAULT_MIN_STATS_UPDATE_FREQ_MS = 0;
     public static final boolean DEFAULT_EXPLAIN_CHUNK_COUNT = false; // TODO: 
update explain plans in test and set to true
+    public static final String DEFAULT_EXTRA_JDBC_ARGUMENTS = 
PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
+
     
     /**
      * Set number of salt buckets lower for sequence table during testing, as 
a high
@@ -89,7 +92,8 @@ public final class QueryServicesTestImpl extends 
BaseQueryServicesImpl {
                 .setDropMetaData(DEFAULT_DROP_METADATA)
                 
.setMaxClientMetaDataCacheSize(DEFAULT_MAX_CLIENT_METADATA_CACHE_SIZE)
                 
.setMaxServerMetaDataCacheSize(DEFAULT_MAX_SERVER_METADATA_CACHE_SIZE)
-                .setForceRowKeyOrder(DEFAULT_FORCE_ROWKEY_ORDER);
+                .setForceRowKeyOrder(DEFAULT_FORCE_ROWKEY_ORDER)
+                .setExtraJDBCArguments(DEFAULT_EXTRA_JDBC_ARGUMENTS);
     }
     
     public QueryServicesTestImpl(ReadOnlyProps defaultProps, ReadOnlyProps 
overrideProps) {

Reply via email to