Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2014-11-20 10:13:06 -0500
committerSimone Bordet2014-11-20 11:06:10 -0500
commitf7df8f9244319d48e64c28c0311765780ddaae9e (patch)
tree8cff43be8a4678cb46e8e8bd45ec0e7b89cf6c10
parent8330fa73e03e3489c18a6818007e58c8a3a1def0 (diff)
downloadorg.eclipse.jetty.project-f7df8f9244319d48e64c28c0311765780ddaae9e.tar.gz
org.eclipse.jetty.project-f7df8f9244319d48e64c28c0311765780ddaae9e.tar.xz
org.eclipse.jetty.project-f7df8f9244319d48e64c28c0311765780ddaae9e.zip
452516 - Make HttpOutput aggregation size configurable.
Introduced new property "outputAggregationSize" in HttpConfiguration, and correspondent property in XML file.
-rw-r--r--jetty-server/src/main/config/etc/jetty.xml1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java52
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java9
3 files changed, 46 insertions, 16 deletions
diff --git a/jetty-server/src/main/config/etc/jetty.xml b/jetty-server/src/main/config/etc/jetty.xml
index 4c1fb5e559..d8708ef417 100644
--- a/jetty-server/src/main/config/etc/jetty.xml
+++ b/jetty-server/src/main/config/etc/jetty.xml
@@ -80,6 +80,7 @@
<Set name="secureScheme">https</Set>
<Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set>
<Set name="outputBufferSize"><Property name="jetty.output.buffer.size" default="32768" /></Set>
+ <Set name="outputAggregationSize"><Property name="jetty.output.aggregation.size" default="8192" /></Set>
<Set name="requestHeaderSize"><Property name="jetty.request.header.size" default="8192" /></Set>
<Set name="responseHeaderSize"><Property name="jetty.response.header.size" default="8192" /></Set>
<Set name="sendServerVersion"><Property name="jetty.send.server.version" default="true" /></Set>
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java
index 8a6b52e876..e68102e93e 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java
@@ -45,6 +45,7 @@ public class HttpConfiguration
private List<Customizer> _customizers=new CopyOnWriteArrayList<>();
private int _outputBufferSize=32*1024;
+ private int _outputAggregationSize=_outputBufferSize/4;
private int _requestHeaderSize=8*1024;
private int _responseHeaderSize=8*1024;
private int _headerCacheSize=512;
@@ -93,6 +94,7 @@ public class HttpConfiguration
{
_customizers.addAll(config._customizers);
_outputBufferSize=config._outputBufferSize;
+ _outputAggregationSize=config._outputAggregationSize;
_requestHeaderSize=config._requestHeaderSize;
_responseHeaderSize=config._responseHeaderSize;
_securePort=config._securePort;
@@ -138,6 +140,13 @@ public class HttpConfiguration
}
/* ------------------------------------------------------------ */
+ @ManagedAttribute("The maximum size in bytes for HTTP output to be aggregated")
+ public int getOutputAggregationSize()
+ {
+ return _outputAggregationSize;
+ }
+
+ /* ------------------------------------------------------------ */
@ManagedAttribute("The maximum allowed size in bytes for a HTTP request header")
public int getRequestHeaderSize()
{
@@ -231,9 +240,9 @@ public class HttpConfiguration
/**
* <p>Set the {@link Customizer}s that are invoked for every
* request received.</p>
- * <p>Customisers are often used to interpret optional headers (eg {@link ForwardedRequestCustomizer}) or
+ * <p>Customizers are often used to interpret optional headers (eg {@link ForwardedRequestCustomizer}) or
* optional protocol semantics (eg {@link SecureRequestCustomizer}).
- * @param customizers
+ * @param customizers the list of customizers
*/
public void setCustomizers(List<Customizer> customizers)
{
@@ -255,6 +264,19 @@ public class HttpConfiguration
}
/* ------------------------------------------------------------ */
+ /**
+ * Set the max size of the response content write that is copied into the aggregate buffer.
+ * Writes that are smaller of this size are copied into the aggregate buffer, while
+ * writes that are larger of this size will cause the aggregate buffer to be flushed
+ * and the write to be executed without being copied.
+ * @param outputAggregationSize the max write size that is aggregated
+ */
+ public void setOutputAggregationSize(int outputAggregationSize)
+ {
+ _outputAggregationSize = outputAggregationSize;
+ }
+
+ /* ------------------------------------------------------------ */
/** Set the maximum size of a request header.
* <p>Larger headers will allow for more and/or larger cookies plus larger form content encoded
* in a URL. However, larger headers consume more memory and can make a server more vulnerable to denial of service
@@ -288,28 +310,32 @@ public class HttpConfiguration
}
/* ------------------------------------------------------------ */
- /** Set the TCP/IP port used for CONFIDENTIAL and INTEGRAL
- * redirections.
- * @param confidentialPort
+ /** Set the TCP/IP port used for CONFIDENTIAL and INTEGRAL redirections.
+ * @param securePort the secure port to redirect to.
*/
- public void setSecurePort(int confidentialPort)
+ public void setSecurePort(int securePort)
{
- _securePort = confidentialPort;
+ _securePort = securePort;
}
/* ------------------------------------------------------------ */
- /** Set the URI scheme used for CONFIDENTIAL and INTEGRAL
- * redirections.
- * @param confidentialScheme A string like"https"
+ /** Set the URI scheme used for CONFIDENTIAL and INTEGRAL redirections.
+ * @param secureScheme A scheme string like "https"
*/
- public void setSecureScheme(String confidentialScheme)
+ public void setSecureScheme(String secureScheme)
{
- _secureScheme = confidentialScheme;
+ _secureScheme = secureScheme;
}
@Override
public String toString()
{
- return String.format("%s@%x{%d,%d/%d,%s://:%d,%s}",this.getClass().getSimpleName(),hashCode(),_outputBufferSize,_requestHeaderSize,_responseHeaderSize,_secureScheme,_securePort,_customizers);
+ return String.format("%s@%x{%d/%d,%d/%d,%s://:%d,%s}",
+ this.getClass().getSimpleName(),
+ hashCode(),
+ _outputBufferSize, _outputAggregationSize,
+ _requestHeaderSize,_responseHeaderSize,
+ _secureScheme,_securePort,
+ _customizers);
}
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
index b106162626..d977fbc207 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
@@ -24,8 +24,10 @@ import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritePendingException;
import java.util.concurrent.atomic.AtomicReference;
-
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
import javax.servlet.WriteListener;
import org.eclipse.jetty.http.HttpContent;
@@ -85,8 +87,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
public HttpOutput(HttpChannel<?> channel)
{
_channel = channel;
- _bufferSize = _channel.getHttpConfiguration().getOutputBufferSize();
- _commitSize=_bufferSize/4;
+ HttpConfiguration config = channel.getHttpConfiguration();
+ _bufferSize = config.getOutputBufferSize();
+ _commitSize = config.getOutputAggregationSize();
}
public HttpChannel<?> getHttpChannel()

Back to the top