Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IO thread count config #13

Closed
wants to merge 113 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
a7b0fcd
clear query parameters before redirect
jloomis Mar 31, 2011
fcdcec9
Merge remote branch 'origin/master'
jloomis Apr 14, 2011
95fc68b
add io thread config param
jloomis Apr 29, 2011
ce5de4c
Improve logging
jfarcand Apr 14, 2011
adee622
Revert that change as it is better to inform than nothing
jfarcand Apr 18, 2011
27dcdf1
Remote test are evil, but make sute it pass all the time
jfarcand Apr 18, 2011
9731df0
Reenable the test - AHC 69
jfarcand Apr 20, 2011
4b1d3a9
Disable as I was able to make it fail on win32
jfarcand Apr 20, 2011
0af7c74
Fix for https://issues.sonatype.org/browse/AHC-69
jfarcand Apr 20, 2011
a0e8986
Fix for https://issues.sonatype.org/browse/AHC-74
jfarcand Apr 20, 2011
de301cd
Allow configuring File region for concurrent upload
jfarcand Apr 20, 2011
a1efd61
Make sure we are backward compatible
jfarcand Apr 20, 2011
65dce8e
Fix for AHC-74 with this provider
jfarcand Apr 20, 2011
ba3d175
Fix for AHC 74 for JDK provider
jfarcand Apr 20, 2011
a58faed
Disable as I was able to make it fail on win32
jfarcand Apr 20, 2011
0518a12
Fix for https://issues.sonatype.org/browse/AHC-69
jfarcand Apr 20, 2011
47fe1bb
o Do not pick up proxy properties by default in JDKAsyncHttpProvider …
nabcos Apr 20, 2011
e296006
Proper ifix for AHC 69
jfarcand Apr 20, 2011
f5abb73
Fix for https://issues.sonatype.org/browse/AHC-77
jfarcand Apr 21, 2011
ebd25c1
Delete the file on exit
jfarcand Apr 21, 2011
e55bc41
Make sure we write only the requested number of bytes
jfarcand Apr 21, 2011
9fe560e
Delete generated junk on exit
jfarcand Apr 21, 2011
34532d0
Improve the test so other provider implementation works as well (griz…
jfarcand Apr 25, 2011
34ce153
Add an API to detect if an config is valid or not
jfarcand Apr 27, 2011
9e8ec7e
Make sure we always cancel the reaper when an IOException occurs
jfarcand Apr 29, 2011
ea81e52
Fix for https://issues.sonatype.org/browse/AHC-80
jfarcand Apr 29, 2011
797fb1c
More work on AHC-80: Make sure the Future hasn't timedout or already …
jfarcand Apr 29, 2011
10f2d8d
Disable the test as the site is down
jfarcand Apr 29, 2011
6abe7af
More fix on AHC-80: patch provided by Steve Katz
jfarcand Apr 29, 2011
7ea00cc
Fix for https://issues.sonatype.org/browse/AHC-79
jfarcand Apr 29, 2011
b3d8baf
More work for AHC-79: try to rechallenge event if there is no auth
jfarcand Apr 29, 2011
ec7317b
Increase the timeout value to avoid test failure on loaded Hudson ins…
jfarcand Apr 29, 2011
2f4472a
Fix for https://issues.sonatype.org/browse/AHC-81
jfarcand May 3, 2011
f32acfb
Fix license headers, no functional changes
jfarcand May 3, 2011
204958d
Handle larger files in multi-part request.
gailh May 3, 2011
588be96
Fix for https://issues.sonatype.org/browse/AHC-83
jfarcand May 4, 2011
723f19b
support for cookies on 302 redirect
marekzebrowski May 4, 2011
f17ee3b
Reformat, improve cookie parsing robusness
jfarcand May 4, 2011
513e3bd
Fixed errors from unit test.
gailh May 4, 2011
3aa6452
Removed fixes for newer version of jetty.
gailh May 4, 2011
cd3908a
Fix for https://issues.sonatype.org/browse/AHC-87
jfarcand May 5, 2011
f8b6d55
Reformat, fix minor typo
jfarcand May 5, 2011
3506e7b
Make realm is not null
jfarcand May 5, 2011
1de1c2b
Small cleanup, no functional change
jfarcand May 5, 2011
2e61bda
Fix for https://issues.sonatype.org/browse/AHC-88
jfarcand May 5, 2011
7c87f7e
More work on AHC 88
jfarcand May 5, 2011
c9f6a34
AHC-69 on win fail again
jfarcand May 5, 2011
ef56446
Fix ClassCastException introduced by AHC-78. Test still failling, but…
jfarcand May 6, 2011
7ed119e
Make sure SSL works as well
jfarcand May 6, 2011
e4cdaed
Rollback fix for AHC-78 as it breaks many Sonatype internal project. …
jfarcand May 6, 2011
701047d
More work on AHC-79: use the proxy information after auth challenge
jfarcand May 9, 2011
118dc1d
Fix for https://issues.sonatype.org/browse/AHC-89
jfarcand May 9, 2011
a3d364a
Fix for https://issues.sonatype.org/browse/AHC-90
jfarcand May 9, 2011
f88cf4c
Incremental fix for https://issues.sonatype.org/browse/AHC-92
jfarcand May 10, 2011
f99a7db
Disable the test as the remote site is down
jfarcand May 10, 2011
2395de4
o Let derived SimpleAHC change realm settings
nabcos May 17, 2011
6604933
Revert changes to SimpleAHC because clirr does not allow addition of …
nabcos May 17, 2011
417ec26
Possibly fixed regression test issues.
gailh May 9, 2011
aa3b339
Fix for https://issues.sonatype.org/browse/AHC-94
jfarcand May 20, 2011
47466a9
Reformat, no functional changes
jfarcand May 20, 2011
ad19f89
Fix cut & paste typo
jfarcand May 20, 2011
d6e5a0f
Add support for Kerberos to NTLM fallback
jfarcand May 20, 2011
5b5bafe
add io thread config param
jloomis Apr 29, 2011
a5d681b
Revert "add io thread config param"
jloomis May 20, 2011
056aaee
clear query parameters before redirect
jloomis Mar 31, 2011
5162df0
add io thread config param
jloomis Apr 29, 2011
a64294a
Reenable the test - AHC 69
jfarcand Apr 20, 2011
855074b
Disable as I was able to make it fail on win32
jfarcand Apr 20, 2011
9e0e79a
Fix for https://issues.sonatype.org/browse/AHC-69
jfarcand Apr 20, 2011
e9d3710
Allow configuring File region for concurrent upload
jfarcand Apr 20, 2011
b7ce43c
Make sure we are backward compatible
jfarcand Apr 20, 2011
2fadabf
Fix for AHC 74 for JDK provider
jfarcand Apr 20, 2011
31ce9f8
Disable as I was able to make it fail on win32
jfarcand Apr 20, 2011
308e738
Fix for https://issues.sonatype.org/browse/AHC-69
jfarcand Apr 20, 2011
e5c8886
Proper ifix for AHC 69
jfarcand Apr 20, 2011
284b501
Improve the test so other provider implementation works as well (griz…
jfarcand Apr 25, 2011
aa9f8fa
Add an API to detect if an config is valid or not
jfarcand Apr 27, 2011
785da71
Make sure we always cancel the reaper when an IOException occurs
jfarcand Apr 29, 2011
994c3aa
Fix for https://issues.sonatype.org/browse/AHC-80
jfarcand Apr 29, 2011
55b9ba8
Disable the test as the site is down
jfarcand Apr 29, 2011
542a20e
More fix on AHC-80: patch provided by Steve Katz
jfarcand Apr 29, 2011
604c24b
Fix for https://issues.sonatype.org/browse/AHC-79
jfarcand Apr 29, 2011
fb5954b
More work for AHC-79: try to rechallenge event if there is no auth
jfarcand Apr 29, 2011
6980e9b
Increase the timeout value to avoid test failure on loaded Hudson ins…
jfarcand Apr 29, 2011
130b59b
Fix for https://issues.sonatype.org/browse/AHC-81
jfarcand May 3, 2011
704e85d
Handle larger files in multi-part request.
gailh May 3, 2011
7ca75ff
support for cookies on 302 redirect
marekzebrowski May 4, 2011
ff90415
Reformat, improve cookie parsing robusness
jfarcand May 4, 2011
b6b0246
Fixed errors from unit test.
gailh May 4, 2011
9db3c7b
Removed fixes for newer version of jetty.
gailh May 4, 2011
525dd16
Fix for https://issues.sonatype.org/browse/AHC-87
jfarcand May 5, 2011
9b5f711
Reformat, fix minor typo
jfarcand May 5, 2011
195fda0
Make realm is not null
jfarcand May 5, 2011
7a9c3c3
Small cleanup, no functional change
jfarcand May 5, 2011
019df5f
Fix for https://issues.sonatype.org/browse/AHC-88
jfarcand May 5, 2011
b7326f9
More work on AHC 88
jfarcand May 5, 2011
c48fd34
AHC-69 on win fail again
jfarcand May 5, 2011
891bda0
Fix ClassCastException introduced by AHC-78. Test still failling, but…
jfarcand May 6, 2011
bedb921
Make sure SSL works as well
jfarcand May 6, 2011
948c25f
Rollback fix for AHC-78 as it breaks many Sonatype internal project. …
jfarcand May 6, 2011
7b41000
More work on AHC-79: use the proxy information after auth challenge
jfarcand May 9, 2011
d6e98bf
Fix for https://issues.sonatype.org/browse/AHC-90
jfarcand May 9, 2011
1f357f5
o Let derived SimpleAHC change realm settings
nabcos May 17, 2011
e6f1640
Revert changes to SimpleAHC because clirr does not allow addition of …
nabcos May 17, 2011
dc58b16
Possibly fixed regression test issues.
gailh May 9, 2011
2ed3fb8
Fix for https://issues.sonatype.org/browse/AHC-94
jfarcand May 20, 2011
dc59401
Reformat, no functional changes
jfarcand May 20, 2011
6ffd362
Fix cut & paste typo
jfarcand May 20, 2011
874fc94
Add support for Kerberos to NTLM fallback
jfarcand May 20, 2011
d949a73
add io thread config param
jloomis Apr 29, 2011
7ec2720
Revert "add io thread config param"
jloomis May 20, 2011
90bbd97
Merge remote branch 'jloomis/master'
jloomis May 20, 2011
fa796ad
get host from authority if uri.getHost null
jloomis May 11, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/main/java/com/ning/http/client/AsyncHttpClientConfig.java
Expand Up @@ -79,6 +79,7 @@ public class AsyncHttpClientConfig {
private final boolean allowSslConnectionPool;
private final boolean useRawUrl;
private final boolean removeQueryParamOnRedirect;
private final int ioThreadMultiplier;
private final HostnameVerifier hostnameVerifier;

private AsyncHttpClientConfig(int maxTotalConnections,
Expand Down Expand Up @@ -106,6 +107,7 @@ private AsyncHttpClientConfig(int maxTotalConnections,
boolean allowSslConnectionCaching,
boolean useRawUrl,
boolean removeQueryParamOnRedirect,
int ioThreadMultiplier,
HostnameVerifier hostnameVerifier) {

this.maxTotalConnections = maxTotalConnections;
Expand All @@ -131,6 +133,7 @@ private AsyncHttpClientConfig(int maxTotalConnections,
this.reaper = reaper;
this.allowSslConnectionPool = allowSslConnectionCaching;
this.removeQueryParamOnRedirect = removeQueryParamOnRedirect;
this.ioThreadMultiplier = ioThreadMultiplier;
this.hostnameVerifier = hostnameVerifier;

if (applicationThreadPool == null) {
Expand Down Expand Up @@ -411,6 +414,14 @@ public boolean isRemoveQueryParamOnRedirect() {
return removeQueryParamOnRedirect;
}

/***
*
* @return number to multiply by availableProcessors() that will determine # of NioWorkers to use
*/
public int getIoThreadMultiplier() {
return ioThreadMultiplier;
}

/**
* Return true if one of the {@link java.util.concurrent.ExecutorService} has been shutdown.
* @return true if one of the {@link java.util.concurrent.ExecutorService} has been shutdown.
Expand Down Expand Up @@ -470,6 +481,7 @@ public Thread newThread(Runnable r) {
private boolean allowSslConnectionPool = true;
private boolean useRawUrl = false;
private boolean removeQueryParamOnRedirect = true;
private int ioThreadMultiplier = 2;
private HostnameVerifier hostnameVerifier = new HostnameVerifier() {

public boolean verify( String s, SSLSession sslSession ) {
Expand Down Expand Up @@ -865,6 +877,11 @@ public Builder setUseProxyProperties(boolean useProxyProperties) {
return this;
}

public Builder setIOThreadMultiplier(int multiplier){
this.ioThreadMultiplier = multiplier;
return this;
}

/**
* Set the {@link HostnameVerifier}
* @param hostnameVerifier {@link HostnameVerifier}
Expand Down Expand Up @@ -903,6 +920,7 @@ public Builder(AsyncHttpClientConfig prototype) {
requestFilters.addAll(prototype.getRequestFilters());
responseFilters.addAll(prototype.getResponseFilters());
useRawUrl = prototype.isUseRawUrl();
ioThreadMultiplier = prototype.getIoThreadMultiplier();
}

/**
Expand Down Expand Up @@ -946,6 +964,7 @@ public AsyncHttpClientConfig build() {
allowSslConnectionPool,
useRawUrl,
removeQueryParamOnRedirect,
ioThreadMultiplier,
hostnameVerifier);
}
}
Expand Down
Expand Up @@ -23,6 +23,7 @@
import com.ning.http.client.ConnectionsPool;
import com.ning.http.client.Cookie;
import com.ning.http.client.FluentCaseInsensitiveStringsMap;
import com.ning.http.client.FluentStringsMap;
import com.ning.http.client.HttpResponseBodyPart;
import com.ning.http.client.HttpResponseHeaders;
import com.ning.http.client.HttpResponseStatus;
Expand Down Expand Up @@ -194,7 +195,9 @@ public NettyAsyncHttpProvider(AsyncHttpClientConfig config) {
} else {
e = Executors.newCachedThreadPool();
}
socketChannelFactory = new NioClientSocketChannelFactory(e, config.executorService());
int numWorkers = config.getIoThreadMultiplier()*Runtime.getRuntime().availableProcessors();
log.info("numWorkers=" + numWorkers);
socketChannelFactory = new NioClientSocketChannelFactory(e, config.executorService(), numWorkers);
}
plainBootstrap = new ClientBootstrap(socketChannelFactory);
secureBootstrap = new ClientBootstrap(socketChannelFactory);
Expand Down Expand Up @@ -486,7 +489,8 @@ private static HttpRequest construct(AsyncHttpClientConfig config,
HttpMethod m,
URI uri,
ChannelBuffer buffer) throws IOException {
String host = uri.getHost();

String host = AsyncHttpProviderUtils.getHost(uri);

if (request.getVirtualHost() != null) {
host = request.getVirtualHost();
Expand Down Expand Up @@ -880,7 +884,7 @@ private <T> ListenableFuture<T> doConnect(final Request request, final AsyncHand

try {
if (proxyServer == null || avoidProxy) {
channelFuture = bootstrap.connect(new InetSocketAddress(uri.getHost(), AsyncHttpProviderUtils.getPort(uri)));
channelFuture = bootstrap.connect(new InetSocketAddress(AsyncHttpProviderUtils.getHost(uri), AsyncHttpProviderUtils.getPort(uri)));
} else {
channelFuture = bootstrap.connect(new InetSocketAddress(proxyServer.getHost(), proxyServer.getPort()));
}
Expand Down Expand Up @@ -1282,7 +1286,7 @@ private Realm kerberosChallenge(List<String> proxyAuth,
NettyResponseFuture<?> future) throws NTLMEngineException {

URI uri = URI.create(request.getUrl());
String host = request.getVirtualHost() == null ? uri.getHost() : request.getVirtualHost();
String host = request.getVirtualHost() == null ? AsyncHttpProviderUtils.getHost(uri) : request.getVirtualHost();
String server = proxyServer == null ? host : proxyServer.getHost();
try {
String challengeHeader = spnegoEngine.generateToken(server);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java
Expand Up @@ -175,6 +175,13 @@ public final static String getAuthority(URI uri) {
return url;
}

public final static String getHost(URI uri) {
String host = uri.getHost();
if (host == null) {
host = uri.getAuthority();
}
return host;
}

public final static URI getRedirectUri(URI uri, String location) {
URI newUri = uri.resolve(location);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ning/http/util/ProxyUtils.java
Expand Up @@ -71,7 +71,7 @@ public class ProxyUtils {
* @return true if we have to avoid proxy use (obeying non-proxy hosts settings), false otherwise.
*/
public static boolean avoidProxy(final ProxyServer proxyServer, final Request request) {
return avoidProxy(proxyServer, URI.create(request.getUrl()).getHost());
return avoidProxy(proxyServer, AsyncHttpProviderUtils.getHost(URI.create(request.getUrl())));
}

/**
Expand Down