You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by km...@apache.org on 2013/06/07 22:43:23 UTC
git commit: KNOX-9: Support Hive via JDBC+ODBC/Thrift/HTTP
Updated Branches:
refs/heads/master 31deadb64 -> a84cd9c26
KNOX-9: Support Hive via JDBC+ODBC/Thrift/HTTP
Project: http://git-wip-us.apache.org/repos/asf/incubator-knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-knox/commit/a84cd9c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-knox/tree/a84cd9c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-knox/diff/a84cd9c2
Branch: refs/heads/master
Commit: a84cd9c262a372fa2c5b7858d4cd233c8b0f5409
Parents: 31deadb
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Fri Jun 7 16:43:06 2013 -0400
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Fri Jun 7 16:43:06 2013 -0400
----------------------------------------------------------------------
gateway-service-hive/pom.xml | 56 +++++++++
.../gateway/hive/HiveDeploymentContributor.java | 95 +++++++++++++++
...oop.gateway.deploy.ServiceDeploymentContributor | 19 +++
pom.xml | 6 +
4 files changed, 176 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/a84cd9c2/gateway-service-hive/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-service-hive/pom.xml b/gateway-service-hive/pom.xml
new file mode 100644
index 0000000..bde0896
--- /dev/null
+++ b/gateway-service-hive/pom.xml
@@ -0,0 +1,56 @@
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>gateway</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>gateway-service-hive</artifactId>
+
+ <name>gateway-service-hive</name>
+ <description>The extension to the gateway for supporting Hive via JDBC+ODBC/Thrift/HTTP.</description>
+
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <dependencies>
+ <dependency>
+ <groupId>${gateway-group}</groupId>
+ <artifactId>gateway-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${gateway-group}</groupId>
+ <artifactId>gateway-provider-rewrite</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/a84cd9c2/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDeploymentContributor.java b/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDeploymentContributor.java
new file mode 100644
index 0000000..f11ceff
--- /dev/null
+++ b/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDeploymentContributor.java
@@ -0,0 +1,95 @@
+/**
+ * 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.hadoop.gateway.hive;
+
+import org.apache.hadoop.gateway.deploy.DeploymentContext;
+import org.apache.hadoop.gateway.deploy.ServiceDeploymentContributorBase;
+import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRuleDescriptor;
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
+import org.apache.hadoop.gateway.filter.rewrite.ext.UrlRewriteActionRewriteDescriptorExt;
+import org.apache.hadoop.gateway.topology.Service;
+
+import java.net.URISyntaxException;
+
+public class HiveDeploymentContributor extends ServiceDeploymentContributorBase {
+
+ private static final String ROLE = "HIVE";
+ private static final String NAME = "hive";
+ private static final String EXTERNAL_PATH = "/hive";
+
+ @Override
+ public String getRole() {
+ return ROLE;
+ }
+
+ @Override
+ public String getName() {
+ return NAME;
+ }
+
+ @Override
+ public void contributeService( DeploymentContext context, Service service ) throws Exception {
+ contributeRewriteRules( context, service );
+ contributeResources( context, service );
+ }
+
+ private void contributeRewriteRules( DeploymentContext context, Service service ) throws URISyntaxException {
+ UrlRewriteRulesDescriptor rules = context.getDescriptor( "rewrite" );
+ UrlRewriteRuleDescriptor rule;
+ UrlRewriteActionRewriteDescriptorExt rewrite;
+
+ rule = rules.addRule( getRole() + "/" + getName() + "/inbound" )
+ .directions( "inbound" )
+ .pattern( "*://*:*/**" + EXTERNAL_PATH );
+ rewrite = rule.addStep( "rewrite" );
+ rewrite.template( service.getUrl().toExternalForm() );
+ }
+
+ public void contributeResources( DeploymentContext context, Service service ) throws URISyntaxException {
+ ResourceDescriptor rootResource = context.getGatewayDescriptor().addResource();
+ rootResource.role( service.getRole() );
+ rootResource.pattern( EXTERNAL_PATH );
+ addAuthenticationFilter( context, service, rootResource );
+ addRewriteFilter( context, service, rootResource );
+ addIdentityAssertionFilter( context, service, rootResource );
+ addDispatchFilter( context, service, rootResource );
+ }
+
+ private void addAuthenticationFilter( DeploymentContext context, Service service, ResourceDescriptor resource ) {
+ if( topologyContainsProviderType( context, "authentication" ) ) {
+ context.contributeFilter( service, resource, "authentication", null, null );
+ }
+ if( topologyContainsProviderType( context, "federation" ) ) {
+ context.contributeFilter( service, resource, "federation", null, null );
+ }
+ }
+
+ private void addRewriteFilter(
+ DeploymentContext context, Service service, ResourceDescriptor resource ) throws URISyntaxException {
+ context.contributeFilter( service, resource, "rewrite", null, null );
+ }
+
+ private void addIdentityAssertionFilter( DeploymentContext context, Service service, ResourceDescriptor resource ) {
+ context.contributeFilter( service, resource, "identity-assertion", null, null );
+ }
+
+ private void addDispatchFilter( DeploymentContext context, Service service, ResourceDescriptor resource ) {
+ context.contributeFilter( service, resource, "dispatch", null, null );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/a84cd9c2/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
----------------------------------------------------------------------
diff --git a/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor b/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
new file mode 100644
index 0000000..3898804
--- /dev/null
+++ b/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
@@ -0,0 +1,19 @@
+##########################################################################
+# 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.
+##########################################################################
+
+org.apache.hadoop.gateway.hive.HiveDeploymentContributor
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/a84cd9c2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f5bd4e6..1f9cc84 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,7 @@
<module>gateway-provider-identity-assertion-pseudo</module>
<module>gateway-service-as</module>
<module>gateway-service-hbase</module>
+ <module>gateway-service-hive</module>
<module>gateway-service-hdfs</module>
<module>gateway-service-oozie</module>
<module>gateway-service-templeton</module>
@@ -344,6 +345,11 @@
</dependency>
<dependency>
<groupId>${gateway-group}</groupId>
+ <artifactId>gateway-service-hive</artifactId>
+ <version>${gateway-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${gateway-group}</groupId>
<artifactId>gateway-service-hdfs</artifactId>
<version>${gateway-version}</version>
</dependency>