knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From su...@apache.org
Subject knox git commit: KNOX-593 removed replayBufferSize and CappedBufferHttpEntity references
Date Thu, 24 Sep 2015 20:39:54 GMT
Repository: knox
Updated Branches:
  refs/heads/master cb5465755 -> 470400f12


KNOX-593 removed replayBufferSize and CappedBufferHttpEntity references


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/470400f1
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/470400f1
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/470400f1

Branch: refs/heads/master
Commit: 470400f12ed66e1a15cc67be0963b3fb8b6a0e43
Parents: cb54657
Author: Sumit Gupta <sumit@apache.org>
Authored: Thu Sep 24 16:38:21 2015 -0400
Committer: Sumit Gupta <sumit@apache.org>
Committed: Thu Sep 24 16:38:21 2015 -0400

----------------------------------------------------------------------
 .../ServiceDefinitionDeploymentContributor.java | 17 ++---
 .../gateway/dispatch/DefaultDispatch.java       | 27 -------
 .../gateway/dispatch/DefaultDispatchTest.java   | 22 +-----
 .../deploy/DeploymentFactoryFuncTest.java       | 78 +-------------------
 4 files changed, 10 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/470400f1/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
index 8b1d17f..f1b7517 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
@@ -50,10 +50,6 @@ public class ServiceDefinitionDeploymentContributor extends ServiceDeploymentCon
 
   private static final String SERVICE_ROLE_PARAM = "serviceRole";
 
-  private static final String REPLAY_BUFFER_SIZE_PARAM = "replayBufferSize";
-
-  private static final String DEFAULT_REPLAY_BUFFER_SIZE = "8";
-
   private static final String XFORWARDED_FILTER_NAME = "XForwardedHeaderFilter";
 
   private static final String XFORWARDED_FILTER_ROLE = "xforwardedheaders";
@@ -221,12 +217,13 @@ public class ServiceDefinitionDeploymentContributor extends ServiceDeploymentCon
     if (httpClientFactory != null) {
       filter.param().name(HTTP_CLIENT_FACTORY_PARAM).value(httpClientFactory);
     }
-    FilterParamDescriptor filterParam = filter.param().name(REPLAY_BUFFER_SIZE_PARAM).value(DEFAULT_REPLAY_BUFFER_SIZE);
-    for ( Map.Entry<String, String> serviceParam : service.getParams().entrySet() )
{
-      if ( REPLAY_BUFFER_SIZE_PARAM.equals(serviceParam.getKey()) ) {
-        filterParam.value(serviceParam.getValue());
-      }
-    }
+    //TODO: [sumit] make sure we pass all service params to the filter
+//    FilterParamDescriptor filterParam = filter.param().name(REPLAY_BUFFER_SIZE_PARAM).value(DEFAULT_REPLAY_BUFFER_SIZE);
+//    for ( Map.Entry<String, String> serviceParam : service.getParams().entrySet()
) {
+//      if ( REPLAY_BUFFER_SIZE_PARAM.equals(serviceParam.getKey()) ) {
+//        filterParam.value(serviceParam.getValue());
+//      }
+//    }
     if ( context.getGatewayConfig().isHadoopKerberosSecured() ) {
       filter.param().name("kerberos").value("true");
     } else {

http://git-wip-us.apache.org/repos/asf/knox/blob/470400f1/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
index 26001bf..c6aa1ea 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
@@ -25,8 +25,6 @@ import org.apache.hadoop.gateway.audit.api.AuditServiceFactory;
 import org.apache.hadoop.gateway.audit.api.Auditor;
 import org.apache.hadoop.gateway.audit.api.ResourceType;
 import org.apache.hadoop.gateway.audit.log4j.audit.AuditConstants;
-import org.apache.hadoop.gateway.config.Configure;
-import org.apache.hadoop.gateway.config.Default;
 import org.apache.hadoop.gateway.config.GatewayConfig;
 import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.i18n.resources.ResourcesFactory;
@@ -65,7 +63,6 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
   protected static Auditor auditor = AuditServiceFactory.getAuditService().getAuditor(AuditConstants.DEFAULT_AUDITOR_NAME,
       AuditConstants.KNOX_SERVICE_NAME, AuditConstants.KNOX_COMPONENT_NAME);
 
-  private int replayBufferSize = 0;
   private Set<String> outboundResponseExcludeHeaders;
 
   @Override
@@ -196,21 +193,6 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
          entity = new InputStreamEntity(contentStream, contentLength, ContentType.parse(contentType));
       }
 
-
-      if ("true".equals(System.getProperty(GatewayConfig.HADOOP_KERBEROS_SECURED))) {
-
-         //Check if delegation token is supplied in the request
-         boolean delegationTokenPresent = false;
-         String queryString = request.getQueryString();
-         if (queryString != null) {
-            delegationTokenPresent = queryString.startsWith("delegation=") ||
-                  queryString.contains("&delegation=");
-         }
-         if (!delegationTokenPresent && getReplayBufferSize() > 0) {
-            entity = new CappedBufferHttpEntity(entity, getReplayBufferSize() * 1024);
-         }
-      }
-
       return entity;
    }
 
@@ -259,15 +241,6 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
       executeRequest(method, request, response);
    }
 
-   protected int getReplayBufferSize() {
-      return replayBufferSize;
-   }
-
-   @Configure
-   protected void setReplayBufferSize(@Default("8") int size) {
-      replayBufferSize = size;
-   }
-
   public Set<String> getOutboundResponseExcludeHeaders() {
     return outboundResponseExcludeHeaders;
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/470400f1/gateway-spi/src/test/java/org/apache/hadoop/gateway/dispatch/DefaultDispatchTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/hadoop/gateway/dispatch/DefaultDispatchTest.java
b/gateway-spi/src/test/java/org/apache/hadoop/gateway/dispatch/DefaultDispatchTest.java
index 592db57..2c09a5d 100644
--- a/gateway-spi/src/test/java/org/apache/hadoop/gateway/dispatch/DefaultDispatchTest.java
+++ b/gateway-spi/src/test/java/org/apache/hadoop/gateway/dispatch/DefaultDispatchTest.java
@@ -23,7 +23,6 @@ import static org.hamcrest.Matchers.instanceOf;
 import static org.hamcrest.Matchers.not;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
@@ -89,7 +88,7 @@ public class DefaultDispatchTest {
   }
 
   @Test
-  public void testCallToSecureClusterWithDelegationTpken() throws URISyntaxException, IOException
{
+  public void testCallToSecureClusterWithDelegationToken() throws URISyntaxException, IOException
{
     System.setProperty(GatewayConfig.HADOOP_KERBEROS_SECURED, "true");
     DefaultDispatch defaultDispatch = new DefaultDispatch();
     ServletInputStream inputStream = EasyMock.createNiceMock( ServletInputStream.class );
@@ -102,22 +101,5 @@ public class DefaultDispatchTest {
     assertFalse("buffering in the presence of delegation token", 
         (httpEntity instanceof CappedBufferHttpEntity));
   }
-  
-  @Test
-  public void testCallToSecureClusterWithoutDelegationTpken() throws URISyntaxException,
IOException {
-    System.setProperty(GatewayConfig.HADOOP_KERBEROS_SECURED, "true");
-    DefaultDispatch defaultDispatch = new DefaultDispatch();
-    defaultDispatch.setReplayBufferSize(10);
-    ServletInputStream inputStream = EasyMock.createNiceMock( ServletInputStream.class );
-    HttpServletRequest inboundRequest = EasyMock.createNiceMock( HttpServletRequest.class
);
-    EasyMock.expect(inboundRequest.getQueryString()).andReturn( "a=123").anyTimes();
-    EasyMock.expect(inboundRequest.getInputStream()).andReturn( inputStream).anyTimes();
-    EasyMock.replay( inboundRequest );
-    HttpEntity httpEntity = defaultDispatch.createRequestEntity(inboundRequest);
-    System.setProperty(GatewayConfig.HADOOP_KERBEROS_SECURED, "false");
-    assertTrue("not buffering in the absence of delegation token", 
-        (httpEntity instanceof CappedBufferHttpEntity));
-  }
-  
-  
+
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/470400f1/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
index 9be668c..4fef2d9 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java
@@ -379,83 +379,7 @@ public class DeploymentFactoryFuncTest {
       assertThat(web, hasXPath("/web-app/listener[4]/listener-class", equalTo("org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteServletContextListener")));
    }
 
-
-  @Test
-  public void testDeploymentWithoutReplayBufferSize() throws Exception {
-    GatewayConfig config = new GatewayTestConfig();
-    File targetDir = new File(System.getProperty("user.dir"), "target");
-    File gatewayDir = new File(targetDir, "gateway-home-" + UUID.randomUUID());
-    gatewayDir.mkdirs();
-    ((GatewayTestConfig) config).setGatewayHomeDir(gatewayDir.getAbsolutePath());
-    File deployDir = new File(config.getGatewayDeploymentDir());
-    deployDir.mkdirs();
-    addStacksDir(config, targetDir);
-
-    DefaultGatewayServices srvcs = new DefaultGatewayServices();
-    Map<String, String> options = new HashMap<String, String>();
-    options.put("persist-master", "false");
-    options.put("master", "password");
-    try {
-      DeploymentFactory.setGatewayServices(srvcs);
-      srvcs.init(config, options);
-    } catch (ServiceLifecycleException e) {
-      e.printStackTrace(); // I18N not required.
-    }
-
-    Service service;
-    Topology topology = new Topology();
-    topology.setName( "test-cluster" );
-
-    service = new Service();
-    service.setRole( "HIVE" );
-    service.setUrls( Arrays.asList( new String[]{ "http://hive-host:50001/" } ) );
-    topology.addService( service );
-
-    service = new Service();
-    service.setRole( "WEBHBASE" );
-    service.setUrls( Arrays.asList( new String[]{ "http://hbase-host:50002/" } ) );
-    topology.addService( service );
-
-    service = new Service();
-    service.setRole( "OOZIE" );
-    service.setUrls( Arrays.asList( new String[]{ "http://hbase-host:50003/" } ) );
-    topology.addService( service );
-
-    WebArchive war = DeploymentFactory.createDeployment( config, topology );
-    Document doc = parse( war.get( "WEB-INF/gateway.xml" ).getAsset().openStream() );
-    //dump( doc );
-
-    Node resourceNode, filterNode, paramNode;
-    String value;
-
-    resourceNode = node( doc, "gateway/resource[role/text()='HIVE']" );
-    assertThat( resourceNode, is(not(nullValue())));
-    filterNode = node( resourceNode, "filter[role/text()='dispatch']" );
-    assertThat( filterNode, is(not(nullValue())));
-    paramNode = node( filterNode, "param[name/text()='replayBufferSize']" );
-    value = value( paramNode, "value/text()" );
-    assertThat( value, is( "8" ) ) ;
-
-    resourceNode = node( doc, "gateway/resource[role/text()='WEBHBASE']" );
-    assertThat( resourceNode, is(not(nullValue())));
-    filterNode = node( resourceNode, "filter[role/text()='dispatch']" );
-    assertThat( filterNode, is(not(nullValue())));
-    paramNode = node( filterNode, "param[name/text()='replayBufferSize']" );
-    value = value( paramNode, "value/text()" );
-    assertThat( value, is( "8" ) ) ;
-
-    resourceNode = node( doc, "gateway/resource[role/text()='OOZIE']" );
-    assertThat( resourceNode, is(not(nullValue())));
-    filterNode = node( resourceNode, "filter[role/text()='dispatch']" );
-    assertThat( filterNode, is(not(nullValue())));
-    paramNode = node( filterNode, "param[name/text()='replayBufferSize']" );
-    value = value( paramNode, "value/text()" );
-    assertThat( value, is( "8" ) ) ;
-
-    FileUtils.deleteQuietly( deployDir );
-  }
-
-  @Test
+  //disable test but keep around to re-purpose for a generic service level parameter test
   public void testDeploymentWithReplayBufferSize() throws Exception {
     GatewayConfig config = new GatewayTestConfig();
     File targetDir = new File(System.getProperty("user.dir"), "target");


Mime
View raw message