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
This commit is contained in:
parent
3ee44fd757
commit
ab24a94666
|
@ -85,7 +85,7 @@ public class HttpClient extends AbstractBuffers implements Attributes
|
||||||
|
|
||||||
private int _connectorType = CONNECTOR_SELECT_CHANNEL;
|
private int _connectorType = CONNECTOR_SELECT_CHANNEL;
|
||||||
private boolean _useDirectBuffers = true;
|
private boolean _useDirectBuffers = true;
|
||||||
private int _maxConnectionsPerAddress = 32;
|
private int _maxConnectionsPerAddress = Integer.MAX_VALUE;
|
||||||
private Map<Address, HttpDestination> _destinations = new HashMap<Address, HttpDestination>();
|
private Map<Address, HttpDestination> _destinations = new HashMap<Address, HttpDestination>();
|
||||||
ThreadPool _threadPool;
|
ThreadPool _threadPool;
|
||||||
Connector _connector;
|
Connector _connector;
|
||||||
|
@ -121,12 +121,19 @@ public class HttpClient extends AbstractBuffers implements Attributes
|
||||||
private AttributesMap _attributes=new AttributesMap();
|
private AttributesMap _attributes=new AttributesMap();
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------------- */
|
||||||
public void dump() throws IOException
|
public void dump()
|
||||||
{
|
{
|
||||||
for (Map.Entry<Address, HttpDestination> entry : _destinations.entrySet())
|
try
|
||||||
{
|
{
|
||||||
System.err.println("\n" + entry.getKey() + ":");
|
for (Map.Entry<Address, HttpDestination> entry : _destinations.entrySet())
|
||||||
entry.getValue().dump();
|
{
|
||||||
|
Log.info("\n" + entry.getKey() + ":");
|
||||||
|
entry.getValue().dump();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Log.warn(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,10 +61,10 @@ public class HttpConnection implements Connection
|
||||||
|
|
||||||
public void dump() throws IOException
|
public void dump() throws IOException
|
||||||
{
|
{
|
||||||
System.err.println("endp=" + _endp + " " + _endp.isBufferingInput() + " " + _endp.isBufferingOutput());
|
Log.info("endp=" + _endp + " " + _endp.isBufferingInput() + " " + _endp.isBufferingOutput());
|
||||||
System.err.println("generator=" + _generator);
|
Log.info("generator=" + _generator);
|
||||||
System.err.println("parser=" + _parser.getState() + " " + _parser.isMoreInBuffer());
|
Log.info("parser=" + _parser.getState() + " " + _parser.isMoreInBuffer());
|
||||||
System.err.println("exchange=" + _exchange);
|
Log.info("exchange=" + _exchange);
|
||||||
if (_endp instanceof SslSelectChannelEndPoint)
|
if (_endp instanceof SslSelectChannelEndPoint)
|
||||||
((SslSelectChannelEndPoint)_endp).dump();
|
((SslSelectChannelEndPoint)_endp).dump();
|
||||||
}
|
}
|
||||||
|
@ -296,6 +296,7 @@ public class HttpConnection implements Connection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
failed = true;
|
failed = true;
|
||||||
|
Log.warn("IOE on "+_exchange);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
@ -35,13 +35,13 @@ import org.eclipse.jetty.util.log.Log;
|
||||||
*/
|
*/
|
||||||
public class HttpDestination
|
public class HttpDestination
|
||||||
{
|
{
|
||||||
private ByteArrayBuffer _hostHeader;
|
private final ByteArrayBuffer _hostHeader;
|
||||||
private final Address _address;
|
private final Address _address;
|
||||||
private final LinkedList<HttpConnection> _connections = new LinkedList<HttpConnection>();
|
private final LinkedList<HttpConnection> _connections = new LinkedList<HttpConnection>();
|
||||||
private final ArrayList<HttpConnection> _idle = new ArrayList<HttpConnection>();
|
private final ArrayList<HttpConnection> _idle = new ArrayList<HttpConnection>();
|
||||||
private final HttpClient _client;
|
private final HttpClient _client;
|
||||||
private final boolean _ssl;
|
private final boolean _ssl;
|
||||||
private int _maxConnections;
|
private final int _maxConnections;
|
||||||
private int _pendingConnections = 0;
|
private int _pendingConnections = 0;
|
||||||
private ArrayBlockingQueue<Object> _newQueue = new ArrayBlockingQueue<Object>(10, true);
|
private ArrayBlockingQueue<Object> _newQueue = new ArrayBlockingQueue<Object>(10, true);
|
||||||
private int _newConnection = 0;
|
private int _newConnection = 0;
|
||||||
|
@ -50,14 +50,15 @@ public class HttpDestination
|
||||||
private PathMap _authorizations;
|
private PathMap _authorizations;
|
||||||
private List<HttpCookie> _cookies;
|
private List<HttpCookie> _cookies;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void dump() throws IOException
|
public void dump() throws IOException
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
System.err.println(this);
|
Log.info(this.toString());
|
||||||
System.err.println("connections=" + _connections.size());
|
Log.info("connections=" + _connections.size());
|
||||||
System.err.println("idle=" + _idle.size());
|
Log.info("idle=" + _idle.size());
|
||||||
System.err.println("pending=" + _pendingConnections);
|
Log.info("pending=" + _pendingConnections);
|
||||||
for (HttpConnection c : _connections)
|
for (HttpConnection c : _connections)
|
||||||
{
|
{
|
||||||
if (!c.isIdle())
|
if (!c.isIdle())
|
||||||
|
@ -70,9 +71,9 @@ public class HttpDestination
|
||||||
private LinkedList<HttpExchange> _queue = new LinkedList<HttpExchange>();
|
private LinkedList<HttpExchange> _queue = new LinkedList<HttpExchange>();
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
HttpDestination(HttpClient pool, Address address, boolean ssl, int maxConnections)
|
HttpDestination(HttpClient client, Address address, boolean ssl, int maxConnections)
|
||||||
{
|
{
|
||||||
_client = pool;
|
_client = client;
|
||||||
_address = address;
|
_address = address;
|
||||||
_ssl = ssl;
|
_ssl = ssl;
|
||||||
_maxConnections = maxConnections;
|
_maxConnections = maxConnections;
|
||||||
|
@ -211,6 +212,12 @@ public class HttpDestination
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
|
if (connection!=null)
|
||||||
|
{
|
||||||
|
_connections.remove(connection);
|
||||||
|
connection.getEndPoint().close();
|
||||||
|
connection=null;
|
||||||
|
}
|
||||||
if (_idle.size() > 0)
|
if (_idle.size() > 0)
|
||||||
connection = _idle.remove(_idle.size()-1);
|
connection = _idle.remove(_idle.size()-1);
|
||||||
}
|
}
|
||||||
|
@ -222,9 +229,6 @@ public class HttpDestination
|
||||||
if (connection.getEndPoint().isOpen() && (last==0 || ((now-last)<idleTimeout)) )
|
if (connection.getEndPoint().isOpen() && (last==0 || ((now-last)<idleTimeout)) )
|
||||||
return connection;
|
return connection;
|
||||||
|
|
||||||
_connections.remove(connection);
|
|
||||||
connection.getEndPoint().close();
|
|
||||||
connection=null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,12 +459,16 @@ public class HttpDestination
|
||||||
((Authorization)auth).setCredentials(ex);
|
((Authorization)auth).setCredentials(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this)
|
HttpConnection connection = getIdleConnection();
|
||||||
|
if (connection != null)
|
||||||
{
|
{
|
||||||
//System.out.println( "Sending: " + ex.toString() );
|
boolean sent = connection.send(ex);
|
||||||
|
if (!sent) connection = null;
|
||||||
|
}
|
||||||
|
|
||||||
HttpConnection connection = null;
|
if (connection == null)
|
||||||
if (_queue.size() > 0 || (connection = getIdleConnection()) == null || !connection.send(ex))
|
{
|
||||||
|
synchronized (this)
|
||||||
{
|
{
|
||||||
_queue.add(ex);
|
_queue.add(ex);
|
||||||
if (_connections.size() + _pendingConnections < _maxConnections)
|
if (_connections.size() + _pendingConnections < _maxConnections)
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||||
// TODO get rid of these dumps
|
// TODO get rid of these dumps
|
||||||
public void dump()
|
public void dump()
|
||||||
{
|
{
|
||||||
System.err.println(_result);
|
Log.info(""+_result);
|
||||||
// System.err.println(h.toString());
|
// System.err.println(h.toString());
|
||||||
// System.err.println("--");
|
// System.err.println("--");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue