Fixes JETTY-1335 (HttpClient's SelectConnector clean-up)
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2815 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
22e142a871
commit
0ace68632c
|
@ -1,5 +1,5 @@
|
||||||
jetty-7.3.1-SNAPSHOT
|
jetty-7.3.1-SNAPSHOT
|
||||||
+ 316382 Support a more strict SSL option with certificates
|
+ 316382 Support a more strict SSL option with certificates
|
||||||
+ 333481 Handle UCS-4 codepoints in decode and encode
|
+ 333481 Handle UCS-4 codepoints in decode and encode
|
||||||
+ 335329 Moved blocking timeout handling to outside try catch
|
+ 335329 Moved blocking timeout handling to outside try catch
|
||||||
+ 336668 policy supports cert validation
|
+ 336668 policy supports cert validation
|
||||||
|
@ -15,6 +15,7 @@ jetty-7.3.1-SNAPSHOT
|
||||||
+ 337746 Fixed Session deIdle recursion
|
+ 337746 Fixed Session deIdle recursion
|
||||||
+ 337784 Improve HashSessionManager for session migrations
|
+ 337784 Improve HashSessionManager for session migrations
|
||||||
+ JETTY-1331 Allow alternate XML configuration processors (eg spring)
|
+ JETTY-1331 Allow alternate XML configuration processors (eg spring)
|
||||||
|
+ JETTY-1335 HttpClient's SelectConnector clean-up
|
||||||
|
|
||||||
jetty-7.3.0.v20110203 3 February 2011
|
jetty-7.3.0.v20110203 3 February 2011
|
||||||
+ JETTY-1259 NullPointerException in JDBCSessionIdManager when invalidating session (further update)
|
+ JETTY-1259 NullPointerException in JDBCSessionIdManager when invalidating session (further update)
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
|
|
||||||
import org.eclipse.jetty.client.security.Authentication;
|
import org.eclipse.jetty.client.security.Authentication;
|
||||||
|
@ -75,7 +74,7 @@ public class HttpClient extends HttpBuffers implements Attributes
|
||||||
|
|
||||||
private int _connectorType = CONNECTOR_SELECT_CHANNEL;
|
private int _connectorType = CONNECTOR_SELECT_CHANNEL;
|
||||||
private boolean _useDirectBuffers = true;
|
private boolean _useDirectBuffers = true;
|
||||||
private boolean _asyncConnects = false;
|
private boolean _connectBlocking = true;
|
||||||
private int _maxConnectionsPerAddress = Integer.MAX_VALUE;
|
private int _maxConnectionsPerAddress = Integer.MAX_VALUE;
|
||||||
private ConcurrentMap<Address, HttpDestination> _destinations = new ConcurrentHashMap<Address, HttpDestination>();
|
private ConcurrentMap<Address, HttpDestination> _destinations = new ConcurrentHashMap<Address, HttpDestination>();
|
||||||
ThreadPool _threadPool;
|
ThreadPool _threadPool;
|
||||||
|
@ -97,12 +96,12 @@ public class HttpClient extends HttpBuffers implements Attributes
|
||||||
private RealmResolver _realmResolver;
|
private RealmResolver _realmResolver;
|
||||||
|
|
||||||
private AttributesMap _attributes=new AttributesMap();
|
private AttributesMap _attributes=new AttributesMap();
|
||||||
|
|
||||||
public HttpClient()
|
public HttpClient()
|
||||||
{
|
{
|
||||||
this(new SslContextFactory());
|
this(new SslContextFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpClient(SslContextFactory sslContextFactory)
|
public HttpClient(SslContextFactory sslContextFactory)
|
||||||
{
|
{
|
||||||
_sslContextFactory = sslContextFactory;
|
_sslContextFactory = sslContextFactory;
|
||||||
|
@ -112,9 +111,9 @@ public class HttpClient extends HttpBuffers implements Attributes
|
||||||
/**
|
/**
|
||||||
* @return True if connects will be in blocking mode.
|
* @return True if connects will be in blocking mode.
|
||||||
*/
|
*/
|
||||||
public boolean isAsyncConnects()
|
public boolean isConnectBlocking()
|
||||||
{
|
{
|
||||||
return _asyncConnects;
|
return _connectBlocking;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------------- */
|
||||||
|
@ -123,7 +122,7 @@ public class HttpClient extends HttpBuffers implements Attributes
|
||||||
*/
|
*/
|
||||||
public void setAsyncConnects(boolean blockingConnects)
|
public void setAsyncConnects(boolean blockingConnects)
|
||||||
{
|
{
|
||||||
_asyncConnects = blockingConnects;
|
_connectBlocking = blockingConnects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------------- */
|
||||||
|
@ -463,7 +462,7 @@ public class HttpClient extends HttpBuffers implements Attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
_sslContextFactory.start();
|
_sslContextFactory.start();
|
||||||
|
|
||||||
if (_connectorType == CONNECTOR_SELECT_CHANNEL)
|
if (_connectorType == CONNECTOR_SELECT_CHANNEL)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -509,7 +508,7 @@ public class HttpClient extends HttpBuffers implements Attributes
|
||||||
_connector.stop();
|
_connector.stop();
|
||||||
_connector = null;
|
_connector = null;
|
||||||
_sslContextFactory.stop();
|
_sslContextFactory.stop();
|
||||||
|
|
||||||
if (_threadPool instanceof LifeCycle)
|
if (_threadPool instanceof LifeCycle)
|
||||||
{
|
{
|
||||||
((LifeCycle)_threadPool).stop();
|
((LifeCycle)_threadPool).stop();
|
||||||
|
@ -549,7 +548,7 @@ public class HttpClient extends HttpBuffers implements Attributes
|
||||||
{
|
{
|
||||||
return _sslContextFactory;
|
return _sslContextFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @return the period in milliseconds a {@link HttpConnection} can be idle for before it is closed.
|
* @return the period in milliseconds a {@link HttpConnection} can be idle for before it is closed.
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.nio.channels.SelectionKey;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
import javax.net.ssl.SSLSession;
|
import javax.net.ssl.SSLSession;
|
||||||
|
@ -46,10 +45,9 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||||
private final HttpClient _httpClient;
|
private final HttpClient _httpClient;
|
||||||
private final Manager _selectorManager=new Manager();
|
private final Manager _selectorManager=new Manager();
|
||||||
private final Timeout _connectTimer = new Timeout();
|
private final Timeout _connectTimer = new Timeout();
|
||||||
private final Map<SocketChannel, Timeout.Task> _connectingChannels = new ConcurrentHashMap<SocketChannel, Timeout.Task>();
|
private final Map<SocketChannel, Timeout.Task> _connectingChannels = new ConcurrentHashMap<SocketChannel, Timeout.Task>();
|
||||||
private SSLContext _sslContext;
|
private SSLContext _sslContext;
|
||||||
private Buffers _sslBuffers;
|
private Buffers _sslBuffers;
|
||||||
private boolean _blockingConnect;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param httpClient
|
* @param httpClient
|
||||||
|
@ -59,24 +57,6 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Get the blockingConnect.
|
|
||||||
* @return the blockingConnect
|
|
||||||
*/
|
|
||||||
public boolean isBlockingConnect()
|
|
||||||
{
|
|
||||||
return _blockingConnect;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Set the blockingConnect.
|
|
||||||
* @param blockingConnect If true, connections are made in blocking mode.
|
|
||||||
*/
|
|
||||||
public void setBlockingConnect(boolean blockingConnect)
|
|
||||||
{
|
|
||||||
_blockingConnect = blockingConnect;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws Exception
|
protected void doStart() throws Exception
|
||||||
|
@ -84,8 +64,8 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||||
super.doStart();
|
super.doStart();
|
||||||
_connectTimer.setDuration(_httpClient.getConnectTimeout());
|
_connectTimer.setDuration(_httpClient.getConnectTimeout());
|
||||||
_connectTimer.setNow();
|
_connectTimer.setNow();
|
||||||
|
|
||||||
if (_httpClient.isAsyncConnects())
|
if (!_httpClient.isConnectBlocking())
|
||||||
{
|
{
|
||||||
_httpClient._threadPool.dispatch(new Runnable()
|
_httpClient._threadPool.dispatch(new Runnable()
|
||||||
{
|
{
|
||||||
|
@ -107,7 +87,7 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_selectorManager.start();
|
_selectorManager.start();
|
||||||
|
|
||||||
final boolean direct=_httpClient.getUseDirectBuffers();
|
final boolean direct=_httpClient.getUseDirectBuffers();
|
||||||
|
@ -170,7 +150,7 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||||
Address address = destination.isProxied() ? destination.getProxy() : destination.getAddress();
|
Address address = destination.isProxied() ? destination.getProxy() : destination.getAddress();
|
||||||
channel.socket().setTcpNoDelay(true);
|
channel.socket().setTcpNoDelay(true);
|
||||||
|
|
||||||
if (_httpClient.isAsyncConnects())
|
if (!_httpClient.isConnectBlocking())
|
||||||
{
|
{
|
||||||
channel.configureBlocking( false );
|
channel.configureBlocking( false );
|
||||||
channel.connect(address.toSocketAddress());
|
channel.connect(address.toSocketAddress());
|
||||||
|
@ -189,7 +169,7 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||||
|
|
||||||
_selectorManager.register( channel, destination );
|
_selectorManager.register( channel, destination );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(IOException ex)
|
catch(IOException ex)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue