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-716 replayBufferSize is kept in bytes
Date Wed, 25 May 2016 19:48:42 GMT
Repository: knox
Updated Branches:
  refs/heads/master 98057fd20 -> d88194a26


KNOX-716 replayBufferSize is kept in bytes


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

Branch: refs/heads/master
Commit: d88194a2632b66445a6561e5937661d4d38bc274
Parents: 98057fd
Author: Sumit Gupta <sumit@apache.org>
Authored: Wed May 25 15:47:54 2016 -0400
Committer: Sumit Gupta <sumit@apache.org>
Committed: Wed May 25 15:47:54 2016 -0400

----------------------------------------------------------------------
 .../hadoop/gateway/dispatch/DefaultDispatch.java  | 18 ++++++++++++++++--
 .../gateway/dispatch/DefaultDispatchTest.java     | 13 ++++++++++++-
 2 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/d88194a2/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 6c72fde..4b9e95d 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
@@ -49,9 +49,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 
 /**
@@ -69,6 +67,7 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
 
   private Set<String> outboundResponseExcludeHeaders;
 
+  //Buffer size in bytes
   private int replayBufferSize = -1;
 
   @Override
@@ -85,14 +84,29 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
   }
 
   protected int getReplayBufferSize() {
+    if (replayBufferSize > 0) {
+      return Math.abs(replayBufferSize/1024);
+    }
     return replayBufferSize;
   }
 
   @Configure
   protected void setReplayBufferSize(@Default("-1")int size) {
+    setReplayBufferSizeInBytes(size);
+  }
+
+  protected int getReplayBufferSizeInBytes() {
+    return replayBufferSize;
+  }
+
+  protected void setReplayBufferSizeInBytes(int size) {
+    if (size > 0) {
+      size *= 1024;
+    }
     replayBufferSize = size;
   }
 
+
   protected void executeRequest(
          HttpUriRequest outboundRequest,
          HttpServletRequest inboundRequest,

http://git-wip-us.apache.org/repos/asf/knox/blob/d88194a2/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 37451fd..c51fb1e 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
@@ -157,7 +157,7 @@ public class DefaultDispatchTest {
     ServletContext servletContext = EasyMock.createNiceMock( ServletContext.class );
     GatewayConfig gatewayConfig = EasyMock.createNiceMock( GatewayConfig.class );
     EasyMock.expect(gatewayConfig.isHadoopKerberosSecured()).andReturn( Boolean.TRUE ).anyTimes();
-    EasyMock.expect(gatewayConfig.getHttpServerRequestBuffer()).andReturn( 16 ).anyTimes();
+    EasyMock.expect(gatewayConfig.getHttpServerRequestBuffer()).andReturn( 16384 ).anyTimes();
     EasyMock.expect( servletContext.getAttribute( GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE
) ).andReturn( gatewayConfig ).anyTimes();
     ServletInputStream inputStream = EasyMock.createNiceMock( ServletInputStream.class );
     HttpServletRequest inboundRequest = EasyMock.createNiceMock( HttpServletRequest.class
);
@@ -169,6 +169,17 @@ public class DefaultDispatchTest {
     assertTrue("not buffering in the absence of delegation token",
         (httpEntity instanceof PartiallyRepeatableHttpEntity));
     assertEquals(defaultDispatch.getReplayBufferSize(), 16);
+    assertEquals(defaultDispatch.getReplayBufferSizeInBytes(), 16384);
+
+    //also test normal setter and getters
+    defaultDispatch.setReplayBufferSize(-1);
+    assertEquals(defaultDispatch.getReplayBufferSizeInBytes(), -1);
+    assertEquals(defaultDispatch.getReplayBufferSize(), -1);
+
+    defaultDispatch.setReplayBufferSize(16);
+    assertEquals(defaultDispatch.getReplayBufferSizeInBytes(), 16384);
+    assertEquals(defaultDispatch.getReplayBufferSize(), 16);
+
   }
 
   @Test( timeout = TestUtils.SHORT_TIMEOUT )


Mime
View raw message