Author: fhanik
Date: Wed Oct 8 16:28:51 2008
New Revision: 703017
URL: http://svn.apache.org/viewvc?rev=703017&view=rev
Log:
Expose all socket settings available for the JIO connector, buffer size can
make large differences, but they are hidden
Make settings consistent with those for the NIO connector, so switching between
Java connectors is seamless
Modified:
tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
tomcat/trunk/webapps/docs/config/http.xml
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java?rev=703017&r1=703016&r2=703017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java Wed Oct 8
16:28:51 2008
@@ -123,8 +123,12 @@
/**
* Set a property.
*/
- public void setProperty(String name, String value) {
+ public boolean setProperty(String name, String value) {
setAttribute(name, value);
+ if (name.startsWith("socket.")) {
+ return endpoint.setProperty(name, value);
+ }
+ return true;
}
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=703017&r1=703016&r2=703017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Wed Oct 8
16:28:51 2008
@@ -26,6 +26,7 @@
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.IntrospectionUtils;
import org.apache.tomcat.util.res.StringManager;
/**
@@ -127,11 +128,32 @@
* Associated server socket.
*/
protected ServerSocket serverSocket = null;
+
+ /**
+ * Holds all the socket properties
+ */
+ protected SocketProperties socketProperties = new SocketProperties();
// ------------------------------------------------------------- Properties
-
+ /**
+ * Generic properties - currently only socket.XXX properties
+ */
+ public boolean setProperty(String name, String value) {
+ final String socketName = "socket.";
+ try {
+ if (name.startsWith(socketName)) {
+ return IntrospectionUtils.setProperty(socketProperties,
name.substring(socketName.length()), value);
+ } else {
+ return IntrospectionUtils.setProperty(this,name,value);
+ }
+ }catch ( Exception x ) {
+ log.error("Unable to set attribute \""+name+"\" to
\""+value+"\"",x);
+ return false;
+ }
+ }
+
/**
* Acceptor thread count.
*/
@@ -201,25 +223,30 @@
/**
* Socket TCP no delay.
*/
- protected boolean tcpNoDelay = false;
- public boolean getTcpNoDelay() { return tcpNoDelay; }
- public void setTcpNoDelay(boolean tcpNoDelay) { this.tcpNoDelay =
tcpNoDelay; }
+ public boolean getTcpNoDelay() { return socketProperties.getTcpNoDelay(); }
+ public void setTcpNoDelay(boolean tcpNoDelay) {
socketProperties.setTcpNoDelay(tcpNoDelay); }
/**
* Socket linger.
*/
- protected int soLinger = 100;
- public int getSoLinger() { return soLinger; }
- public void setSoLinger(int soLinger) { this.soLinger = soLinger; }
+ public int getSoLinger() {return socketProperties.getSoLingerTime();}
+ public void setSoLinger(int soLinger) {
+ if (soLinger>=0) {
+ socketProperties.setSoLingerOn(true);
+ socketProperties.setSoLingerTime(soLinger);
+ } else {
+ socketProperties.setSoLingerOn(false);
+ socketProperties.setSoLingerTime(-1);
+ }
+ }
/**
* Socket timeout.
*/
- protected int soTimeout = -1;
- public int getSoTimeout() { return soTimeout; }
- public void setSoTimeout(int soTimeout) { this.soTimeout = soTimeout; }
+ public int getSoTimeout() { return socketProperties.getSoTimeout(); }
+ public void setSoTimeout(int soTimeout) {
socketProperties.setSoTimeout(soTimeout); }
/**
@@ -617,16 +644,7 @@
try {
// 1: Set socket options: timeout, linger, etc
- if (soLinger >= 0) {
- socket.setSoLinger(true, soLinger);
- }
- if (tcpNoDelay) {
- socket.setTcpNoDelay(tcpNoDelay);
- }
- if (soTimeout > 0) {
- socket.setSoTimeout(soTimeout);
- }
-
+ socketProperties.setProperties(socket);
// 2: SSL handshake
step = 2;
serverSocketFactory.handshake(socket);
Modified: tomcat/trunk/webapps/docs/config/http.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/http.xml?rev=703017&r1=703016&r2=703017&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/http.xml (original)
+++ tomcat/trunk/webapps/docs/config/http.xml Wed Oct 8 16:28:51 2008
@@ -383,6 +383,52 @@
</attribute>
</attributes>
+ <subsection name="Java TCP socket attributes">
+
+ <attribute name="socket.rxBufSize" required="false">
+ <p>(int)The socket receive buffer (SO_RCVBUF) size in bytes. Default
value is <code>25188</code></p>
+ </attribute>
+ <attribute name="socket.txBufSize" required="false">
+ <p>(int)The socket send buffer (SO_SNDBUF) size in bytes. Default
value is <code>43800</code></p>
+ </attribute>
+ <attribute name="socket.tcpNoDelay" required="false">
+ <p>(bool)same as the standard setting <code>tcpNoDelay</code>. Default
value is <code>false</code></p>
+ </attribute>
+ <attribute name="socket.soKeepAlive" required="false">
+ <p>(bool)Boolean value for the socket's keep alive setting
(SO_KEEPALIVE). Default is <code>false</code>. </p>
+ </attribute>
+ <attribute name="socket.ooBInline" required="false">
+ <p>(bool)Boolean value for the socket OOBINLINE setting. Default value
is <code>true</code></p>
+ </attribute>
+ <attribute name="socket.soReuseAddress" required="false">
+ <p>(bool)Boolean value for the sockets reuse address option
(SO_REUSEADDR). Default value is <code>true</code></p>
+ </attribute>
+ <attribute name="socket.soLingerOn" required="false">
+ <p>(bool)Boolean value for the sockets so linger option (SO_LINGER).
Default value is <code>true</code>.
+ This option is paired with the <code>soLingerTime</code> value.</p>
+ </attribute>
+ <attribute name="socket.soLingerTime" required="false">
+ <p>(bool)Value in seconds for the sockets so linger option
(SO_LINGER). Default value is <code>25</code> seconds.
+ This option is paired with the soLinger value.</p>
+ </attribute>
+ <attribute name="socket.soTimeout" required="false">
+ <p>(int)Value in milliseconds for the sockets read timeout
(SO_TIMEOUT). Default value is <code>5000</code> milliseconds.</p>
+ </attribute>
+ <attribute name="socket.soTrafficClass" required="false">
+ <p>(byte)Value between <code>0</code> and <code>255</code> for the
traffic class on the socket, <code>0x04 | 0x08 | 0x010</code></p>
+ </attribute>
+ <attribute name="socket.performanceConnectionTime" required="false">
+ <p>(int)The first value for the performance settings. Default is
<code>1</code>, see <a
href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setPerformancePreferences(int,%20int,%20int)">Socket
Performance Options</a></p>
+ </attribute>
+ <attribute name="socket.performanceLatency" required="false">
+ <p>(int)The second value for the performance settings. Default is
<code>0</code>, see <a
href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setPerformancePreferences(int,%20int,%20int)">Socket
Performance Options</a></p>
+ </attribute>
+ <attribute name="socket.performanceBandwidth" required="false">
+ <p>(int)The third value for the performance settings. Default is
<code>1</code>, see <a
href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setPerformancePreferences(int,%20int,%20int)">Socket
Performance Options</a></p>
+ </attribute>
+
+
+ </subsection>
</subsection>
@@ -458,12 +504,6 @@
<br/>When you are using direct buffers, make sure you allocate the
appropriate amount of memory for the
direct memory space. On Sun's JDK that would be something like
<code>-XX:MaxDirectMemorySize=256m</code></p>
</attribute>
- <attribute name="socket.rxBufSize" required="false">
- <p>(int)The socket receive buffer (SO_RCVBUF) size in bytes. Default
value is <code>25188</code></p>
- </attribute>
- <attribute name="socket.txBufSize" required="false">
- <p>(int)The socket send buffer (SO_SNDBUF) size in bytes. Default
value is <code>43800</code></p>
- </attribute>
<attribute name="socket.appReadBufSize" required="false">
<p>(int)Each connection that is opened up in Tomcat get associated
with a read and a write ByteBuffer
This attribute controls the size of these buffers. By default this
read buffer is sized at <code>8192</code> bytes.
@@ -511,41 +551,6 @@
The default is <code>500</code>.
Other values are <code>-1</code>. unlimited cache, and
<code>0</code>, no cache.</p>
</attribute>
- <attribute name="socket.tcpNoDelay" required="false">
- <p>(bool)same as the standard setting <code>tcpNoDelay</code>. Default
value is <code>false</code></p>
- </attribute>
- <attribute name="socket.soKeepAlive" required="false">
- <p>(bool)Boolean value for the socket's keep alive setting
(SO_KEEPALIVE). Default is <code>false</code>. </p>
- </attribute>
- <attribute name="socket.ooBInline" required="false">
- <p>(bool)Boolean value for the socket OOBINLINE setting. Default value
is <code>true</code></p>
- </attribute>
- <attribute name="socket.soReuseAddress" required="false">
- <p>(bool)Boolean value for the sockets reuse address option
(SO_REUSEADDR). Default value is <code>true</code></p>
- </attribute>
- <attribute name="socket.soLingerOn" required="false">
- <p>(bool)Boolean value for the sockets so linger option (SO_LINGER).
Default value is <code>true</code>.
- This option is paired with the <code>soLingerTime</code> value.</p>
- </attribute>
- <attribute name="socket.soLingerTime" required="false">
- <p>(bool)Value in seconds for the sockets so linger option
(SO_LINGER). Default value is <code>25</code> seconds.
- This option is paired with the soLinger value.</p>
- </attribute>
- <attribute name="socket.soTimeout" required="false">
- <p>(int)Value in milliseconds for the sockets read timeout
(SO_TIMEOUT). Default value is <code>5000</code> milliseconds.</p>
- </attribute>
- <attribute name="socket.soTrafficClass" required="false">
- <p>(byte)Value between <code>0</code> and <code>255</code> for the
traffic class on the socket, <code>0x04 | 0x08 | 0x010</code></p>
- </attribute>
- <attribute name="socket.performanceConnectionTime" required="false">
- <p>(int)The first value for the performance settings. Default is
<code>1</code>, see <a
href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setPerformancePreferences(int,%20int,%20int)">Socket
Performance Options</a></p>
- </attribute>
- <attribute name="socket.performanceLatency" required="false">
- <p>(int)The second value for the performance settings. Default is
<code>0</code>, see <a
href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setPerformancePreferences(int,%20int,%20int)">Socket
Performance Options</a></p>
- </attribute>
- <attribute name="socket.performanceBandwidth" required="false">
- <p>(int)The third value for the performance settings. Default is
<code>1</code>, see <a
href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setPerformancePreferences(int,%20int,%20int)">Socket
Performance Options</a></p>
- </attribute>
<attribute name="selectorPool.maxSelectors" required="false">
<p>(int)The max selectors to be used in the pool, to reduce selector
contention.
Use this option when the command line
<code>org.apache.tomcat.util.net.NioSelectorShared</code> value is set to false.
@@ -738,10 +743,10 @@
Classname Http11Protocol Http11NioProtocol
Http11AprProtocol
Tomcat Version 3.x 4.x 5.x 6.x 6.x
5.5.x 6.x
Support Polling NO YES
YES
- Polling Size N/A Unlimited - Restricted by mem
Unlimited
- Read HTTP Request Blocking Blocking
Blocking
- Read HTTP Body Blocking Blocking
Blocking
- Write HTTP Response Blocking Blocking
Blocking
+ Polling Size N/A Unlimited - Restricted by mem
Unlimited - Configurable
+ Read HTTP Request Blocking Non Blocking
Blocking
+ Read HTTP Body Blocking Sim Blocking
Blocking
+ Write HTTP Response Blocking Sim Blocking
Blocking
SSL Support Java SSL Java SSL
OpenSSL
SSL Handshake Blocking Non blocking
Blocking
Max Connections maxThreads See polling size
See polling size
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]