From ab24a94666aa5d23243813777bdfd4a463b16a08 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 7 May 2009 06:46:40 +0000 Subject: [PATCH] JETTY-1015 work in progress git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@207 7e9141cc-0065-0410-87d8-b60c137991c4 --- .../org/eclipse/jetty/client/HttpClient.java | 17 ++++++--- .../eclipse/jetty/client/HttpConnection.java | 9 +++-- .../eclipse/jetty/client/HttpDestination.java | 38 +++++++++++-------- .../http/ssl/SslSelectChannelEndPoint.java | 2 +- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index 9f5788d3989..e07515a62b3 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -85,7 +85,7 @@ public class HttpClient extends AbstractBuffers implements Attributes private int _connectorType = CONNECTOR_SELECT_CHANNEL; private boolean _useDirectBuffers = true; - private int _maxConnectionsPerAddress = 32; + private int _maxConnectionsPerAddress = Integer.MAX_VALUE; private Map _destinations = new HashMap(); ThreadPool _threadPool; Connector _connector; @@ -121,12 +121,19 @@ public class HttpClient extends AbstractBuffers implements Attributes private AttributesMap _attributes=new AttributesMap(); /* ------------------------------------------------------------------------------- */ - public void dump() throws IOException + public void dump() { - for (Map.Entry entry : _destinations.entrySet()) + try { - System.err.println("\n" + entry.getKey() + ":"); - entry.getValue().dump(); + for (Map.Entry entry : _destinations.entrySet()) + { + Log.info("\n" + entry.getKey() + ":"); + entry.getValue().dump(); + } + } + catch(Exception e) + { + Log.warn(e); } } diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java index 1031bfe2443..3db6db700a9 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java @@ -61,10 +61,10 @@ public class HttpConnection implements Connection public void dump() throws IOException { - System.err.println("endp=" + _endp + " " + _endp.isBufferingInput() + " " + _endp.isBufferingOutput()); - System.err.println("generator=" + _generator); - System.err.println("parser=" + _parser.getState() + " " + _parser.isMoreInBuffer()); - System.err.println("exchange=" + _exchange); + Log.info("endp=" + _endp + " " + _endp.isBufferingInput() + " " + _endp.isBufferingOutput()); + Log.info("generator=" + _generator); + Log.info("parser=" + _parser.getState() + " " + _parser.isMoreInBuffer()); + Log.info("exchange=" + _exchange); if (_endp instanceof SslSelectChannelEndPoint) ((SslSelectChannelEndPoint)_endp).dump(); } @@ -296,6 +296,7 @@ public class HttpConnection implements Connection } } failed = true; + Log.warn("IOE on "+_exchange); throw e; } finally diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java index 9dd43482e3c..e8b071d6679 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java @@ -35,13 +35,13 @@ import org.eclipse.jetty.util.log.Log; */ public class HttpDestination { - private ByteArrayBuffer _hostHeader; + private final ByteArrayBuffer _hostHeader; private final Address _address; private final LinkedList _connections = new LinkedList(); private final ArrayList _idle = new ArrayList(); private final HttpClient _client; private final boolean _ssl; - private int _maxConnections; + private final int _maxConnections; private int _pendingConnections = 0; private ArrayBlockingQueue _newQueue = new ArrayBlockingQueue(10, true); private int _newConnection = 0; @@ -50,14 +50,15 @@ public class HttpDestination private PathMap _authorizations; private List _cookies; + /* ------------------------------------------------------------ */ public void dump() throws IOException { synchronized (this) { - System.err.println(this); - System.err.println("connections=" + _connections.size()); - System.err.println("idle=" + _idle.size()); - System.err.println("pending=" + _pendingConnections); + Log.info(this.toString()); + Log.info("connections=" + _connections.size()); + Log.info("idle=" + _idle.size()); + Log.info("pending=" + _pendingConnections); for (HttpConnection c : _connections) { if (!c.isIdle()) @@ -70,9 +71,9 @@ public class HttpDestination private LinkedList _queue = new LinkedList(); /* ------------------------------------------------------------ */ - HttpDestination(HttpClient pool, Address address, boolean ssl, int maxConnections) + HttpDestination(HttpClient client, Address address, boolean ssl, int maxConnections) { - _client = pool; + _client = client; _address = address; _ssl = ssl; _maxConnections = maxConnections; @@ -211,6 +212,12 @@ public class HttpDestination { synchronized (this) { + if (connection!=null) + { + _connections.remove(connection); + connection.getEndPoint().close(); + connection=null; + } if (_idle.size() > 0) connection = _idle.remove(_idle.size()-1); } @@ -222,9 +229,6 @@ public class HttpDestination if (connection.getEndPoint().isOpen() && (last==0 || ((now-last) 0 || (connection = getIdleConnection()) == null || !connection.send(ex)) + if (connection == null) + { + synchronized (this) { _queue.add(ex); if (_connections.size() + _pendingConnections < _maxConnections) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslSelectChannelEndPoint.java b/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslSelectChannelEndPoint.java index 0357f57c323..4c548892fea 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslSelectChannelEndPoint.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslSelectChannelEndPoint.java @@ -97,7 +97,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint // TODO get rid of these dumps public void dump() { - System.err.println(_result); + Log.info(""+_result); // System.err.println(h.toString()); // System.err.println("--"); }