Author: hiranya
Date: Sun Nov 24 23:14:04 2013
New Revision: 1545106
URL: http://svn.apache.org/r1545106
Log:
* Not setting the http.socket.rcv-buffer-size and http.socket.snd-buffer-size
properties unless the user has specified them explicitly. This will cause
Synapse to use platform defaults when appropriate. (see the thread: HTTP Core
Performance and Reactor Buffer Size)
* Updated the relevant documentation and test cases.
* Changed the EchoHttpServerController to reuse server sockets when appopriate.
Modified:
synapse/trunk/java/modules/documentation/src/site/xdoc/userguide/transports/pass_through.xml
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/EchoHttpServerController.java
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/utils/config/HttpTransportConfiguration.java
synapse/trunk/java/modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/utils/config/HttpTransportConfigurationTest.java
synapse/trunk/java/modules/transports/core/nhttp/src/test/resources/test-http.properties
Modified:
synapse/trunk/java/modules/documentation/src/site/xdoc/userguide/transports/pass_through.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/documentation/src/site/xdoc/userguide/transports/pass_through.xml?rev=1545106&r1=1545105&r2=1545106&view=diff
==============================================================================
---
synapse/trunk/java/modules/documentation/src/site/xdoc/userguide/transports/pass_through.xml
(original)
+++
synapse/trunk/java/modules/documentation/src/site/xdoc/userguide/transports/pass_through.xml
Sun Nov 24 23:14:04 2013
@@ -838,10 +838,11 @@
suggestion to the OS kernel from Synapse about the
size of buffers to
use for the data to be received over the socket
(See <a
href="http://docs.oracle.com/javase/1.5.0/docs/api/java/net/SocketOptions.html#SO_RCVBUF">SO_RCVBUF</a>).
- <div
class="xmlConf">http.socket.rcv-buffer-size=4096</div>
+ If no value is specified, Synapse will use the
platform (OS) default.
+ <div
class="xmlConf">http.socket.rcv-buffer-size=8192</div>
</td>
<td>No</td>
- <td>8192</td>
+ <td>Platform default</td>
</tr>
<tr>
<td>http.socket.snd-buffer-size</td>
@@ -851,10 +852,11 @@
suggestion to the OS kernel from Synapse about the
size of buffers to
use for the data to be sent over the socket
(See <a
href="http://docs.oracle.com/javase/1.5.0/docs/api/java/net/SocketOptions.html#SO_SNDBUF">SO_SNDBUF</a>).
- <div
class="xmlConf">http.socket.snd-buffer-size=4096</div>
+ If no value is specified, Synapse will use the
platform (OS) default.
+ <div
class="xmlConf">http.socket.snd-buffer-size=8192</div>
</td>
<td>No</td>
- <td>8192</td>
+ <td>Platform default</td>
</tr>
<tr>
<td>http.socket.linger</td>
Modified:
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/EchoHttpServerController.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/EchoHttpServerController.java?rev=1545106&r1=1545105&r2=1545106&view=diff
==============================================================================
---
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/EchoHttpServerController.java
(original)
+++
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/EchoHttpServerController.java
Sun Nov 24 23:14:04 2013
@@ -33,6 +33,7 @@ import org.apache.synapse.samples.framew
import java.io.IOException;
import java.io.InterruptedIOException;
+import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.atomic.AtomicInteger;
@@ -98,7 +99,9 @@ public class EchoHttpServerController ex
public RequestListenerThread(final int port) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
- this.serversocket = new ServerSocket(port);
+ this.serversocket = new ServerSocket();
+ this.serversocket.setReuseAddress(true);
+ this.serversocket.bind(new InetSocketAddress(port));
// Set up the HTTP protocol processor
HttpProcessor httpProcessor = HttpProcessorBuilder.create()
@@ -146,6 +149,12 @@ public class EchoHttpServerController ex
try {
this.interrupt();
this.serversocket.close();
+ while (this.isAlive() || !this.serversocket.isClosed()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ignored) {
+ }
+ }
} catch (IOException e) {
log.warn("Error while shutting down echo server", e);
}
Modified:
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/utils/config/HttpTransportConfiguration.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/utils/config/HttpTransportConfiguration.java?rev=1545106&r1=1545105&r2=1545106&view=diff
==============================================================================
---
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/utils/config/HttpTransportConfiguration.java
(original)
+++
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/utils/config/HttpTransportConfiguration.java
Sun Nov 24 23:14:04 2013
@@ -69,9 +69,15 @@ public abstract class HttpTransportConfi
getIntProperty(HttpConfigConstants.SO_TIMEOUT, 60000)))
.setConnectTimeout(getIntProperty(HttpConfigConstants.CONNECTION_TIMEOUT, 0))
.setInterestOpQueued(getBooleanProperty(HttpConfigConstants.INTEREST_OPS_QUEUEING,
false))
-
.setTcpNoDelay(getBooleanProperty(HttpConfigConstants.TCP_NODELAY, true))
-
.setRcvBufSize(getIntProperty(HttpConfigConstants.SOCKET_RCV_BUFFER_SIZE, 8 *
1024))
-
.setSndBufSize(getIntProperty(HttpConfigConstants.SOCKET_SND_BUFFER_SIZE, 8 *
1024));
+
.setTcpNoDelay(getBooleanProperty(HttpConfigConstants.TCP_NODELAY, true));
+
+ if (getIntProperty(HttpConfigConstants.SOCKET_RCV_BUFFER_SIZE) !=
null) {
+
builder.setRcvBufSize(getIntProperty(HttpConfigConstants.SOCKET_RCV_BUFFER_SIZE));
+ }
+
+ if (getIntProperty(HttpConfigConstants.SOCKET_SND_BUFFER_SIZE) !=
null) {
+
builder.setSndBufSize(getIntProperty(HttpConfigConstants.SOCKET_SND_BUFFER_SIZE));
+ }
if (getIntProperty(HttpConfigConstants.SO_LINGER) != null) {
builder.setSoLinger(getIntProperty(HttpConfigConstants.SO_LINGER));
@@ -99,9 +105,15 @@ public abstract class HttpTransportConfi
getIntProperty(HttpConfigConstants.SO_TIMEOUT, 60000)))
.setConnectTimeout(getIntProperty(HttpConfigConstants.CONNECTION_TIMEOUT, 0))
.setInterestOpQueued(getBooleanProperty(HttpConfigConstants.INTEREST_OPS_QUEUEING,
false))
-
.setTcpNoDelay(getBooleanProperty(HttpConfigConstants.TCP_NODELAY, true))
-
.setRcvBufSize(getIntProperty(HttpConfigConstants.SOCKET_RCV_BUFFER_SIZE, 8 *
1024))
-
.setSndBufSize(getIntProperty(HttpConfigConstants.SOCKET_SND_BUFFER_SIZE, 8 *
1024));
+
.setTcpNoDelay(getBooleanProperty(HttpConfigConstants.TCP_NODELAY, true));
+
+ if (getIntProperty(HttpConfigConstants.SOCKET_RCV_BUFFER_SIZE) !=
null) {
+
builder.setRcvBufSize(getIntProperty(HttpConfigConstants.SOCKET_RCV_BUFFER_SIZE));
+ }
+
+ if (getIntProperty(HttpConfigConstants.SOCKET_SND_BUFFER_SIZE) !=
null) {
+
builder.setSndBufSize(getIntProperty(HttpConfigConstants.SOCKET_SND_BUFFER_SIZE));
+ }
if (getIntProperty(HttpConfigConstants.SO_LINGER) != null) {
builder.setSoLinger(getIntProperty(HttpConfigConstants.SO_LINGER));
Modified:
synapse/trunk/java/modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/utils/config/HttpTransportConfigurationTest.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/utils/config/HttpTransportConfigurationTest.java?rev=1545106&r1=1545105&r2=1545106&view=diff
==============================================================================
---
synapse/trunk/java/modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/utils/config/HttpTransportConfigurationTest.java
(original)
+++
synapse/trunk/java/modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/utils/config/HttpTransportConfigurationTest.java
Sun Nov 24 23:14:04 2013
@@ -36,8 +36,6 @@ public class HttpTransportConfigurationT
IOReactorConfig reactorConfig = config.getListeningReactorConfig();
assertEquals(2, reactorConfig.getIoThreadCount());
assertEquals(0, reactorConfig.getConnectTimeout());
- assertEquals(1024 * 8, reactorConfig.getRcvBufSize());
- assertEquals(1024 * 8, reactorConfig.getSndBufSize());
assertEquals(60000, reactorConfig.getSoTimeout());
assertEquals(true, reactorConfig.isTcpNoDelay());
assertEquals(false, reactorConfig.isInterestOpQueued());
@@ -45,8 +43,6 @@ public class HttpTransportConfigurationT
reactorConfig = config.getConnectingReactorConfig();
assertEquals(2, reactorConfig.getIoThreadCount());
assertEquals(0, reactorConfig.getConnectTimeout());
- assertEquals(1024 * 8, reactorConfig.getRcvBufSize());
- assertEquals(1024 * 8, reactorConfig.getSndBufSize());
assertEquals(60000, reactorConfig.getSoTimeout());
assertEquals(true, reactorConfig.isTcpNoDelay());
assertEquals(false, reactorConfig.isInterestOpQueued());
@@ -67,8 +63,6 @@ public class HttpTransportConfigurationT
assertEquals(true, reactorConfig.isSoReuseAddress());
assertEquals(2, reactorConfig.getIoThreadCount());
assertEquals(0, reactorConfig.getConnectTimeout());
- assertEquals(1024 * 8, reactorConfig.getRcvBufSize());
- assertEquals(1024 * 8, reactorConfig.getSndBufSize());
assertEquals(60000, reactorConfig.getSoTimeout());
assertEquals(true, reactorConfig.isTcpNoDelay());
assertEquals(false, reactorConfig.isInterestOpQueued());
@@ -79,13 +73,14 @@ public class HttpTransportConfigurationT
assertEquals(CodingErrorAction.REPORT,
connConfig.getUnmappableInputAction());
}
- public void testTimeoutConfig() {
+ public void testTimeoutAndBufferSizeConfig() {
HttpTransportConfiguration config = new
SimpleHttpTransportConfiguration("test-http");
IOReactorConfig reactorConfig = config.getListeningReactorConfig();
assertEquals(30000, reactorConfig.getSoTimeout());
assertEquals(2, reactorConfig.getIoThreadCount());
assertEquals(0, reactorConfig.getConnectTimeout());
+ // Should be able to override platform default buffer sizes if needed
assertEquals(1024 * 8, reactorConfig.getRcvBufSize());
assertEquals(1024 * 8, reactorConfig.getSndBufSize());
assertEquals(true, reactorConfig.isTcpNoDelay());
@@ -95,6 +90,7 @@ public class HttpTransportConfigurationT
assertEquals(20000, reactorConfig.getSoTimeout());
assertEquals(2, reactorConfig.getIoThreadCount());
assertEquals(0, reactorConfig.getConnectTimeout());
+ // Should be able to override platform default buffer sizes if needed
assertEquals(1024 * 8, reactorConfig.getRcvBufSize());
assertEquals(1024 * 8, reactorConfig.getSndBufSize());
assertEquals(true, reactorConfig.isTcpNoDelay());
Modified:
synapse/trunk/java/modules/transports/core/nhttp/src/test/resources/test-http.properties
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/test/resources/test-http.properties?rev=1545106&r1=1545105&r2=1545106&view=diff
==============================================================================
---
synapse/trunk/java/modules/transports/core/nhttp/src/test/resources/test-http.properties
(original)
+++
synapse/trunk/java/modules/transports/core/nhttp/src/test/resources/test-http.properties
Sun Nov 24 23:14:04 2013
@@ -7,3 +7,7 @@ http.connection.timeout=0
http.socket.buffer-size=8192
http.tcp.nodelay=true
http.nio.interest-ops-queueing=false
+
+http.socket.rcv-buffer-size=8192
+http.socket.snd-buffer-size=8192
+