@@ -80,6 +80,7 @@ public class AsyncHttpClientConfig {
80
80
private final boolean useRawUrl ;
81
81
private final boolean removeQueryParamOnRedirect ;
82
82
private final HostnameVerifier hostnameVerifier ;
83
+ private final int ioThreadMultiplier ;
83
84
84
85
private AsyncHttpClientConfig (int maxTotalConnections ,
85
86
int maxConnectionPerHost ,
@@ -106,7 +107,8 @@ private AsyncHttpClientConfig(int maxTotalConnections,
106
107
boolean allowSslConnectionCaching ,
107
108
boolean useRawUrl ,
108
109
boolean removeQueryParamOnRedirect ,
109
- HostnameVerifier hostnameVerifier ) {
110
+ HostnameVerifier hostnameVerifier ,
111
+ int ioThreadMultiplier ) {
110
112
111
113
this .maxTotalConnections = maxTotalConnections ;
112
114
this .maxConnectionPerHost = maxConnectionPerHost ;
@@ -132,6 +134,7 @@ private AsyncHttpClientConfig(int maxTotalConnections,
132
134
this .allowSslConnectionPool = allowSslConnectionCaching ;
133
135
this .removeQueryParamOnRedirect = removeQueryParamOnRedirect ;
134
136
this .hostnameVerifier = hostnameVerifier ;
137
+ this .ioThreadMultiplier = ioThreadMultiplier ;
135
138
136
139
if (applicationThreadPool == null ) {
137
140
this .applicationThreadPool = Executors .newCachedThreadPool ();
@@ -426,6 +429,13 @@ public boolean isClosed(){
426
429
public HostnameVerifier getHostnameVerifier () {
427
430
return hostnameVerifier ;
428
431
}
432
+ /***
433
+ *
434
+ * @return number to multiply by availableProcessors() that will determine # of NioWorkers to use
435
+ */
436
+ public int getIoThreadMultiplier () {
437
+ return ioThreadMultiplier ;
438
+ }
429
439
430
440
/**
431
441
* Builder for an {@link AsyncHttpClient}
@@ -476,6 +486,7 @@ public boolean verify( String s, SSLSession sslSession ) {
476
486
return true ;
477
487
}
478
488
};
489
+ private int ioThreadMultiplier = 2 ;
479
490
480
491
public Builder () {
481
492
}
@@ -865,6 +876,11 @@ public Builder setUseProxyProperties(boolean useProxyProperties) {
865
876
return this ;
866
877
}
867
878
879
+ public Builder setIOThreadMultiplier (int multiplier ){
880
+ this .ioThreadMultiplier = multiplier ;
881
+ return this ;
882
+ }
883
+
868
884
/**
869
885
* Set the {@link HostnameVerifier}
870
886
* @param hostnameVerifier {@link HostnameVerifier}
@@ -903,6 +919,7 @@ public Builder(AsyncHttpClientConfig prototype) {
903
919
requestFilters .addAll (prototype .getRequestFilters ());
904
920
responseFilters .addAll (prototype .getResponseFilters ());
905
921
useRawUrl = prototype .isUseRawUrl ();
922
+ ioThreadMultiplier = prototype .getIoThreadMultiplier ();
906
923
}
907
924
908
925
/**
@@ -946,7 +963,8 @@ public AsyncHttpClientConfig build() {
946
963
allowSslConnectionPool ,
947
964
useRawUrl ,
948
965
removeQueryParamOnRedirect ,
949
- hostnameVerifier );
966
+ hostnameVerifier ,
967
+ ioThreadMultiplier );
950
968
}
951
969
}
952
970
}
0 commit comments