You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by su...@apache.org on 2015/02/20 04:58:18 UTC
[3/5] knox git commit: Combined work from branch that adds support
for config based services. KNOX-481, KNOX-483 and KNOX-487
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-oozie/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-service-oozie/pom.xml b/gateway-service-oozie/pom.xml
deleted file mode 100644
index 00f8cc3..0000000
--- a/gateway-service-oozie/pom.xml
+++ /dev/null
@@ -1,95 +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.
--->
-<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>
- <artifactId>gateway</artifactId>
- <groupId>org.apache.knox</groupId>
- <version>0.6.0-SNAPSHOT</version>
- </parent>
- <artifactId>gateway-service-oozie</artifactId>
-
- <name>gateway-service-oozie</name>
- <description>The extensions to the gateway for supporting Oozie.</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>org.jboss.shrinkwrap</groupId>
- <artifactId>shrinkwrap-api</artifactId>
- <version>1.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.shrinkwrap</groupId>
- <artifactId>shrinkwrap-impl-base</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.shrinkwrap.descriptors</groupId>
- <artifactId>shrinkwrap-descriptors-api-javaee</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.shrinkwrap.descriptors</groupId>
- <artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${gateway-group}</groupId>
- <artifactId>gateway-test-utils</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-library</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-oozie/src/main/java/org/apache/hadoop/gateway/oozie/OozieDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-service-oozie/src/main/java/org/apache/hadoop/gateway/oozie/OozieDeploymentContributor.java b/gateway-service-oozie/src/main/java/org/apache/hadoop/gateway/oozie/OozieDeploymentContributor.java
deleted file mode 100644
index 0e9ffae..0000000
--- a/gateway-service-oozie/src/main/java/org/apache/hadoop/gateway/oozie/OozieDeploymentContributor.java
+++ /dev/null
@@ -1,121 +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.oozie;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-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.UrlRewriteRulesDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptorFactory;
-import org.apache.hadoop.gateway.topology.Service;
-
-public class OozieDeploymentContributor extends ServiceDeploymentContributorBase {
-
- private static final String RULES_RESOURCE = OozieDeploymentContributor.class.getName().replace( '.', '/' ) + "/rewrite.xml";
- private static final String EXTERNAL_PATH = "/oozie";
-
- private static final String REPLAY_BUFFER_SIZE_PARAM = "replayBufferSize";
-
- // Oozie replay buffer size in KB
- private static final String DEFAULT_REPLAY_BUFFER_SIZE = "8";
-
- @Override
- public String getRole() {
- return "OOZIE";
- }
-
- @Override
- public String getName() {
- return "oozie";
- }
-
- @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, IOException {
- UrlRewriteRulesDescriptor oozieRules = loadRulesFromTemplate();
- UrlRewriteRulesDescriptor clusterRules = context.getDescriptor( "rewrite" );
- clusterRules.addRules( oozieRules );
- }
-
- public void contributeResources( DeploymentContext context, Service service ) throws URISyntaxException {
- ResourceDescriptor rootResource = context.getGatewayDescriptor().addResource();
- rootResource.role( service.getRole() );
- rootResource.pattern( EXTERNAL_PATH + "/**?**" );
- addWebAppSecFilters(context, service, rootResource);
- addAuthenticationFilter( context, service, rootResource );
- addRewriteFilter( context, service, rootResource );
- addIdentityAssertionFilter( context, service, rootResource );
- addAuthorizationFilter(context, service, rootResource);
- addDispatchFilter( context, service, rootResource );
-
- ResourceDescriptor v1Resource = context.getGatewayDescriptor().addResource();
- v1Resource.role( service.getRole() );
- v1Resource.pattern( EXTERNAL_PATH + "/v1/**?**" );
- addWebAppSecFilters(context, service, v1Resource);
- addAuthenticationFilter( context, service, v1Resource );
- addRewriteFilter( context, service, v1Resource );
- addIdentityAssertionFilter( context, service, v1Resource );
- addAuthorizationFilter(context, service, v1Resource);
- addDispatchFilter( context, service, v1Resource );
-
- ResourceDescriptor v2Resource = context.getGatewayDescriptor().addResource();
- v2Resource.role( service.getRole() );
- v2Resource.pattern( EXTERNAL_PATH + "/v2/**?**" );
- addWebAppSecFilters(context, service, v2Resource);
- addAuthenticationFilter( context, service, v2Resource );
- addRewriteFilter( context, service, v2Resource );
- addIdentityAssertionFilter( context, service, v2Resource );
- addAuthorizationFilter(context, service, v2Resource);
- addDispatchFilter( context, service, v2Resource );
- }
-
- private void addRewriteFilter(
- DeploymentContext context, Service service, ResourceDescriptor resource ) throws URISyntaxException {
- List<FilterParamDescriptor> params = new ArrayList<FilterParamDescriptor>();
- params.add( resource.createFilterParam().name( "request.body" ).value( "OOZIE/oozie/configuration" ) );
- context.contributeFilter( service, resource, "rewrite", null, params );
- }
-
- private void addDispatchFilter(DeploymentContext context, Service service,
- ResourceDescriptor resource) {
- context.contributeFilter(service, resource, "dispatch", "http-client", null );
- }
-
- UrlRewriteRulesDescriptor loadRulesFromTemplate() throws IOException {
- InputStream stream = this.getClass().getClassLoader().getResourceAsStream( RULES_RESOURCE );
- Reader reader = new InputStreamReader( stream );
- UrlRewriteRulesDescriptor rules = UrlRewriteRulesDescriptorFactory.load( "xml", reader );
- reader.close();
- stream.close();
- return rules;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-oozie/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
----------------------------------------------------------------------
diff --git a/gateway-service-oozie/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor b/gateway-service-oozie/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
deleted file mode 100644
index cba4689..0000000
--- a/gateway-service-oozie/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
+++ /dev/null
@@ -1,19 +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.
-##########################################################################
-
-org.apache.hadoop.gateway.oozie.OozieDeploymentContributor
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-oozie/src/main/resources/org/apache/hadoop/gateway/oozie/OozieDeploymentContributor/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-service-oozie/src/main/resources/org/apache/hadoop/gateway/oozie/OozieDeploymentContributor/rewrite.xml b/gateway-service-oozie/src/main/resources/org/apache/hadoop/gateway/oozie/OozieDeploymentContributor/rewrite.xml
deleted file mode 100644
index d3c52bb..0000000
--- a/gateway-service-oozie/src/main/resources/org/apache/hadoop/gateway/oozie/OozieDeploymentContributor/rewrite.xml
+++ /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.
--->
-<rules>
-
- <rule dir="IN" name="OOZIE/oozie/root" pattern="*://*:*/**/oozie/{**}?{**}">
- <rewrite template="{$serviceUrl[OOZIE]}/{**}?{**}"/>
- </rule>
-
- <rule dir="IN" name="OOZIE/oozie/v1" pattern="*://*:*/**/oozie/v1/{**}?{**}">
- <rewrite template="{$serviceUrl[OOZIE]}/v1/{**}?{**}"/>
- </rule>
-
- <rule dir="IN" name="OOZIE/oozie/v2" pattern="*://*:*/**/oozie/v2/{**}?{**}">
- <rewrite template="{$serviceUrl[OOZIE]}/v2/{**}?{**}"/>
- </rule>
-
- <rule name="OOZIE/oozie/user-name">
- <rewrite template="{$username}"/>
- </rule>
-
- <rule name="OOZIE/oozie/name-node-url">
- <rewrite template="hdfs://{$serviceMappedAddr[NAMENODE]}"/>
- </rule>
-
- <rule name="OOZIE/oozie/job-tracker-address">
- <rewrite template="{$serviceMappedAddr[JOBTRACKER]}"/>
- </rule>
-
- <rule name="OOZIE/oozie/hdfs-path" flow="OR">
- <match pattern="/~">
- <rewrite template="hdfs://{$serviceMappedHost[NAMENODE]}:{$servicePort[NAMENODE]}/user/{$username}"/>
- </match>
- <match pattern="/~/{path=**}">
- <rewrite template="hdfs://{$serviceMappedHost[NAMENODE]}:{$servicePort[NAMENODE]}/user/{$username}/{path=**}"/>
- </match>
- <match pattern="{path=**}">
- <rewrite template="hdfs://{$serviceMappedHost[NAMENODE]}:{$servicePort[NAMENODE]}/{path=**}"/>
- </match>
- </rule>
-
- <filter name="OOZIE/oozie/configuration">
- <content type="*/xml">
- <buffer path="/configuration/property">
- <detect path="name" value="user.name">
- <apply path="value" rule="OOZIE/oozie/user-name"/>
- </detect>
- <detect path="name" value="nameNode">
- <apply path="value" rule="OOZIE/oozie/name-node-url"/>
- </detect>
- <detect path="name" value="jobTracker">
- <apply path="value" rule="OOZIE/oozie/job-tracker-address"/>
- </detect>
- <detect path="name" value="fs.default.name">
- <apply path="value" rule="OOZIE/oozie/name-node-url"/>
- </detect>
- <detect path="name" value="fs.defaultFS">
- <apply path="value" rule="OOZIE/oozie/name-node-url"/>
- </detect>
- <detect path="name" value="oozie.wf.application.path">
- <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
- </detect>
- <detect path="name" value="oozie.coord.application.path">
- <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
- </detect>
- <detect path="name" value="oozie.bundle.application.path">
- <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
- </detect>
- <detect path="name" value="oozie.libpath">
- <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
- </detect>
- <detect path="name" value="mapreduce.job.user.name">
- <apply path="value" rule="OOZIE/oozie/user-name"/>
- </detect>
- <detect path="name" value="mapred.job.tracker">
- <apply path="value" rule="OOZIE/oozie/job-tracker-address"/>
- </detect>
- <detect path="name" value="mapred.input.dir">
- <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
- </detect>
- <detect path="name" value="inputDir">
- <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
- </detect>
- <detect path="name" value="mapred.output.dir">
- <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
- </detect>
- <detect path="name" value="outputDir">
- <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
- </detect>
- </buffer>
- </content>
- <content type="*/json">
- <apply path="$[user.name]" rule="OOZIE/oozie/user-name"/>
- <apply path="$[nameNode]" rule="OOZIE/oozie/name-node-url"/>
- <apply path="$[jobTracker]" rule="OOZIE/oozie/job-tracker-addr"/>
- <apply path="$[fs.default.name]" rule="OOZIE/oozie/name-node-url"/>
- <apply path="$[fs.defaultFS]" rule="OOZIE/oozie/name-node-url"/>
- <apply path="$[oozie.wf.application.path]" rule="OOZIE/oozie/hdfs-path"/>
- <apply path="$[oozie.coord.application.path]" rule="OOZIE/oozie/hdfs-path"/>
- <apply path="$[oozie.bundle.application.path]" rule="OOZIE/oozie/hdfs-path"/>
- <apply path="$[oozie.libpath]" rule="OOZIE/oozie/hdfs-path"/>
- <apply path="$[mapreduce.job.user.name]" rule="OOZIE/oozie/user-name"/>
- <apply path="$[mapred.job.tracker]" rule="OOZIE/oozie/job-tracker-address"/>
- <apply path="$[mapred.input.dir]" rule="OOZIE/oozie/hdfs-path"/>
- <apply path="$[mapred.output.dir]" rule="OOZIE/oozie/hdfs-path"/>
- </content>
- </filter>
-
-</rules>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-oozie/src/test/java/org/apache/hadoop/gateway/oozie/OozieDeploymentContributorTest.java
----------------------------------------------------------------------
diff --git a/gateway-service-oozie/src/test/java/org/apache/hadoop/gateway/oozie/OozieDeploymentContributorTest.java b/gateway-service-oozie/src/test/java/org/apache/hadoop/gateway/oozie/OozieDeploymentContributorTest.java
deleted file mode 100644
index fad79f0..0000000
--- a/gateway-service-oozie/src/test/java/org/apache/hadoop/gateway/oozie/OozieDeploymentContributorTest.java
+++ /dev/null
@@ -1,130 +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.oozie;
-
-import org.apache.hadoop.gateway.deploy.DeploymentContext;
-import org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteRulesDescriptorImpl;
-import org.apache.hadoop.gateway.topology.Service;
-import org.easymock.EasyMock;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.Iterator;
-import java.util.ServiceLoader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.fail;
-
-public class OozieDeploymentContributorTest {
-
- @Test
- public void testServiceLoader() throws Exception {
- ServiceLoader loader = ServiceLoader.load( ServiceDeploymentContributor.class );
- Iterator iterator = loader.iterator();
- assertThat( "Service iterator empty.", iterator.hasNext() );
- while( iterator.hasNext() ) {
- Object object = iterator.next();
- if( object instanceof OozieDeploymentContributor ) {
- return;
- }
- }
- fail( "Failed to find " + OozieDeploymentContributor.class.getName() + " via service loader." );
- }
-
- @Test
- public void testLoadRulesFromTemplate() throws IOException, URISyntaxException {
- WebArchive webArchive = ShrinkWrap.create( WebArchive.class, "test-archive" );
-
- UrlRewriteRulesDescriptorImpl clusterRules = new UrlRewriteRulesDescriptorImpl();
-
- DeploymentContext context = EasyMock.createNiceMock( DeploymentContext.class );
- EasyMock.expect( context.getDescriptor( "rewrite" ) ).andReturn( clusterRules ).anyTimes();
- EasyMock.expect( context.getWebArchive() ).andReturn( webArchive ).anyTimes();
-
- Service service = EasyMock.createNiceMock( Service.class );
- EasyMock.expect( service.getRole() ).andReturn( "OOZIE" ).anyTimes();
- EasyMock.expect( service.getName() ).andReturn( null ).anyTimes();
- EasyMock.expect( service.getUrl() ).andReturn( "http://test-host:777" ).anyTimes();
-
- EasyMock.replay( context, service );
-
- OozieDeploymentContributor contributor = new OozieDeploymentContributor();
-
- UrlRewriteRulesDescriptor oozieRules = contributor.loadRulesFromTemplate();
-
- assertThat( oozieRules, notNullValue() );
- assertThat( oozieRules.getFilter( "OOZIE/oozie/configuration" ), notNullValue() );
- }
-
-// @Test
-// public void testDeployment() throws Exception {
-// WebArchive webArchive = ShrinkWrap.create( WebArchive.class, "test-archive" );
-//
-// UrlRewriteRulesDescriptorImpl rewriteRules = new UrlRewriteRulesDescriptorImpl();
-//
-// Map<String,String> serviceParams = new HashMap<String, String>();
-// Service service = new Service();
-// service.setRole( "OOZIE" );
-// service.setName( "oozie" );
-// service.setUrl( "http://test-host:42/test-path" );
-// service.setParams( serviceParams );
-//
-// Topology topology = new Topology();
-// topology.setName( "test-topology" );
-// topology.addService( service );
-//
-// GatewayDescriptor gateway = EasyMock.createNiceMock( GatewayDescriptor.class );
-// DeploymentContext context = EasyMock.createNiceMock( DeploymentContext.class );
-// EasyMock.expect( context.getWebArchive() ).andReturn( webArchive ).anyTimes();
-// EasyMock.expect( context.getDescriptor( "rewrite" ) ).andReturn( rewriteRules ).anyTimes();
-// EasyMock.expect( context.getWebAppDescriptor() ).andReturn( Descriptors.create( WebAppDescriptor.class ) ).anyTimes();
-// EasyMock.expect( context.getTopology() ).andReturn( topology ).anyTimes();
-// EasyMock.expect( context.getGatewayDescriptor() ).andReturn( gateway ).anyTimes();
-// Capture<Service> capturedService = new Capture<Service>();
-// Capture<ResourceDescriptor> capturedResource = new Capture<ResourceDescriptor>();
-// Capture<String> capturedRole = new Capture<String>();
-// Capture<String> capturedName = new Capture<String>();
-// Capture<List<FilterParamDescriptor>> capturedParams = new Capture<List<FilterParamDescriptor>>();
-// context.contributeFilter( capture(capturedService) , capture(capturedResource), capture(capturedRole), capture(capturedName), capture(capturedParams) );
-// EasyMock.expectLastCall().anyTimes();
-// EasyMock.replay( gateway, context );
-//
-// OozieDeploymentContributor contributor = new OozieDeploymentContributor();
-//
-// assertThat( contributor.getRole(), CoreMatchers.is( "OOZIE" ) );
-// assertThat( contributor.getName(), CoreMatchers.is( "oozie" ) );
-//
-// // Just make sure it doesn't blow up.
-// contributor.initializeContribution( context );
-//
-// contributor.contributeService( context, service );
-//
-// // Just make sure it doesn't blow up.
-// contributor.finalizeContribution( context );
-//
-// assertThat( capturedRole.getValue(), is( "dispatch" ) );
-// assertThat( capturedName.getValue(), is( "http-client" ) );
-// }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhcat/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-service-webhcat/pom.xml b/gateway-service-webhcat/pom.xml
deleted file mode 100644
index 3f81cc4..0000000
--- a/gateway-service-webhcat/pom.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.knox</groupId>
- <artifactId>gateway</artifactId>
- <version>0.6.0-SNAPSHOT</version>
- </parent>
- <artifactId>gateway-service-webhcat</artifactId>
-
- <name>gateway-service-webhcat</name>
- <description>The extension to the gateway for supporting WebHCat.</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>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhcat/src/main/java/org/apache/hadoop/gateway/webhcat/WebHCatDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-service-webhcat/src/main/java/org/apache/hadoop/gateway/webhcat/WebHCatDeploymentContributor.java b/gateway-service-webhcat/src/main/java/org/apache/hadoop/gateway/webhcat/WebHCatDeploymentContributor.java
deleted file mode 100644
index 9ee7a9a..0000000
--- a/gateway-service-webhcat/src/main/java/org/apache/hadoop/gateway/webhcat/WebHCatDeploymentContributor.java
+++ /dev/null
@@ -1,95 +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.webhcat;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URISyntaxException;
-
-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.UrlRewriteRulesDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptorFactory;
-import org.apache.hadoop.gateway.topology.Service;
-
-public class WebHCatDeploymentContributor extends ServiceDeploymentContributorBase {
-
- private static final String RULES_RESOURCE = WebHCatDeploymentContributor.class.getName().replace( '.', '/' ) + "/rewrite.xml";
- private static final String WEBHCAT_EXTERNAL_PATH = "/templeton/v1";
-
- @Override
- public String getRole() {
- return "WEBHCAT";
- }
-
- @Override
- public String getName() {
- return "webhcat";
- }
-
- @Override
- public void contributeService( DeploymentContext context, Service service ) throws Exception {
- contributeRewriteRules( context, service );
- contributeResources( context, service );
- }
-
- private void contributeRewriteRules( DeploymentContext context, Service service ) throws IOException {
- UrlRewriteRulesDescriptor hbaseRules = loadRulesFromTemplate();
- UrlRewriteRulesDescriptor clusterRules = context.getDescriptor( "rewrite" );
- clusterRules.addRules( hbaseRules );
- }
-
- private UrlRewriteRulesDescriptor loadRulesFromTemplate() throws IOException {
- InputStream stream = this.getClass().getClassLoader().getResourceAsStream( RULES_RESOURCE );
- Reader reader = new InputStreamReader( stream );
- UrlRewriteRulesDescriptor rules = UrlRewriteRulesDescriptorFactory.load( "xml", reader );
- reader.close();
- stream.close();
- return rules;
- }
-
- private void contributeResources( DeploymentContext context, Service service ) throws URISyntaxException {
- ResourceDescriptor rootResource = context.getGatewayDescriptor().addResource();
- rootResource.role( service.getRole() );
- rootResource.pattern( WEBHCAT_EXTERNAL_PATH + "/?**" );
- addWebAppSecFilters( context, service, rootResource );
- addAuthenticationFilter( context, service, rootResource );
- addRewriteFilter( context, service, rootResource, null );
- addIdentityAssertionFilter( context, service, rootResource );
- addAuthorizationFilter( context, service, rootResource );
- addDispatchFilter( context, service, rootResource );
-
- ResourceDescriptor pathResource = context.getGatewayDescriptor().addResource();
- pathResource.role( service.getRole() );
- pathResource.pattern( WEBHCAT_EXTERNAL_PATH + "/**?**" );
- addWebAppSecFilters( context, service, pathResource );
- addAuthenticationFilter( context, service, pathResource );
- addRewriteFilter( context, service, pathResource, null );
- addIdentityAssertionFilter( context, service, pathResource );
- addAuthorizationFilter( context, service, pathResource );
- addDispatchFilter( context, service, pathResource );
- }
-
- private void addDispatchFilter(
- DeploymentContext context, Service service, ResourceDescriptor resource ) {
- context.contributeFilter( service, resource, "dispatch", "http-client", null );
- }
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhcat/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
----------------------------------------------------------------------
diff --git a/gateway-service-webhcat/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor b/gateway-service-webhcat/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
deleted file mode 100644
index 1b74d89..0000000
--- a/gateway-service-webhcat/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
+++ /dev/null
@@ -1,19 +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.
-##########################################################################
-
-org.apache.hadoop.gateway.webhcat.WebHCatDeploymentContributor
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhcat/src/main/resources/org/apache/hadoop/gateway/webhcat/WebHCatDeploymentContributor/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-service-webhcat/src/main/resources/org/apache/hadoop/gateway/webhcat/WebHCatDeploymentContributor/rewrite.xml b/gateway-service-webhcat/src/main/resources/org/apache/hadoop/gateway/webhcat/WebHCatDeploymentContributor/rewrite.xml
deleted file mode 100644
index 558abb4..0000000
--- a/gateway-service-webhcat/src/main/resources/org/apache/hadoop/gateway/webhcat/WebHCatDeploymentContributor/rewrite.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
- 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.
--->
-<rules>
-
- <rule dir="IN" name="WEBHCAT/webhcat/root/inbound" pattern="*://*:*/**/templeton/v1/?{**}">
- <rewrite template="{$serviceUrl[WEBHCAT]}/v1/?{**}"/>
- </rule>
-
- <rule dir="IN" name="WEBHCAT/webhcat/path/inbound" pattern="*://*:*/**/templeton/v1/{path=**}?{**}">
- <rewrite template="{$serviceUrl[WEBHCAT]}/v1/{path=**}?{**}"/>
- </rule>
-
-</rules>
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/NameNodeHaDispatchDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/NameNodeHaDispatchDeploymentContributor.java b/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/NameNodeHaDispatchDeploymentContributor.java
deleted file mode 100644
index c7b3ff9..0000000
--- a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/NameNodeHaDispatchDeploymentContributor.java
+++ /dev/null
@@ -1,60 +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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.hdfs;
-
-import org.apache.hadoop.gateway.deploy.DeploymentContext;
-import org.apache.hadoop.gateway.deploy.ProviderDeploymentContributorBase;
-import org.apache.hadoop.gateway.descriptor.FilterParamDescriptor;
-import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
-import org.apache.hadoop.gateway.hdfs.dispatch.WebHdfsHaHttpClientDispatch;
-import org.apache.hadoop.gateway.topology.Provider;
-import org.apache.hadoop.gateway.topology.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public class NameNodeHaDispatchDeploymentContributor extends ProviderDeploymentContributorBase {
-
- private static final String ROLE = "dispatch";
-
- private static final String NAME = "ha-hdfs";
-
- @Override
- public String getRole() {
- return ROLE;
- }
-
- @Override
- public String getName() {
- return NAME;
- }
-
- @Override
- public void contributeFilter(DeploymentContext context, Provider provider, Service service, ResourceDescriptor resource, List<FilterParamDescriptor> params) {
- if (params == null) {
- params = new ArrayList<FilterParamDescriptor>();
- }
- params.add(resource.createFilterParam().name(WebHdfsHaHttpClientDispatch.RESOURCE_ROLE_ATTRIBUTE).value(resource.role()));
- Map<String, String> providerParams = provider.getParams();
- for (Map.Entry<String, String> entry : providerParams.entrySet()) {
- params.add(resource.createFilterParam().name(entry.getKey().toLowerCase()).value(entry.getValue()));
- }
- resource.addFilter().name(getName()).role(getRole()).impl(WebHdfsHaHttpClientDispatch.class).params(params);
- }
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/WebHdfsDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/WebHdfsDeploymentContributor.java b/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/WebHdfsDeploymentContributor.java
deleted file mode 100644
index 0e63597..0000000
--- a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/WebHdfsDeploymentContributor.java
+++ /dev/null
@@ -1,173 +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.hdfs;
-
-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.UrlRewriteRulesDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptorFactory;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteServletFilter;
-import org.apache.hadoop.gateway.topology.Provider;
-import org.apache.hadoop.gateway.topology.Service;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public class WebHdfsDeploymentContributor extends ServiceDeploymentContributorBase {
-
- private static final String RULES_RESOURCE = WebHdfsDeploymentContributor.class.getName().replace( '.', '/' ) + "/rewrite.xml";
- private static final String WEBHDFS_EXTERNAL_PATH = "/webhdfs/v1";
- private static final String DATANODE_EXTERNAL_PATH = "/webhdfs/data/v1";
-
- @Override
- public String getRole() {
- return "WEBHDFS";
- }
-
- @Override
- public String getName() {
- return "webhdfs";
- }
-
- @Override
- public void contributeService( DeploymentContext context, Service service ) throws Exception {
- contributeRewriteRules( context, service );
- contributeNameNodeResource( context, service );
- contributeDataNodeResource( context, service );
- }
-
- private void contributeRewriteRules( DeploymentContext context, Service service ) throws URISyntaxException, IOException {
- UrlRewriteRulesDescriptor serviceRules = loadRulesFromClassPath();
- UrlRewriteRulesDescriptor clusterRules = context.getDescriptor( "rewrite" );
- clusterRules.addRules( serviceRules );
- }
-
- public void contributeNameNodeResource( DeploymentContext context, Service service ) throws URISyntaxException {
- List<FilterParamDescriptor> params;
- ResourceDescriptor rootResource = context.getGatewayDescriptor().addResource();
- rootResource.role( service.getRole() );
- rootResource.pattern( WEBHDFS_EXTERNAL_PATH + "/?**" );
- addWebAppSecFilters(context, service, rootResource);
- addAuthenticationFilter( context, service, rootResource );
- params = new ArrayList<FilterParamDescriptor>();
- params.add( rootResource.createFilterParam().
- name( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM ).value( getQualifiedName() + "/inbound/namenode/root" ) );
- addRewriteFilter( context, service, rootResource, params );
- addIdentityAssertionFilter( context, service, rootResource );
- addAuthorizationFilter( context, service, rootResource );
- String dispatchName = getDispatchNameForNN( context );
- String dispatchRole = "dispatch";
- addDispatchFilter( context, service, rootResource, dispatchRole, dispatchName );
-
- ResourceDescriptor fileResource = context.getGatewayDescriptor().addResource();
- fileResource.role( service.getRole() );
- fileResource.pattern( WEBHDFS_EXTERNAL_PATH + "/**?**" );
- addWebAppSecFilters(context, service, fileResource);
- addAuthenticationFilter( context, service, fileResource );
- params = new ArrayList<FilterParamDescriptor>();
- params.add( fileResource.createFilterParam().
- name( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM ).value( getQualifiedName() + "/inbound/namenode/file" ) );
- params.add( fileResource.createFilterParam().
- name( UrlRewriteServletFilter.RESPONSE_HEADERS_FILTER_PARAM ).value( getQualifiedName() + "/outbound/namenode/headers" ) );
- addRewriteFilter( context, service, fileResource, params );
- addIdentityAssertionFilter( context, service, fileResource );
- addAuthorizationFilter( context, service, fileResource );
- addDispatchFilter( context, service, fileResource, dispatchRole, dispatchName );
-
- ResourceDescriptor homeResource = context.getGatewayDescriptor().addResource();
- homeResource.role( service.getRole() );
- homeResource.pattern( WEBHDFS_EXTERNAL_PATH + "/~?**" );
- addWebAppSecFilters(context, service, homeResource);
- addAuthenticationFilter( context, service, homeResource );
- params = new ArrayList<FilterParamDescriptor>();
- params.add( homeResource.createFilterParam().
- name( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM ).value( getQualifiedName() + "/inbound/namenode/home" ) );
- addRewriteFilter( context, service, homeResource, params );
- addIdentityAssertionFilter( context, service, homeResource );
- addAuthorizationFilter( context, service, homeResource );
- addDispatchFilter( context, service, homeResource, dispatchRole, dispatchName );
-
- ResourceDescriptor homeFileResource = context.getGatewayDescriptor().addResource();
- homeFileResource.role( service.getRole() );
- homeFileResource.pattern( WEBHDFS_EXTERNAL_PATH + "/~/**?**" );
- addWebAppSecFilters(context, service, homeFileResource);
- addAuthenticationFilter( context, service, homeFileResource );
- params = new ArrayList<FilterParamDescriptor>();
- params.add( homeFileResource.createFilterParam().
- name( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM ).value( getQualifiedName() + "/inbound/namenode/home/file" ) );
- params.add( homeFileResource.createFilterParam().
- name( UrlRewriteServletFilter.RESPONSE_HEADERS_FILTER_PARAM ).value( getQualifiedName() + "/outbound/namenode/headers" ) );
- addRewriteFilter( context, service, homeFileResource, params );
- addIdentityAssertionFilter( context, service, homeFileResource );
- addAuthorizationFilter( context, service, homeFileResource );
- addDispatchFilter( context, service, homeFileResource, dispatchRole, dispatchName );
- }
-
- public void contributeDataNodeResource( DeploymentContext context, Service service ) throws URISyntaxException {
- List<FilterParamDescriptor> params;
- ResourceDescriptor fileResource = context.getGatewayDescriptor().addResource();
- fileResource.role( service.getRole() );
- fileResource.pattern( DATANODE_EXTERNAL_PATH + "/**?**" );
- addWebAppSecFilters(context, service, fileResource);
- addAuthenticationFilter( context, service, fileResource );
- addIdentityAssertionFilter( context, service, fileResource );
- addAuthorizationFilter( context, service, fileResource );
- params = new ArrayList<FilterParamDescriptor>();
- params.add( fileResource.createFilterParam().
- name( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM ).value( getQualifiedName() + "/inbound/datanode" ) );
- addRewriteFilter( context, service, fileResource, params );
- addDispatchFilter( context, service, fileResource, "dispatch", "http-client" );
- }
-
- String getQualifiedName() {
- return getRole() + "/" + getName();
- }
-
- UrlRewriteRulesDescriptor loadRulesFromClassPath() throws IOException {
- InputStream stream = this.getClass().getClassLoader().getResourceAsStream( RULES_RESOURCE );
- Reader reader = new InputStreamReader( stream );
- UrlRewriteRulesDescriptor rules = UrlRewriteRulesDescriptorFactory.load( "xml", reader );
- reader.close();
- stream.close();
- return rules;
- }
-
- /**
- * Returns the name of the dispatch to use by checking to see if 'HA' is enabled.
- */
- private String getDispatchNameForNN(DeploymentContext context) {
- Provider provider = getProviderByRole(context, "ha");
- if (provider != null && provider.isEnabled()) {
- Map<String, String> params = provider.getParams();
- if (params != null) {
- if (params.containsKey(getRole())) {
- return "ha-hdfs";
- }
- }
- }
- return "hdfs";
- }
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/WebHdfsDispatchDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/WebHdfsDispatchDeploymentContributor.java b/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/WebHdfsDispatchDeploymentContributor.java
deleted file mode 100644
index 78353d1..0000000
--- a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/WebHdfsDispatchDeploymentContributor.java
+++ /dev/null
@@ -1,47 +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.hdfs;
-
-import org.apache.hadoop.gateway.deploy.DeploymentContext;
-import org.apache.hadoop.gateway.deploy.ProviderDeploymentContributorBase;
-import org.apache.hadoop.gateway.descriptor.FilterParamDescriptor;
-import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
-import org.apache.hadoop.gateway.hdfs.dispatch.HdfsDispatch;
-import org.apache.hadoop.gateway.topology.Provider;
-import org.apache.hadoop.gateway.topology.Service;
-
-import java.util.List;
-
-public class WebHdfsDispatchDeploymentContributor extends ProviderDeploymentContributorBase {
-
- @Override
- public String getRole() {
- return "dispatch";
- }
-
- @Override
- public String getName() {
- return "hdfs";
- }
-
- @Override
- public void contributeFilter( DeploymentContext context, Provider provider, Service service, ResourceDescriptor resource, List<FilterParamDescriptor> params ) {
- resource.addFilter().role( getRole() ).name( getName() ).impl( HdfsDispatch.class ).params(params);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java b/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
index a0aa014..f21b6e9 100644
--- a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
+++ b/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
@@ -17,10 +17,12 @@
*/
package org.apache.hadoop.gateway.hdfs.dispatch;
+import org.apache.hadoop.gateway.config.Configure;
import org.apache.hadoop.gateway.filter.AbstractGatewayFilter;
import org.apache.hadoop.gateway.ha.provider.HaProvider;
import org.apache.hadoop.gateway.ha.provider.HaServiceConfig;
import org.apache.hadoop.gateway.ha.provider.HaServletContextListener;
+import org.apache.hadoop.gateway.ha.provider.impl.HaServiceConfigConstants;
import org.apache.hadoop.gateway.hdfs.i18n.WebHdfsMessages;
import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
import org.apache.http.HttpResponse;
@@ -43,19 +45,17 @@ public class WebHdfsHaHttpClientDispatch extends HdfsDispatch {
private static final String RETRY_COUNTER_ATTRIBUTE = "dispatch.ha.retry.counter";
- public static final String RESOURCE_ROLE_ATTRIBUTE = "resource.role";
+ public static final String RESOURCE_ROLE = "WEBHDFS";
private static final WebHdfsMessages LOG = MessagesFactory.get(WebHdfsMessages.class);
- private int maxFailoverAttempts;
+ private int maxFailoverAttempts = HaServiceConfigConstants.DEFAULT_MAX_FAILOVER_ATTEMPTS;
- private int failoverSleep;
+ private int failoverSleep = HaServiceConfigConstants.DEFAULT_FAILOVER_SLEEP;
- private int maxRetryAttempts;
+ private int maxRetryAttempts = HaServiceConfigConstants.DEFAULT_MAX_RETRY_ATTEMPTS;
- private int retrySleep;
-
- private String resourceRole;
+ private int retrySleep = HaServiceConfigConstants.DEFAULT_RETRY_SLEEP;
private HaProvider haProvider;
@@ -67,19 +67,27 @@ public class WebHdfsHaHttpClientDispatch extends HdfsDispatch {
}
@Override
- public void init(FilterConfig filterConfig) throws ServletException {
- super.init(filterConfig);
- resourceRole = filterConfig.getInitParameter(RESOURCE_ROLE_ATTRIBUTE);
- LOG.initializingForResourceRole(resourceRole);
- haProvider = HaServletContextListener.getHaProvider(filterConfig.getServletContext());
- HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(resourceRole);
- maxFailoverAttempts = serviceConfig.getMaxFailoverAttempts();
- failoverSleep = serviceConfig.getFailoverSleep();
- maxRetryAttempts = serviceConfig.getMaxRetryAttempts();
- retrySleep = serviceConfig.getRetrySleep();
+ public void init() {
+ super.init();
+ if (haProvider != null) {
+ HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(RESOURCE_ROLE);
+ maxFailoverAttempts = serviceConfig.getMaxFailoverAttempts();
+ failoverSleep = serviceConfig.getFailoverSleep();
+ maxRetryAttempts = serviceConfig.getMaxRetryAttempts();
+ retrySleep = serviceConfig.getRetrySleep();
+ }
}
- @Override
+ public HaProvider getHaProvider() {
+ return haProvider;
+ }
+
+ @Configure
+ public void setHaProvider(HaProvider haProvider) {
+ this.haProvider = haProvider;
+ }
+
+ @Override
protected void executeRequest(HttpUriRequest outboundRequest, HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) throws IOException {
HttpResponse inboundResponse = null;
try {
@@ -126,7 +134,7 @@ public class WebHdfsHaHttpClientDispatch extends HdfsDispatch {
}
inboundRequest.setAttribute(FAILOVER_COUNTER_ATTRIBUTE, counter);
if (counter.incrementAndGet() <= maxFailoverAttempts) {
- haProvider.markFailedURL(resourceRole, outboundRequest.getURI().toString());
+ haProvider.markFailedURL(RESOURCE_ROLE, outboundRequest.getURI().toString());
//null out target url so that rewriters run again
inboundRequest.setAttribute(AbstractGatewayFilter.TARGET_REQUEST_URL_ATTRIBUTE_NAME, null);
URI uri = getDispatchUrl(inboundRequest);
@@ -135,12 +143,12 @@ public class WebHdfsHaHttpClientDispatch extends HdfsDispatch {
try {
Thread.sleep(failoverSleep);
} catch (InterruptedException e) {
- LOG.failoverSleepFailed(resourceRole, e);
+ LOG.failoverSleepFailed(RESOURCE_ROLE, e);
}
}
executeRequest(outboundRequest, inboundRequest, outboundResponse);
} else {
- LOG.maxFailoverAttemptsReached(maxFailoverAttempts, resourceRole);
+ LOG.maxFailoverAttemptsReached(maxFailoverAttempts, RESOURCE_ROLE);
if (inboundResponse != null) {
writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse, inboundResponse);
} else {
@@ -161,12 +169,12 @@ public class WebHdfsHaHttpClientDispatch extends HdfsDispatch {
try {
Thread.sleep(retrySleep);
} catch (InterruptedException e) {
- LOG.retrySleepFailed(resourceRole, e);
+ LOG.retrySleepFailed(RESOURCE_ROLE, e);
}
}
executeRequest(outboundRequest, inboundRequest, outboundResponse);
} else {
- LOG.maxRetryAttemptsReached(maxRetryAttempts, resourceRole, outboundRequest.getURI().toString());
+ LOG.maxRetryAttemptsReached(maxRetryAttempts, RESOURCE_ROLE, outboundRequest.getURI().toString());
if (inboundResponse != null) {
writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse, inboundResponse);
} else {
@@ -174,4 +182,16 @@ public class WebHdfsHaHttpClientDispatch extends HdfsDispatch {
}
}
}
+
+ private static URI getDispatchUrl(HttpServletRequest request) {
+ StringBuffer str = request.getRequestURL();
+ String query = request.getQueryString();
+ if ( query != null ) {
+ str.append('?');
+ str.append(query);
+ }
+ URI url = URI.create(str.toString());
+ return url;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhdfs/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor b/gateway-service-webhdfs/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
deleted file mode 100644
index 6fde03f..0000000
--- a/gateway-service-webhdfs/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
+++ /dev/null
@@ -1,20 +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.
-##########################################################################
-
-org.apache.hadoop.gateway.hdfs.NameNodeHaDispatchDeploymentContributor
-org.apache.hadoop.gateway.hdfs.WebHdfsDispatchDeploymentContributor
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhdfs/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor b/gateway-service-webhdfs/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
index 0a3d6ee..d918906 100644
--- a/gateway-service-webhdfs/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
+++ b/gateway-service-webhdfs/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
@@ -16,6 +16,5 @@
# limitations under the License.
##########################################################################
-org.apache.hadoop.gateway.hdfs.WebHdfsDeploymentContributor
org.apache.hadoop.gateway.hdfs.NameNodeDeploymentContributor
org.apache.hadoop.gateway.hdfs.JobTrackerDeploymentContributor
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/NameNodeHaDispatchDeploymentContributorTest.java
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/NameNodeHaDispatchDeploymentContributorTest.java b/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/NameNodeHaDispatchDeploymentContributorTest.java
deleted file mode 100644
index 596ac81..0000000
--- a/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/NameNodeHaDispatchDeploymentContributorTest.java
+++ /dev/null
@@ -1,44 +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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.hdfs;
-
-import org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor;
-import org.junit.Test;
-
-import java.util.Iterator;
-import java.util.ServiceLoader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
-
-public class NameNodeHaDispatchDeploymentContributorTest {
-
- @Test
- public void testServiceLoader() throws Exception {
- ServiceLoader loader = ServiceLoader.load( ProviderDeploymentContributor.class );
- Iterator iterator = loader.iterator();
- assertThat( "Service iterator empty.", iterator.hasNext() );
- while( iterator.hasNext() ) {
- Object object = iterator.next();
- if( object instanceof NameNodeHaDispatchDeploymentContributor) {
- return;
- }
- }
- fail( "Failed to find " + NameNodeHaDispatchDeploymentContributor.class.getName() + " via service loader." );
- }
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatchTest.java
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatchTest.java b/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatchTest.java
index ae861a9..757288f 100644
--- a/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatchTest.java
+++ b/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatchTest.java
@@ -27,6 +27,7 @@ import org.apache.hadoop.gateway.ha.provider.impl.DefaultHaServiceConfig;
import org.apache.hadoop.gateway.ha.provider.impl.HaDescriptorFactory;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
@@ -69,12 +70,11 @@ public class WebHdfsHaHttpClientDispatchTest {
EasyMock.expect(context.getAttribute(HaServletContextListener.PROVIDER_ATTRIBUTE_NAME)).andReturn(haProvider).anyTimes();
FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
EasyMock.expect(config.getServletContext()).andReturn(context).anyTimes();
- EasyMock.expect(config.getInitParameter( WebHdfsHaHttpClientDispatch.RESOURCE_ROLE_ATTRIBUTE )).andReturn("test-role").anyTimes();
EasyMock.expect(config.getInitParameter(EasyMock.anyObject(String.class))).andReturn(null).anyTimes();
InstrumentedWebHdfsHaHttpClientDispatch dispatch = new InstrumentedWebHdfsHaHttpClientDispatch();
EasyMock.replay(context,config);
- dispatch.init(config);
+ dispatch.init();
assertThat( dispatch.getAppCookieManager(), notNullValue() );
}
@@ -94,7 +94,6 @@ public class WebHdfsHaHttpClientDispatchTest {
FilterConfig filterConfig = EasyMock.createNiceMock(FilterConfig.class);
ServletContext servletContext = EasyMock.createNiceMock(ServletContext.class);
- EasyMock.expect(filterConfig.getInitParameter(WebHdfsHaHttpClientDispatch.RESOURCE_ROLE_ATTRIBUTE)).andReturn(serviceName).anyTimes();
EasyMock.expect(filterConfig.getServletContext()).andReturn(servletContext).anyTimes();
EasyMock.expect(servletContext.getAttribute(HaServletContextListener.PROVIDER_ATTRIBUTE_NAME)).andReturn(provider).anyTimes();
@@ -125,7 +124,9 @@ public class WebHdfsHaHttpClientDispatchTest {
EasyMock.replay(filterConfig, servletContext, outboundRequest, inboundRequest, outboundResponse);
Assert.assertEquals(uri1.toString(), provider.getActiveURL(serviceName));
WebHdfsHaHttpClientDispatch dispatch = new WebHdfsHaHttpClientDispatch();
- dispatch.init(filterConfig);
+ dispatch.setHttpClient(new DefaultHttpClient());
+ dispatch.setHaProvider(provider);
+ dispatch.init();
long startTime = System.currentTimeMillis();
try {
dispatch.executeRequest(outboundRequest, inboundRequest, outboundResponse);
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-yarn-rm/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-service-yarn-rm/pom.xml b/gateway-service-yarn-rm/pom.xml
deleted file mode 100644
index fc9db48..0000000
--- a/gateway-service-yarn-rm/pom.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.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.
--->
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.knox</groupId>
- <artifactId>gateway</artifactId>
- <version>0.6.0-SNAPSHOT</version>
- </parent>
- <artifactId>gateway-service-yarn-rm</artifactId>
- <name>gateway-service-yarn-rm</name>
- <description>The extension to the gateway for supporting YARN Resource Manager REST API.</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>${gateway-group}</groupId>
- <artifactId>gateway-test-utils</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-yarn-rm/src/main/java/org/apache/hadoop/gateway/yarn/rm/ResourceManagerDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-service-yarn-rm/src/main/java/org/apache/hadoop/gateway/yarn/rm/ResourceManagerDeploymentContributor.java b/gateway-service-yarn-rm/src/main/java/org/apache/hadoop/gateway/yarn/rm/ResourceManagerDeploymentContributor.java
deleted file mode 100644
index 21e1b2e..0000000
--- a/gateway-service-yarn-rm/src/main/java/org/apache/hadoop/gateway/yarn/rm/ResourceManagerDeploymentContributor.java
+++ /dev/null
@@ -1,150 +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.yarn.rm;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-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.UrlRewriteRulesDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptorFactory;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteServletFilter;
-import org.apache.hadoop.gateway.topology.Service;
-
-public class ResourceManagerDeploymentContributor extends
- ServiceDeploymentContributorBase {
- private static final String RULES_RESOURCE = ResourceManagerDeploymentContributor.class
- .getName().replace( '.', '/' ) + "/rewrite.xml";
- private static final String EXTERNAL_PATH = "/resourcemanager";
- private static final String PROXY_PATH = "/resourcemanager/proxy";
-
- @Override
- public String getRole() {
- return "RESOURCEMANAGER";
- }
-
- @Override
- public String getName() {
- return "resourcemanager";
- }
-
- @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, IOException {
- UrlRewriteRulesDescriptor serviceRules = loadRulesFromClassPath();
- UrlRewriteRulesDescriptor clusterRules = context.getDescriptor( "rewrite" );
- clusterRules.addRules( serviceRules );
- }
-
- private UrlRewriteRulesDescriptor loadRulesFromClassPath() throws IOException {
- InputStream stream = this.getClass().getClassLoader()
- .getResourceAsStream( RULES_RESOURCE );
- Reader reader = new InputStreamReader( stream );
- UrlRewriteRulesDescriptor rules = UrlRewriteRulesDescriptorFactory.load(
- "xml", reader );
- reader.close();
- stream.close();
- return rules;
- }
-
- private void contributeResources(DeploymentContext context, Service service)
- throws URISyntaxException {
- Map<String, String> filterParams = new HashMap<String, String>();
-
- contributeResource( context, service, EXTERNAL_PATH + "/v1/cluster/", null );
-
- contributeResource( context, service, EXTERNAL_PATH + "/v1/cluster/**?**", null );
-
- filterParams.clear();
- filterParams.put( UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM, getQualifiedName() + "/apps/outbound" );
- contributeResource( context, service, EXTERNAL_PATH + "/v1/cluster/apps?**", filterParams );
-
- filterParams.clear();
- filterParams.put( UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM, getQualifiedName() + "/app/outbound" );
- contributeResource( context, service, EXTERNAL_PATH + "/v1/cluster/apps/*?**", filterParams );
-
- filterParams.clear();
- filterParams.put( UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM, getQualifiedName() + "/appattempts/outbound" );
- contributeResource( context, service, EXTERNAL_PATH + "/v1/cluster/apps/*/appattempts?**", filterParams );
-
- filterParams.clear();
- filterParams.put( UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM, getQualifiedName() + "/nodes/outbound" );
- contributeResource( context, service, EXTERNAL_PATH + "/v1/cluster/nodes?**", filterParams );
-
- filterParams.clear();
- filterParams.put( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM, getQualifiedName() + "/nodeId/inbound" );
- filterParams.put( UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM, getQualifiedName() + "/node/outbound" );
- contributeResource( context, service, EXTERNAL_PATH + "/v1/cluster/nodes/*?**", filterParams );
-
- filterParams.clear();
- filterParams.put( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM, getQualifiedName() + "/inbound/proxy" );
- contributeResource( context, service, PROXY_PATH + "/*/ws/v1/**?**", filterParams );
-
- filterParams.clear();
- filterParams.put( UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM, getQualifiedName() + "/proxy/jobattempts/outbound" );
- contributeResource( context, service, PROXY_PATH + "/*/ws/v1/mapreduce/jobs/*/jobattempts", filterParams );
-
-
- filterParams.clear();
- filterParams.put( UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM, getQualifiedName() + "/proxy/taskattempts/outbound" );
- contributeResource( context, service, PROXY_PATH + "/*/ws/v1/mapreduce/jobs/*/tasks/*/attempts", filterParams );
-
- filterParams.clear();
- filterParams.put( UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM, getQualifiedName() + "/proxy/taskattempt/outbound" );
- contributeResource( context, service, PROXY_PATH + "/*/ws/v1/mapreduce/jobs/*/tasks/*/attempts/*", filterParams );
- }
-
- private void contributeResource( DeploymentContext context, Service service, String pattern, Map<String, String> filterParams ) throws URISyntaxException {
- List<FilterParamDescriptor> params = new ArrayList<FilterParamDescriptor>();
- ResourceDescriptor resource = context.getGatewayDescriptor().addResource();
- resource.role( service.getRole() );
- resource.pattern( pattern );
- addWebAppSecFilters( context, service, resource );
- addAuthenticationFilter( context, service, resource );
- addIdentityAssertionFilter( context, service, resource );
- addAuthorizationFilter( context, service, resource );
- if ( filterParams != null ) {
- for( Entry<String, String> filterParam : filterParams.entrySet() ) {
- params.add( resource.createFilterParam().name( filterParam.getKey() ).value( filterParam.getValue() ) );
- }
- }
- addRewriteFilter( context, service, resource, params );
- addDispatchFilter( context, service, resource, "dispatch", "http-client" );
- }
-
- private String getQualifiedName() {
- return getRole() + "/" + getName();
- }
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-yarn-rm/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
----------------------------------------------------------------------
diff --git a/gateway-service-yarn-rm/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor b/gateway-service-yarn-rm/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
deleted file mode 100644
index 3db76c7..0000000
--- a/gateway-service-yarn-rm/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
+++ /dev/null
@@ -1,19 +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.
-##########################################################################
-
-org.apache.hadoop.gateway.yarn.rm.ResourceManagerDeploymentContributor
\ No newline at end of file