You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2005/12/29 20:23:44 UTC
svn commit: r359877 - in /jakarta/httpcomponents/trunk:
coyote-httpconnector/src/java/org/apache/http/coyote/
coyote-httpconnector/src/java/org/apache/http/coyote/impl/
coyote-httpconnector/src/java/org/apache/http/coyote/params/
coyote-httpconnector/s...
Author: olegk
Date: Thu Dec 29 11:23:22 2005
New Revision: 359877
URL: http://svn.apache.org/viewcvs?rev=359877&view=rev
Log:
Removed SO_SNDBUFFER and SO_RCVBUFFER parameters. Added socket buffer parameter
Modified:
jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java
jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java
jakarta/httpcomponents/trunk/coyote-httpconnector/src/tests/server.xml
jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/AbstractHttpConnection.java
jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/io/SocketHttpDataReceiver.java
jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/io/SocketHttpDataTransmitter.java
jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/params/HttpConnectionParams.java
Modified: jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java?rev=359877&r1=359876&r2=359877&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java (original)
+++ jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java Thu Dec 29 11:23:22 2005
@@ -94,12 +94,12 @@
CoyoteParams.setPort(this.params, port);
}
- public int getReadBuffer() {
- return CoyoteParams.getReadBuffer(this.params);
+ public int getSocketBuffer() {
+ return HttpConnectionParams.getSocketBufferSize(this.params);
}
- public void setReadBuffer(int port) {
- CoyoteParams.setReadBuffer(this.params, port);
+ public void setSocketBuffer(int buffersize) {
+ HttpConnectionParams.setSocketBufferSize(this.params, buffersize);
}
public int getMinThreads() {
Modified: jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java?rev=359877&r1=359876&r2=359877&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java (original)
+++ jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java Thu Dec 29 11:23:22 2005
@@ -73,6 +73,7 @@
import org.apache.http.impl.ConnectionReuseStrategy;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.message.BasicHttpResponse;
+import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.AbstractHttpProcessor;
import org.apache.http.protocol.ResponseConnControl;
@@ -139,7 +140,7 @@
this.coyoteres.setHook(this);
this.coyoteres.setRequest(this.coyotereq);
- int buffersize = CoyoteParams.getReadBuffer(this.params);
+ int buffersize = HttpConnectionParams.getSocketBufferSize(this.params);
if (buffersize < 2048) {
buffersize = 2048;
}
Modified: jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java?rev=359877&r1=359876&r2=359877&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java (original)
+++ jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/params/CoyoteParams.java Thu Dec 29 11:23:22 2005
@@ -50,14 +50,6 @@
public static final String CONNECTOR_PORT = "http.connector.port";
/**
- * Defines the size of the read buffer in bytes.
- * <p>
- * This parameter expects a value of type {@link Integer}.
- * </p>
- */
- public static final String READ_BUFFER = "http.connector.readbuffer";
-
- /**
*/
private CoyoteParams() {
super();
@@ -87,27 +79,4 @@
params.setIntParameter(CONNECTOR_PORT, port);
}
- /**
- * Returns the size of the read buffer.
- *
- * @return buffer size in bytes
- */
- public static int getReadBuffer(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- return params.getIntParameter(READ_BUFFER, 8192);
- }
-
- /**
- * Sets the size of the read buffer.
- *
- * @param size buffer size in bytes
- */
- public static void setReadBuffer(final HttpParams params, int size) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- params.setIntParameter(READ_BUFFER, size);
- }
}
Modified: jakarta/httpcomponents/trunk/coyote-httpconnector/src/tests/server.xml
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/coyote-httpconnector/src/tests/server.xml?rev=359877&r1=359876&r2=359877&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/coyote-httpconnector/src/tests/server.xml (original)
+++ jakarta/httpcomponents/trunk/coyote-httpconnector/src/tests/server.xml Thu Dec 29 11:23:22 2005
@@ -21,12 +21,12 @@
socketBuffer="8192" tcpNoDelay="true"
connectionTimeout="20000"
enableLookups="false" acceptCount="100"
- compression="off" maxKeepAliveRequests="10000" />
+ compression="off" maxKeepAliveRequests="10000000" />
<Connector port="8888" protocol="org.apache.http.coyote.HttpProtocolHandler"
minThreads="25" maxThreads="150"
- mode="ClassicIO" readBuffer="8192"
- socketTimeout="20000" tcpNoDelay="true" />
+ socketBuffer="8192" tcpNoDelay="true"
+ connectionTimeout="20000" />
<Engine name="Catalina" defaultHost="localhost">
Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/AbstractHttpConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/AbstractHttpConnection.java?rev=359877&r1=359876&r2=359877&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/AbstractHttpConnection.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/AbstractHttpConnection.java Thu Dec 29 11:23:22 2005
@@ -114,26 +114,19 @@
socket.setSoLinger(linger > 0, linger);
}
- int sndBufSize = HttpConnectionParams.getSendBufferSize(params);
- if (sndBufSize >= 0) {
- socket.setSendBufferSize(sndBufSize);
- }
- int rcvBufSize = HttpConnectionParams.getReceiveBufferSize(params);
- if (rcvBufSize >= 0) {
- socket.setReceiveBufferSize(rcvBufSize);
- }
+ int buffersize = HttpConnectionParams.getSocketBufferSize(params);
assertNotOpen();
this.open = true;
this.socket = socket;
if (this.trxfactory != null) {
this.datatransmitter = this.trxfactory.create(this.socket);
} else {
- this.datatransmitter = new SocketHttpDataTransmitter(this.socket);
+ this.datatransmitter = new SocketHttpDataTransmitter(this.socket, buffersize);
}
if (this.rcvfactory != null) {
this.datareceiver = this.rcvfactory.create(this.socket);
} else {
- this.datareceiver = new SocketHttpDataReceiver(this.socket);
+ this.datareceiver = new SocketHttpDataReceiver(this.socket, buffersize);
}
}
Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/io/SocketHttpDataReceiver.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/io/SocketHttpDataReceiver.java?rev=359877&r1=359876&r2=359877&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/io/SocketHttpDataReceiver.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/io/SocketHttpDataReceiver.java Thu Dec 29 11:23:22 2005
@@ -71,15 +71,17 @@
private final Socket socket;
- public SocketHttpDataReceiver(final Socket socket) throws IOException {
+ public SocketHttpDataReceiver(final Socket socket, int buffersize) throws IOException {
super();
if (socket == null) {
throw new IllegalArgumentException("Socket may not be null");
}
this.socket = socket;
- int buffersize = socket.getReceiveBufferSize();
- if (buffersize < 2048) {
- buffersize = 2048;
+ if (buffersize < 0) {
+ buffersize = socket.getReceiveBufferSize();
+ }
+ if (buffersize < 1024) {
+ buffersize = 1024;
}
init(socket.getInputStream(), buffersize);
}
Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/io/SocketHttpDataTransmitter.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/io/SocketHttpDataTransmitter.java?rev=359877&r1=359876&r2=359877&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/io/SocketHttpDataTransmitter.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/io/SocketHttpDataTransmitter.java Thu Dec 29 11:23:22 2005
@@ -44,14 +44,16 @@
*/
public class SocketHttpDataTransmitter extends AbstractHttpDataTransmitter {
- public SocketHttpDataTransmitter(final Socket socket) throws IOException {
+ public SocketHttpDataTransmitter(final Socket socket, int buffersize) throws IOException {
super();
if (socket == null) {
throw new IllegalArgumentException("Socket may not be null");
}
- int buffersize = socket.getSendBufferSize();
- if (buffersize < 2048) {
- buffersize = 2048;
+ if (buffersize < 0) {
+ buffersize = socket.getReceiveBufferSize();
+ }
+ if (buffersize < 1024) {
+ buffersize = 1024;
}
init(socket.getOutputStream(), buffersize);
}
Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/params/HttpConnectionParams.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/params/HttpConnectionParams.java?rev=359877&r1=359876&r2=359877&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/params/HttpConnectionParams.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/params/HttpConnectionParams.java Thu Dec 29 11:23:22 2005
@@ -67,28 +67,13 @@
public static final String TCP_NODELAY = "http.tcp.nodelay";
/**
- * Determines a hint the size of the underlying buffers used by the platform
- * for outgoing network I/O. This value is a suggestion to the kernel from
- * the application about the size of buffers to use for the data to be sent
- * over the socket.
+ * Determines the size of the internal socket buffer used to buffer data
+ * while receiving / transmitting HTTP messages
* <p>
* This parameter expects a value of type {@link Integer}.
* </p>
- * @see java.net.SocketOptions#SO_SNDBUF
*/
- public static final String SO_SNDBUF = "http.socket.sendbuffer";
-
- /**
- * Determines a hint the size of the underlying buffers used by the platform
- * for incoming network I/O. This value is a suggestion to the kernel from
- * the application about the size of buffers to use for the data to be received
- * over the socket.
- * <p>
- * This parameter expects a value of type {@link Integer}.
- * </p>
- * @see java.net.SocketOptions#SO_RCVBUF
- */
- public static final String SO_RCVBUF = "http.socket.receivebuffer";
+ public static final String SOCKET_BUFFER_SIZE = "http.socket.buffer-size";
/**
* Sets SO_LINGER with the specified linger time in seconds. The maximum timeout
@@ -189,64 +174,18 @@
params.setBooleanParameter(TCP_NODELAY, value);
}
- /**
- * Returns a hint the size of the underlying buffers used by the platform for
- * outgoing network I/O. This value is a suggestion to the kernel from the
- * application about the size of buffers to use for the data to be sent over
- * the socket.
- *
- * @return the hint size of the send buffer
- */
- public static int getSendBufferSize(final HttpParams params) {
+ public static int getSocketBufferSize(final HttpParams params) {
if (params == null) {
throw new IllegalArgumentException("HTTP parameters may not be null");
}
- return params.getIntParameter(SO_SNDBUF, -1);
+ return params.getIntParameter(SOCKET_BUFFER_SIZE, -1);
}
-
- /**
- * Sets a hint the size of the underlying buffers used by the platform for
- * outgoing network I/O. This value is a suggestion to the kernel from the
- * application about the size of buffers to use for the data to be sent over
- * the socket.
- *
- * @param size the hint size of the send buffer
- */
- public static void setSendBufferSize(final HttpParams params, int size) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- params.setIntParameter(SO_SNDBUF, size);
- }
-
- /**
- * Returns a hint the size of the underlying buffers used by the platform
- * for incoming network I/O. This value is a suggestion to the kernel from
- * the application about the size of buffers to use for the data to be received
- * over the socket.
- *
- * @return the hint size of the send buffer
- */
- public static int getReceiveBufferSize(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- return params.getIntParameter(SO_RCVBUF, -1);
- }
-
- /**
- * Sets a hint the size of the underlying buffers used by the platform
- * for incoming network I/O. This value is a suggestion to the kernel from
- * the application about the size of buffers to use for the data to be received
- * over the socket.
- *
- * @param size the hint size of the send buffer
- */
- public static void setReceiveBufferSize(final HttpParams params, int size) {
+
+ public static void setSocketBufferSize(final HttpParams params, int size) {
if (params == null) {
throw new IllegalArgumentException("HTTP parameters may not be null");
}
- params.setIntParameter(SO_RCVBUF, size);
+ params.setIntParameter(SOCKET_BUFFER_SIZE, size);
}
/**