@@ -77,6 +77,7 @@ public class AsyncHttpClientConfig {
77
77
private final boolean allowSslConnectionPool ;
78
78
private final boolean useRawUrl ;
79
79
private final boolean removeQueryParamOnRedirect ;
80
+ private final int ioThreadMultiplier ;
80
81
81
82
private AsyncHttpClientConfig (int maxTotalConnections ,
82
83
int maxConnectionPerHost ,
@@ -102,7 +103,8 @@ private AsyncHttpClientConfig(int maxTotalConnections,
102
103
int maxRequestRetry ,
103
104
boolean allowSslConnectionCaching ,
104
105
boolean useRawUrl ,
105
- boolean removeQueryParamOnRedirect ) {
106
+ boolean removeQueryParamOnRedirect ,
107
+ int ioThreadMultiplier ) {
106
108
107
109
this .maxTotalConnections = maxTotalConnections ;
108
110
this .maxConnectionPerHost = maxConnectionPerHost ;
@@ -127,6 +129,7 @@ private AsyncHttpClientConfig(int maxTotalConnections,
127
129
this .reaper = reaper ;
128
130
this .allowSslConnectionPool = allowSslConnectionCaching ;
129
131
this .removeQueryParamOnRedirect = removeQueryParamOnRedirect ;
132
+ this .ioThreadMultiplier = ioThreadMultiplier ;
130
133
131
134
if (applicationThreadPool == null ) {
132
135
this .applicationThreadPool = Executors .newCachedThreadPool ();
@@ -406,6 +409,13 @@ public boolean isRemoveQueryParamOnRedirect() {
406
409
return removeQueryParamOnRedirect ;
407
410
}
408
411
412
+ /***
413
+ *
414
+ * @return number to multiply by availableProcessors() that will determine # of NioWorkers to use
415
+ */
416
+ public int getIoThreadMultiplier () {
417
+ return ioThreadMultiplier ;
418
+ }
409
419
410
420
/**
411
421
* Builder for an {@link AsyncHttpClient}
@@ -450,6 +460,7 @@ public Thread newThread(Runnable r) {
450
460
private boolean allowSslConnectionPool = true ;
451
461
private boolean useRawUrl = false ;
452
462
private boolean removeQueryParamOnRedirect = true ;
463
+ private int ioThreadMultiplier = 2 ;
453
464
454
465
public Builder () {
455
466
}
@@ -839,6 +850,11 @@ public Builder setUseProxyProperties(boolean useProxyProperties) {
839
850
return this ;
840
851
}
841
852
853
+ public Builder setIOThreadMultiplier (int multiplier ){
854
+ this .ioThreadMultiplier = multiplier ;
855
+ return this ;
856
+ }
857
+
842
858
/**
843
859
* Create a config builder with values taken from the given prototype configuration.
844
860
*
@@ -867,6 +883,7 @@ public Builder(AsyncHttpClientConfig prototype) {
867
883
requestFilters .addAll (prototype .getRequestFilters ());
868
884
responseFilters .addAll (prototype .getResponseFilters ());
869
885
useRawUrl = prototype .isUseRawUrl ();
886
+ ioThreadMultiplier = prototype .getIoThreadMultiplier ();
870
887
}
871
888
872
889
/**
@@ -904,7 +921,8 @@ public AsyncHttpClientConfig build() {
904
921
maxRequestRetry ,
905
922
allowSslConnectionPool ,
906
923
useRawUrl ,
907
- removeQueryParamOnRedirect );
924
+ removeQueryParamOnRedirect ,
925
+ ioThreadMultiplier );
908
926
}
909
927
}
910
928
}
0 commit comments