Repository: phoenix
Updated Branches:
  refs/heads/master e25d7d098 -> e4f5cc627


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e4f5cc62/phoenix-server/src/main/java/org/apache/phoenix/queryserver/server/PhoenixMetaFactoryImpl.java
----------------------------------------------------------------------
diff --git 
a/phoenix-server/src/main/java/org/apache/phoenix/queryserver/server/PhoenixMetaFactoryImpl.java
 
b/phoenix-server/src/main/java/org/apache/phoenix/queryserver/server/PhoenixMetaFactoryImpl.java
new file mode 100644
index 0000000..c74d2c9
--- /dev/null
+++ 
b/phoenix-server/src/main/java/org/apache/phoenix/queryserver/server/PhoenixMetaFactoryImpl.java
@@ -0,0 +1,76 @@
+/*
+ * 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.phoenix.queryserver.server;
+
+import com.google.common.base.Preconditions;
+import org.apache.calcite.avatica.Meta;
+import org.apache.calcite.avatica.jdbc.JdbcMeta;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.mapreduce.util.PhoenixConfigurationUtil;
+import org.apache.phoenix.util.QueryUtil;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Bridge between Phoenix and Avatica.
+ */
+public class PhoenixMetaFactoryImpl extends Configured implements 
PhoenixMetaFactory {
+
+  // invoked via reflection
+  public PhoenixMetaFactoryImpl() {
+    super(HBaseConfiguration.create());
+  }
+
+  // invoked via reflection
+  public PhoenixMetaFactoryImpl(Configuration conf) {
+    super(conf);
+  }
+
+  @Override
+  public Meta create(List<String> args) {
+    Configuration conf = Preconditions.checkNotNull(getConf(), "Configuration 
must not be null.");
+    Properties info = new Properties();
+    info.putAll(conf.getValByRegex("avatica.*"));
+    try {
+      final String url;
+      if (args.size() == 0) {
+        url = QueryUtil.getConnectionUrl(info, conf);
+      } else if (args.size() == 1) {
+        url = args.get(0);
+      } else {
+        throw new RuntimeException(
+            "0 or 1 argument expected. Received " + 
Arrays.toString(args.toArray()));
+      }
+      // TODO: what about -D configs passed in from cli? How do they get 
pushed down?
+      return new JdbcMeta(url, info);
+    } catch (SQLException | ClassNotFoundException e) {
+      throw new RuntimeException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/e4f5cc62/phoenix-server/src/test/java/org/apache/phoenix/DriverCohabitationTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-server/src/test/java/org/apache/phoenix/DriverCohabitationTest.java 
b/phoenix-server/src/test/java/org/apache/phoenix/DriverCohabitationTest.java
new file mode 100644
index 0000000..1df6d2c
--- /dev/null
+++ 
b/phoenix-server/src/test/java/org/apache/phoenix/DriverCohabitationTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.phoenix;
+
+import org.apache.phoenix.queryserver.client.ThinClientUtil;
+import org.apache.phoenix.util.QueryUtil;
+import org.junit.Test;
+
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Collections;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Ensure the "thick" Phoenix driver and it's "thin" counterpart can coexist on
+ * the same classpath.
+ */
+public class DriverCohabitationTest {
+
+  @Test
+  public void testDriverCohabitation() throws SQLException {
+    Driver thickDriver = null;
+    Driver thinDriver = null;
+
+    for (Driver d : Collections.list(DriverManager.getDrivers())) {
+      if (d instanceof org.apache.phoenix.jdbc.PhoenixDriver) {
+        thickDriver = d;
+      } else if (d instanceof org.apache.phoenix.queryserver.client.Driver) {
+        thinDriver = d;
+      }
+    }
+    assertNotNull("Thick driver not registered with DriverManager.", 
thickDriver);
+    assertNotNull("Thin driver not registered with DriverManager.", 
thinDriver);
+
+    final String thickUrl = QueryUtil.getUrl("localhost");
+    final String thinUrl = ThinClientUtil.getConnectionUrl("localhost", 1234);
+    assertTrue("Thick driver should accept connections like " + thickUrl,
+        thickDriver.acceptsURL(thickUrl));
+    assertFalse("Thick driver should reject connections like " + thinUrl,
+        thickDriver.acceptsURL(thinUrl));
+    assertTrue("Thin driver should accept connections like " + thinUrl,
+        thinDriver.acceptsURL(thinUrl));
+    assertFalse("Thin driver should reject connections like " + thickUrl,
+        thinDriver.acceptsURL(thickUrl));
+  }
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/e4f5cc62/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 977218d..d38f2e4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,6 +26,8 @@
     <module>phoenix-core</module>
     <module>phoenix-flume</module>
     <module>phoenix-pig</module>
+    <module>phoenix-server-client</module>
+    <module>phoenix-server</module>
     <module>phoenix-assembly</module>
     <module>phoenix-pherf</module>
     <module>phoenix-spark</module>
@@ -91,7 +93,7 @@
     <commons-configuration.version>1.6</commons-configuration.version>
     <commons-io.version>2.1</commons-io.version>
     <commons-lang.version>2.5</commons-lang.version>
-    <commons-logging.version>1.1.1</commons-logging.version>
+    <commons-logging.version>1.2</commons-logging.version>
     <commons-csv.version>1.0</commons-csv.version>
     <sqlline.version>1.1.8</sqlline.version>
     <guava.version>12.0.1</guava.version>
@@ -106,6 +108,7 @@
     <collections.version>3.2.1</collections.version>
     <jodatime.version>2.7</jodatime.version>
     <joni.version>2.1.2</joni.version>
+    <calcite.version>1.2.0-incubating</calcite.version>
 
     <!-- Test Dependencies -->
     <mockito-all.version>1.8.5</mockito-all.version>
@@ -161,7 +164,7 @@
                     </goals>
                   </pluginExecutionFilter>
                   <action>
-                    <ignore></ignore>
+                    <ignore />
                   </action>
                 </pluginExecution>
               </pluginExecutions>
@@ -205,7 +208,7 @@
               <exclude>.project</exclude>
               <exclude>.classpath</exclude>
               <exclude>.settings/**</exclude>
-              <exclude>**/resources/java.sql.Driver</exclude>
+              <exclude>**/java.sql.Driver</exclude>
               <!-- exclude protobuf files -->
               <exclude>**/generated/**</exclude>
             </excludes>
@@ -433,6 +436,16 @@
         <artifactId>phoenix-spark</artifactId>
         <version>${project.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.phoenix</groupId>
+        <artifactId>phoenix-server</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.phoenix</groupId>
+        <artifactId>phoenix-server-client</artifactId>
+        <version>${project.version}</version>
+      </dependency>
 
       <!-- HBase dependencies -->
       <dependency>
@@ -450,6 +463,19 @@
       </dependency>
       <dependency>
         <groupId>org.apache.hbase</groupId>
+        <artifactId>hbase-it</artifactId>
+        <version>${hbase.version}</version>
+        <type>test-jar</type>
+        <scope>test</scope>
+        <exclusions>
+          <exclusion>
+            <groupId>org.jruby</groupId>
+            <artifactId>jruby-complete</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hbase</groupId>
         <artifactId>hbase-protocol</artifactId>
         <version>${hbase.version}</version>
       </dependency>
@@ -524,6 +550,16 @@
           </exclusion>
         </exclusions>
       </dependency>
+      <dependency>
+        <groupId>org.apache.calcite</groupId>
+        <artifactId>calcite-avatica</artifactId>
+        <version>${calcite.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.calcite</groupId>
+        <artifactId>calcite-avatica-server</artifactId>
+        <version>${calcite.version}</version>
+      </dependency>
 
       <!-- Make sure we have all the antlr dependencies -->
       <dependency>
@@ -633,6 +669,11 @@
         <version>${slf4j.version}</version>
       </dependency>
       <dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+        <version>${commons-logging.version}</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.htrace</groupId>
         <artifactId>htrace-core</artifactId>
         <version>${htrace.version}</version>

Reply via email to