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/09/16 15:18:00 UTC
git commit: Fix git file rename issue.
Updated Branches:
refs/heads/master 3f1ede539 -> d34100de8
Fix git file rename issue.
Project: http://git-wip-us.apache.org/repos/asf/incubator-knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-knox/commit/d34100de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-knox/tree/d34100de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-knox/diff/d34100de
Branch: refs/heads/master
Commit: d34100de8fe47671d351c94759f88382b451b43f
Parents: 3f1ede5
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Mon Sep 16 09:17:43 2013 -0400
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Mon Sep 16 09:17:43 2013 -0400
----------------------------------------------------------------------
.../hbase/HBaseDeploymentContributor.java | 122 +++++++++++++++++++
.../hbase/HbaseDeploymentContributor.java | 122 -------------------
2 files changed, 122 insertions(+), 122 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/d34100de/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributor.java b/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributor.java
new file mode 100644
index 0000000..8243a9f
--- /dev/null
+++ b/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributor.java
@@ -0,0 +1,122 @@
+/**
+ * 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.hbase;
+
+import org.apache.hadoop.gateway.deploy.DeploymentContext;
+import org.apache.hadoop.gateway.deploy.ServiceDeploymentContributorBase;
+import org.apache.hadoop.gateway.descriptor.FilterParamDescriptor;
+import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterDescriptor;
+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.filter.rewrite.ext.UrlRewriteMatchDescriptor;
+import org.apache.hadoop.gateway.topology.Service;
+
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class HBaseDeploymentContributor extends ServiceDeploymentContributorBase {
+
+ private static final String EXTERNAL_PATH = "/hbase/api/v1";
+ private static final String CLUSTER_URL_FUNCTION = "{gateway.url}";
+
+ @Override
+ public String getRole() {
+ return "HBASE";
+ }
+
+ @Override
+ public String getName() {
+ return "hbase";
+ }
+
+ @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;
+ UrlRewriteMatchDescriptor match;
+
+ rule = rules.addRule( getQualifiedName() + "/root/inbound" )
+ .directions( "inbound" )
+ .pattern( "*://*:*/**" + EXTERNAL_PATH + "/?{**}" );
+ rewrite = rule.addStep( "rewrite" );
+ rewrite.template( service.getUrl() + "/?{**}" );
+
+ rule = rules.addRule( getQualifiedName() + "/root/inbound" )
+ .directions( "inbound" )
+ .pattern( "*://*:*/**" + EXTERNAL_PATH + "/{**}?{**}" );
+ rewrite = rule.addStep( "rewrite" );
+ rewrite.template( service.getUrl() + "/{**}?{**}" );
+
+ rule = rules.addRule( getQualifiedName() + "/hbase/outbound" )
+ .directions( "outbound" );
+ match = rule.addStep( "match" );
+ match.pattern( "*://*:*/{path=**}?{**}" );
+ rewrite = rule.addStep( "rewrite" );
+ rewrite.template( CLUSTER_URL_FUNCTION + EXTERNAL_PATH + "/{path}?{**}" );
+
+ UrlRewriteFilterDescriptor filter = rules.addFilter( getQualifiedName() + "/hbase/outbound" );
+ UrlRewriteFilterContentDescriptor content = filter.addContent( "application/x-http-headers" );
+ content.addApply( "Location", getQualifiedName() + "/hbase/outbound" );
+ }
+
+ private 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 );
+
+ ResourceDescriptor fileResource = context.getGatewayDescriptor().addResource();
+ fileResource.role( service.getRole() );
+ fileResource.pattern( EXTERNAL_PATH + "/**?**" );
+ addAuthenticationFilter( context, service, fileResource );
+ addRewriteFilter( context, service, fileResource );
+ addIdentityAssertionFilter( context, service, fileResource );
+ addAuthorizationFilter(context, service, fileResource);
+ addDispatchFilter( context, service, fileResource );
+ }
+
+ private void addRewriteFilter(
+ DeploymentContext context, Service service, ResourceDescriptor resource ) throws URISyntaxException {
+ List<FilterParamDescriptor> params = new ArrayList<FilterParamDescriptor>();
+ params.add( resource.createFilterParam().name( "response.headers" ).value( getQualifiedName() + "/hbase/outbound" ) );
+ context.contributeFilter( service, resource, "rewrite", null, params );
+ }
+
+ private void addDispatchFilter(
+ DeploymentContext context, Service service, ResourceDescriptor resource ) {
+ context.contributeFilter( service, resource, "dispatch", null, null );
+ }
+
+ private String getQualifiedName() {
+ return getRole() + "/" + getName();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/d34100de/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HbaseDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HbaseDeploymentContributor.java b/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HbaseDeploymentContributor.java
deleted file mode 100644
index 8243a9f..0000000
--- a/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HbaseDeploymentContributor.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * 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.hbase;
-
-import org.apache.hadoop.gateway.deploy.DeploymentContext;
-import org.apache.hadoop.gateway.deploy.ServiceDeploymentContributorBase;
-import org.apache.hadoop.gateway.descriptor.FilterParamDescriptor;
-import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFilterDescriptor;
-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.filter.rewrite.ext.UrlRewriteMatchDescriptor;
-import org.apache.hadoop.gateway.topology.Service;
-
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class HBaseDeploymentContributor extends ServiceDeploymentContributorBase {
-
- private static final String EXTERNAL_PATH = "/hbase/api/v1";
- private static final String CLUSTER_URL_FUNCTION = "{gateway.url}";
-
- @Override
- public String getRole() {
- return "HBASE";
- }
-
- @Override
- public String getName() {
- return "hbase";
- }
-
- @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;
- UrlRewriteMatchDescriptor match;
-
- rule = rules.addRule( getQualifiedName() + "/root/inbound" )
- .directions( "inbound" )
- .pattern( "*://*:*/**" + EXTERNAL_PATH + "/?{**}" );
- rewrite = rule.addStep( "rewrite" );
- rewrite.template( service.getUrl() + "/?{**}" );
-
- rule = rules.addRule( getQualifiedName() + "/root/inbound" )
- .directions( "inbound" )
- .pattern( "*://*:*/**" + EXTERNAL_PATH + "/{**}?{**}" );
- rewrite = rule.addStep( "rewrite" );
- rewrite.template( service.getUrl() + "/{**}?{**}" );
-
- rule = rules.addRule( getQualifiedName() + "/hbase/outbound" )
- .directions( "outbound" );
- match = rule.addStep( "match" );
- match.pattern( "*://*:*/{path=**}?{**}" );
- rewrite = rule.addStep( "rewrite" );
- rewrite.template( CLUSTER_URL_FUNCTION + EXTERNAL_PATH + "/{path}?{**}" );
-
- UrlRewriteFilterDescriptor filter = rules.addFilter( getQualifiedName() + "/hbase/outbound" );
- UrlRewriteFilterContentDescriptor content = filter.addContent( "application/x-http-headers" );
- content.addApply( "Location", getQualifiedName() + "/hbase/outbound" );
- }
-
- private 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 );
-
- ResourceDescriptor fileResource = context.getGatewayDescriptor().addResource();
- fileResource.role( service.getRole() );
- fileResource.pattern( EXTERNAL_PATH + "/**?**" );
- addAuthenticationFilter( context, service, fileResource );
- addRewriteFilter( context, service, fileResource );
- addIdentityAssertionFilter( context, service, fileResource );
- addAuthorizationFilter(context, service, fileResource);
- addDispatchFilter( context, service, fileResource );
- }
-
- private void addRewriteFilter(
- DeploymentContext context, Service service, ResourceDescriptor resource ) throws URISyntaxException {
- List<FilterParamDescriptor> params = new ArrayList<FilterParamDescriptor>();
- params.add( resource.createFilterParam().name( "response.headers" ).value( getQualifiedName() + "/hbase/outbound" ) );
- context.contributeFilter( service, resource, "rewrite", null, params );
- }
-
- private void addDispatchFilter(
- DeploymentContext context, Service service, ResourceDescriptor resource ) {
- context.contributeFilter( service, resource, "dispatch", null, null );
- }
-
- private String getQualifiedName() {
- return getRole() + "/" + getName();
- }
-
-}