You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2007/05/29 06:08:51 UTC
svn commit: r542403 - in
/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp:
ConnectionPool.java HttpCoreNIOListener.java util/PipeImpl.java
Author: asankha
Date: Mon May 28 21:08:49 2007
New Revision: 542403
URL: http://svn.apache.org/viewvc?view=rev&rev=542403
Log:
fix a few issues encountered during performance testing with 1k and 5k requests and responses
make selection of native and simulated pipes configurable via system property
Modified:
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ConnectionPool.java
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOListener.java
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/util/PipeImpl.java
Modified: webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ConnectionPool.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ConnectionPool.java?view=diff&rev=542403&r1=542402&r2=542403
==============================================================================
--- webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ConnectionPool.java (original)
+++ webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ConnectionPool.java Mon May 28 21:08:49 2007
@@ -41,26 +41,33 @@
String key = host + ":" + Integer.toString(port);
List connections = (List) connMap.get(key);
- if (connections == null) {
- log.debug("No connections available for reuse");
+ if (connections == null || connections.isEmpty()) {
+ if (log.isDebugEnabled()) {
+ log.debug("No connections available for reuse");
+ }
return null;
} else {
NHttpClientConnection conn = null;
- while (!connections.isEmpty()) {
- conn = (NHttpClientConnection) connections.remove(0);
-
- if (conn.isOpen()) {
- log.debug("A connection to host : " + host + " on port : " +
- port + " is available in the pool, and will be reused");
- return conn;
- } else {
- log.debug("closing stale connection");
- try {
- conn.close();
- } catch (IOException ignore) {
- ignore.printStackTrace();
+ synchronized (connections) {
+ while (!connections.isEmpty()) {
+ conn = (NHttpClientConnection) connections.remove(0);
+
+ if (conn.isOpen()) {
+ if (log.isDebugEnabled()) {
+ log.debug("A connection to host : " + host + " on port : " +
+ port + " is available in the pool, and will be reused");
+ }
+ return conn;
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("closing stale connection");
+ }
+ try {
+ conn.close();
+ } catch (IOException ignore) {
+ }
}
}
}
@@ -76,8 +83,14 @@
List connections = (List) connMap.get(key);
if (connections == null) {
- connections = Collections.synchronizedList(new LinkedList());
- connMap.put(key, connections);
+ synchronized(connMap) {
+ // use double locking to make sure
+ connections = (List) connMap.get(key);
+ if (connections == null) {
+ connections = Collections.synchronizedList(new LinkedList());
+ connMap.put(key, connections);
+ }
+ }
}
connections.add(conn);
Modified: webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOListener.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOListener.java?view=diff&rev=542403&r1=542402&r2=542403
==============================================================================
--- webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOListener.java (original)
+++ webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOListener.java Mon May 28 21:08:49 2007
@@ -111,7 +111,7 @@
NHttpConfiguration cfg = NHttpConfiguration.getInstance();
params
.setIntParameter(HttpConnectionParams.SO_TIMEOUT,
- cfg.getProperty(HttpConnectionParams.SO_TIMEOUT, 30000))
+ cfg.getProperty(HttpConnectionParams.SO_TIMEOUT, 60000))
.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE,
cfg.getProperty(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024))
.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK,
Modified: webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/util/PipeImpl.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/util/PipeImpl.java?view=diff&rev=542403&r1=542402&r2=542403
==============================================================================
--- webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/util/PipeImpl.java (original)
+++ webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/util/PipeImpl.java Mon May 28 21:08:49 2007
@@ -49,11 +49,26 @@
protected static boolean useNative;
static {
- if (!"/".equals(File.separator)) {
- log.info("Using simulated buffered Pipes for event-driven to stream IO bridging");
- } else {
- log.info("Using native OS Pipes for event-driven to stream IO bridging");
+ // platfom default - Unix - native, Windows - Piped Streams
+ if ("/".equals(File.separator)) {
useNative = true;
+ }
+
+ // has this been overridden?
+ String option = System.getProperty("native_pipes");
+ if (option != null) {
+ // if an option is specified, use it
+ if ("true".equals(option)) {
+ useNative = true;
+ } else if ("false".equals(option)) {
+ useNative = false;
+ }
+ }
+
+ if (useNative) {
+ log.info("Using native OS Pipes for event-driven to stream IO bridging");
+ } else {
+ log.info("Using simulated buffered Pipes for event-driven to stream IO bridging");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org