Skip to content

Commit

Permalink
Rename AllowPoolingConnections into KeepAlive
Browse files Browse the repository at this point in the history
  • Loading branch information
slandelle committed Oct 24, 2015
1 parent 80db591 commit 5db0ee2
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 34 deletions.
Expand Up @@ -119,7 +119,7 @@ public interface AsyncHttpClientConfig {
* *
* @return true if keep-alive is enabled * @return true if keep-alive is enabled
*/ */
boolean isAllowPoolingConnections(); boolean isKeepAlive();


/** /**
* Return the USER_AGENT header value * Return the USER_AGENT header value
Expand Down
Expand Up @@ -74,7 +74,7 @@ public class DefaultAsyncHttpClientConfig implements AsyncHttpClientConfig {
private final int readTimeout; private final int readTimeout;
private final int webSocketTimeout; private final int webSocketTimeout;


private final boolean allowPoolingConnections; private final boolean keepAlive;
private final int pooledConnectionIdleTimeout; private final int pooledConnectionIdleTimeout;
private final int connectionTtl; private final int connectionTtl;


Expand Down Expand Up @@ -121,7 +121,7 @@ private DefaultAsyncHttpClientConfig(int connectTimeout,//
int requestTimeout,// int requestTimeout,//
int readTimeout,// int readTimeout,//
int webSocketTimeout,// int webSocketTimeout,//
boolean allowPoolingConnection,// boolean keepAlive,//
int idleConnectionInPoolTimeout,// int idleConnectionInPoolTimeout,//
int connectionTtl,// int connectionTtl,//
SSLContext sslContext, // SSLContext sslContext, //
Expand Down Expand Up @@ -164,7 +164,7 @@ private DefaultAsyncHttpClientConfig(int connectTimeout,//
this.requestTimeout = requestTimeout; this.requestTimeout = requestTimeout;
this.readTimeout = readTimeout; this.readTimeout = readTimeout;
this.webSocketTimeout = webSocketTimeout; this.webSocketTimeout = webSocketTimeout;
this.allowPoolingConnections = allowPoolingConnection; this.keepAlive = keepAlive;
this.pooledConnectionIdleTimeout = idleConnectionInPoolTimeout; this.pooledConnectionIdleTimeout = idleConnectionInPoolTimeout;
this.connectionTtl = connectionTtl; this.connectionTtl = connectionTtl;
this.sslContext = sslContext; this.sslContext = sslContext;
Expand Down Expand Up @@ -271,8 +271,8 @@ public int getMaxRedirects() {
} }


@Override @Override
public boolean isAllowPoolingConnections() { public boolean isKeepAlive() {
return allowPoolingConnections; return keepAlive;
} }


@Override @Override
Expand Down Expand Up @@ -440,7 +440,7 @@ public static class Builder {
private int requestTimeout = defaultRequestTimeout(); private int requestTimeout = defaultRequestTimeout();
private int readTimeout = defaultReadTimeout(); private int readTimeout = defaultReadTimeout();
private int webSocketTimeout = defaultWebSocketTimeout(); private int webSocketTimeout = defaultWebSocketTimeout();
private boolean allowPoolingConnections = defaultAllowPoolingConnections(); private boolean keepAlive = defaultKeepAlive();
private int pooledConnectionIdleTimeout = defaultPooledConnectionIdleTimeout(); private int pooledConnectionIdleTimeout = defaultPooledConnectionIdleTimeout();
private int connectionTtl = defaultConnectionTtl(); private int connectionTtl = defaultConnectionTtl();
private SSLContext sslContext; private SSLContext sslContext;
Expand Down Expand Up @@ -489,7 +489,7 @@ public Builder(AsyncHttpClientConfig config) {
requestTimeout = config.getRequestTimeout(); requestTimeout = config.getRequestTimeout();
readTimeout = config.getReadTimeout(); readTimeout = config.getReadTimeout();
webSocketTimeout = config.getWebSocketTimeout(); webSocketTimeout = config.getWebSocketTimeout();
allowPoolingConnections = config.isAllowPoolingConnections(); keepAlive = config.isKeepAlive();
pooledConnectionIdleTimeout = config.getPooledConnectionIdleTimeout(); pooledConnectionIdleTimeout = config.getPooledConnectionIdleTimeout();
connectionTtl = config.getConnectionTtl(); connectionTtl = config.getConnectionTtl();
sslContext = config.getSslContext(); sslContext = config.getSslContext();
Expand Down Expand Up @@ -587,8 +587,8 @@ public Builder setUserAgent(String userAgent) {
return this; return this;
} }


public Builder setAllowPoolingConnections(boolean allowPoolingConnections) { public Builder setKeepAlive(boolean keepAlive) {
this.allowPoolingConnections = allowPoolingConnections; this.keepAlive = keepAlive;
return this; return this;
} }


Expand Down Expand Up @@ -784,7 +784,7 @@ public DefaultAsyncHttpClientConfig build() {
requestTimeout,// requestTimeout,//
readTimeout,// readTimeout,//
webSocketTimeout,// webSocketTimeout,//
allowPoolingConnections,// keepAlive,//
pooledConnectionIdleTimeout,// pooledConnectionIdleTimeout,//
connectionTtl,// connectionTtl,//
sslContext, // sslContext, //
Expand Down
Expand Up @@ -87,8 +87,8 @@ public static boolean defaultStrict302Handling() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT_CONFIG_ROOT + "strict302Handling"); return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT_CONFIG_ROOT + "strict302Handling");
} }


public static boolean defaultAllowPoolingConnections() { public static boolean defaultKeepAlive() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT_CONFIG_ROOT + "allowPoolingConnections"); return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT_CONFIG_ROOT + "keepAlive");
} }


public static int defaultMaxRequestRetry() { public static int defaultMaxRequestRetry() {
Expand Down
Expand Up @@ -111,7 +111,7 @@ public ChannelManager(final AsyncHttpClientConfig config, AdvancedConfig advance
this.sslEngineFactory = config.getSslEngineFactory() != null ? config.getSslEngineFactory() : new SSLEngineFactory.DefaultSSLEngineFactory(config); this.sslEngineFactory = config.getSslEngineFactory() != null ? config.getSslEngineFactory() : new SSLEngineFactory.DefaultSSLEngineFactory(config);


ChannelPool channelPool = advancedConfig.getChannelPool(); ChannelPool channelPool = advancedConfig.getChannelPool();
if (channelPool == null && config.isAllowPoolingConnections()) { if (channelPool == null && config.isKeepAlive()) {
channelPool = new DefaultChannelPool(config, nettyTimer); channelPool = new DefaultChannelPool(config, nettyTimer);
} else if (channelPool == null) { } else if (channelPool == null) {
channelPool = new NoopChannelPool(); channelPool = new NoopChannelPool();
Expand Down
Expand Up @@ -141,7 +141,7 @@ public NettyRequest newNettyRequest(Request request, boolean forceConnect, Proxy
HttpMethod method = forceConnect ? HttpMethod.CONNECT : HttpMethod.valueOf(request.getMethod()); HttpMethod method = forceConnect ? HttpMethod.CONNECT : HttpMethod.valueOf(request.getMethod());
boolean connect = method == HttpMethod.CONNECT; boolean connect = method == HttpMethod.CONNECT;


boolean allowConnectionPooling = config.isAllowPoolingConnections(); boolean allowConnectionPooling = config.isKeepAlive();


HttpVersion httpVersion = !allowConnectionPooling || (connect && proxyServer.isForceHttp10()) ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1; HttpVersion httpVersion = !allowConnectionPooling || (connect && proxyServer.isForceHttp10()) ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1;
String requestUri = requestUri(uri, proxyServer, connect); String requestUri = requestUri(uri, proxyServer, connect);
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/resources/ahc-default.properties
Expand Up @@ -15,7 +15,7 @@ org.asynchttpclient.enabledProtocols=TLSv1.2, TLSv1.1, TLSv1
org.asynchttpclient.useProxySelector=false org.asynchttpclient.useProxySelector=false
org.asynchttpclient.useProxyProperties=false org.asynchttpclient.useProxyProperties=false
org.asynchttpclient.strict302Handling=false org.asynchttpclient.strict302Handling=false
org.asynchttpclient.allowPoolingConnections=true org.asynchttpclient.keepAlive=true
org.asynchttpclient.requestCompressionLevel=-1 org.asynchttpclient.requestCompressionLevel=-1
org.asynchttpclient.maxRequestRetry=5 org.asynchttpclient.maxRequestRetry=5
org.asynchttpclient.disableUrlEncodingForBoundRequests=false org.asynchttpclient.disableUrlEncodingForBoundRequests=false
Expand Down
Expand Up @@ -88,7 +88,7 @@ public void testDefaultStrict302Handling() {
} }


public void testDefaultAllowPoolingConnection() { public void testDefaultAllowPoolingConnection() {
Assert.assertTrue(AsyncHttpClientConfigDefaults.defaultAllowPoolingConnections()); Assert.assertTrue(AsyncHttpClientConfigDefaults.defaultKeepAlive());
testBooleanSystemProperty("allowPoolingConnections", "defaultAllowPoolingConnections", "false"); testBooleanSystemProperty("allowPoolingConnections", "defaultAllowPoolingConnections", "false");
} }


Expand Down
Expand Up @@ -305,7 +305,7 @@ public void basicAuthAsyncConfigTest() throws Exception {


@Test(groups = { "standalone", "default_provider" }) @Test(groups = { "standalone", "default_provider" })
public void basicAuthFileNoKeepAliveTest() throws Exception { public void basicAuthFileNoKeepAliveTest() throws Exception {
try (AsyncHttpClient client = asyncHttpClient(config().setAllowPoolingConnections(false).build())) { try (AsyncHttpClient client = asyncHttpClient(config().setKeepAlive(false).build())) {


Future<Response> f = client.preparePost(getTargetUrl())// Future<Response> f = client.preparePost(getTargetUrl())//
.setBody(SIMPLE_TEXT_FILE)// .setBody(SIMPLE_TEXT_FILE)//
Expand Down
Expand Up @@ -38,7 +38,7 @@ public void multipleSslRequestsWithDelayAndKeepAlive() throws Exception {
AsyncHttpClientConfig config = config()// AsyncHttpClientConfig config = config()//
.setFollowRedirect(true)// .setFollowRedirect(true)//
.setSslContext(getSSLContext())// .setSslContext(getSSLContext())//
.setAllowPoolingConnections(true)// .setKeepAlive(true)//
.setConnectTimeout(10000)// .setConnectTimeout(10000)//
.setPooledConnectionIdleTimeout(60000)// .setPooledConnectionIdleTimeout(60000)//
.setRequestTimeout(10000)// .setRequestTimeout(10000)//
Expand Down
2 changes: 1 addition & 1 deletion client/src/test/java/org/asynchttpclient/RC10KTest.java
Expand Up @@ -92,7 +92,7 @@ public void handle(String s, Request r, HttpServletRequest req, HttpServletRespo


@Test(timeOut = 10 * 60 * 1000, groups = "scalability") @Test(timeOut = 10 * 60 * 1000, groups = "scalability")
public void rc10kProblem() throws IOException, ExecutionException, TimeoutException, InterruptedException { public void rc10kProblem() throws IOException, ExecutionException, TimeoutException, InterruptedException {
try (AsyncHttpClient ahc = asyncHttpClient(config().setMaxConnectionsPerHost(C10K).setAllowPoolingConnections(true).build())) { try (AsyncHttpClient ahc = asyncHttpClient(config().setMaxConnectionsPerHost(C10K).setKeepAlive(true).build())) {
List<Future<Integer>> resps = new ArrayList<>(C10K); List<Future<Integer>> resps = new ArrayList<>(C10K);
int i = 0; int i = 0;
while (i < C10K) { while (i < C10K) {
Expand Down
Expand Up @@ -67,7 +67,7 @@ public void setUp() throws Exception {
public void testGetRedirectFinalUrl() throws Exception { public void testGetRedirectFinalUrl() throws Exception {


AsyncHttpClientConfig config = config()// AsyncHttpClientConfig config = config()//
.setAllowPoolingConnections(true)// .setKeepAlive(true)//
.setMaxConnectionsPerHost(1)// .setMaxConnectionsPerHost(1)//
.setMaxConnections(1)// .setMaxConnections(1)//
.setConnectTimeout(1000)// .setConnectTimeout(1000)//
Expand Down
Expand Up @@ -123,7 +123,7 @@ public Response onCompleted(Response response) throws Exception {
@Test(groups = { "online", "default_provider" }, enabled = false) @Test(groups = { "online", "default_provider" }, enabled = false)
public void invalidStreamTest2() throws Exception { public void invalidStreamTest2() throws Exception {
AsyncHttpClientConfig config = config().setRequestTimeout(10000).setFollowRedirect(true) AsyncHttpClientConfig config = config().setRequestTimeout(10000).setFollowRedirect(true)
.setAllowPoolingConnections(false).setMaxRedirects(6).build(); .setKeepAlive(false).setMaxRedirects(6).build();


try (AsyncHttpClient c = asyncHttpClient(config)) { try (AsyncHttpClient c = asyncHttpClient(config)) {
Response response = c.prepareGet("http://bit.ly/aUjTtG").execute().get(); Response response = c.prepareGet("http://bit.ly/aUjTtG").execute().get();
Expand Down
Expand Up @@ -54,7 +54,7 @@ public void testMaxConnectionsWithinThreads() throws Exception {


String[] urls = new String[] { servletEndpointUri.toString(), servletEndpointUri.toString() }; String[] urls = new String[] { servletEndpointUri.toString(), servletEndpointUri.toString() };


AsyncHttpClientConfig config = config().setConnectTimeout(1000).setRequestTimeout(5000).setAllowPoolingConnections(true)// AsyncHttpClientConfig config = config().setConnectTimeout(1000).setRequestTimeout(5000).setKeepAlive(true)//
.setMaxConnections(1).setMaxConnectionsPerHost(1).build(); .setMaxConnections(1).setMaxConnectionsPerHost(1).build();


final CountDownLatch inThreadsLatch = new CountDownLatch(2); final CountDownLatch inThreadsLatch = new CountDownLatch(2);
Expand Down
Expand Up @@ -43,7 +43,7 @@ public void testMaxTotalConnectionsExceedingException() throws IOException {
String[] urls = new String[] { "http://google.com", "http://github.com/" }; String[] urls = new String[] { "http://google.com", "http://github.com/" };


AsyncHttpClientConfig config = config().setConnectTimeout(1000) AsyncHttpClientConfig config = config().setConnectTimeout(1000)
.setRequestTimeout(5000).setAllowPoolingConnections(false).setMaxConnections(1).setMaxConnectionsPerHost(1) .setRequestTimeout(5000).setKeepAlive(false).setMaxConnections(1).setMaxConnectionsPerHost(1)
.build(); .build();


try (AsyncHttpClient client = asyncHttpClient(config)) { try (AsyncHttpClient client = asyncHttpClient(config)) {
Expand Down Expand Up @@ -78,7 +78,7 @@ public void testMaxTotalConnections() throws Exception {
final AtomicReference<String> failedUrl = new AtomicReference<>(); final AtomicReference<String> failedUrl = new AtomicReference<>();


AsyncHttpClientConfig config = config().setConnectTimeout(1000).setRequestTimeout(5000) AsyncHttpClientConfig config = config().setConnectTimeout(1000).setRequestTimeout(5000)
.setAllowPoolingConnections(false).setMaxConnections(2).setMaxConnectionsPerHost(1).build(); .setKeepAlive(false).setMaxConnections(2).setMaxConnectionsPerHost(1).build();


try (AsyncHttpClient client = asyncHttpClient(config)) { try (AsyncHttpClient client = asyncHttpClient(config)) {
for (String url : urls) { for (String url : urls) {
Expand Down
Expand Up @@ -49,7 +49,7 @@ public class ConnectionPoolTest extends AbstractBasicTest {


@Test(groups = { "standalone", "default_provider" }) @Test(groups = { "standalone", "default_provider" })
public void testMaxTotalConnections() throws Exception { public void testMaxTotalConnections() throws Exception {
try (AsyncHttpClient client = asyncHttpClient(config().setAllowPoolingConnections(true).setMaxConnections(1))) { try (AsyncHttpClient client = asyncHttpClient(config().setKeepAlive(true).setMaxConnections(1))) {
String url = getTargetUrl(); String url = getTargetUrl();
int i; int i;
Exception exception = null; Exception exception = null;
Expand All @@ -68,7 +68,7 @@ public void testMaxTotalConnections() throws Exception {


@Test(groups = { "standalone", "default_provider" }) @Test(groups = { "standalone", "default_provider" })
public void testMaxTotalConnectionsException() throws IOException { public void testMaxTotalConnectionsException() throws IOException {
try (AsyncHttpClient client = asyncHttpClient(config().setAllowPoolingConnections(true).setMaxConnections(1))) { try (AsyncHttpClient client = asyncHttpClient(config().setKeepAlive(true).setMaxConnections(1))) {
String url = getTargetUrl(); String url = getTargetUrl();


List<ListenableFuture<Response>> futures = new ArrayList<>(); List<ListenableFuture<Response>> futures = new ArrayList<>();
Expand Down Expand Up @@ -131,7 +131,7 @@ public Response onCompleted(Response response) throws Exception {


@Test(groups = { "standalone", "default_provider" }) @Test(groups = { "standalone", "default_provider" })
public void multipleMaxConnectionOpenTest() throws Exception { public void multipleMaxConnectionOpenTest() throws Exception {
AsyncHttpClientConfig cg = config().setAllowPoolingConnections(true).setConnectTimeout(5000).setMaxConnections(1).build(); AsyncHttpClientConfig cg = config().setKeepAlive(true).setConnectTimeout(5000).setMaxConnections(1).build();
try (AsyncHttpClient c = asyncHttpClient(cg)) { try (AsyncHttpClient c = asyncHttpClient(cg)) {
String body = "hello there"; String body = "hello there";


Expand All @@ -157,7 +157,7 @@ public void multipleMaxConnectionOpenTest() throws Exception {


@Test(groups = { "standalone", "default_provider" }) @Test(groups = { "standalone", "default_provider" })
public void multipleMaxConnectionOpenTestWithQuery() throws Exception { public void multipleMaxConnectionOpenTestWithQuery() throws Exception {
AsyncHttpClientConfig cg = config().setAllowPoolingConnections(true).setConnectTimeout(5000).setMaxConnections(1).build(); AsyncHttpClientConfig cg = config().setKeepAlive(true).setConnectTimeout(5000).setMaxConnections(1).build();
try (AsyncHttpClient c = asyncHttpClient(cg)) { try (AsyncHttpClient c = asyncHttpClient(cg)) {
String body = "hello there"; String body = "hello there";


Expand Down
Expand Up @@ -83,7 +83,7 @@ private ListenableFuture<Response> testMethodRequest(AsyncHttpClient client, int
public void testRetryNonBlocking() throws IOException, InterruptedException, ExecutionException { public void testRetryNonBlocking() throws IOException, InterruptedException, ExecutionException {


AsyncHttpClientConfig config = config()// AsyncHttpClientConfig config = config()//
.setAllowPoolingConnections(true)// .setKeepAlive(true)//
.setMaxConnections(100)// .setMaxConnections(100)//
.setConnectTimeout(60000)// .setConnectTimeout(60000)//
.setRequestTimeout(30000)// .setRequestTimeout(30000)//
Expand Down Expand Up @@ -114,7 +114,7 @@ public void testRetryNonBlocking() throws IOException, InterruptedException, Exe
public void testRetryNonBlockingAsyncConnect() throws IOException, InterruptedException, ExecutionException { public void testRetryNonBlockingAsyncConnect() throws IOException, InterruptedException, ExecutionException {


AsyncHttpClientConfig config = config()// AsyncHttpClientConfig config = config()//
.setAllowPoolingConnections(true)// .setKeepAlive(true)//
.setMaxConnections(100)// .setMaxConnections(100)//
.setConnectTimeout(60000)// .setConnectTimeout(60000)//
.setRequestTimeout(30000)// .setRequestTimeout(30000)//
Expand Down
Expand Up @@ -110,7 +110,7 @@ private void feed(FeedableBodyGenerator feedableBodyGenerator, InputStream is) t


private DefaultAsyncHttpClientConfig.Builder httpClientBuilder() { private DefaultAsyncHttpClientConfig.Builder httpClientBuilder() {
return config()// return config()//
.setAllowPoolingConnections(true)// .setKeepAlive(true)//
.setMaxConnectionsPerHost(1)// .setMaxConnectionsPerHost(1)//
.setMaxConnections(1)// .setMaxConnections(1)//
.setConnectTimeout(1000)// .setConnectTimeout(1000)//
Expand Down
Expand Up @@ -546,8 +546,8 @@ public Builder setUserAgent(String userAgent) {
return this; return this;
} }


public Builder setAllowPoolingConnections(boolean allowPoolingConnections) { public Builder setKeepAlive(boolean allowPoolingConnections) {
configBuilder.setAllowPoolingConnections(allowPoolingConnections); configBuilder.setKeepAlive(allowPoolingConnections);
return this; return this;
} }


Expand Down

0 comments on commit 5db0ee2

Please sign in to comment.