AlbumenJ commented on code in PR #13599:
URL: https://github.com/apache/dubbo/pull/13599#discussion_r1444569259
##########
dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/restclient/OKHttpRestClient.java:
##########
@@ -136,15 +150,35 @@ public void close(int timeout) {}
@Override
public boolean isClosed() {
- return okHttpClient.retryOnConnectionFailure();
+ return false;
}
- public OkHttpClient createHttpClient(HttpClientConfig httpClientConfig) {
+ public OkHttpClient createHttpClient(HttpClientConfig httpClientConfig,
URL url) {
+ // reuse okHttpClient
+ if (this.okHttpClient != null) {
+ return okHttpClient;
+ }
+
+ Dispatcher dispatcher = new Dispatcher();
+ if (url != null) {
+ // use dubbo client thread pool to replace okhttp self thread pool
+ dispatcher = new Dispatcher(initRestClientExecutor(url));
+ }
+
OkHttpClient client = new OkHttpClient.Builder()
+ .dispatcher(dispatcher)
.readTimeout(httpClientConfig.getReadTimeout(),
TimeUnit.SECONDS)
.writeTimeout(httpClientConfig.getWriteTimeout(),
TimeUnit.SECONDS)
.connectTimeout(httpClientConfig.getConnectTimeout(),
TimeUnit.SECONDS)
.build();
return client;
}
+
+ private ExecutorService initRestClientExecutor(URL url) {
+ ExecutorRepository executorRepository =
ExecutorRepository.getInstance(url.getOrDefaultApplicationModel());
+
+ url = url.addParameter(THREAD_NAME_KEY, CLIENT_THREAD_POOL_NAME)
+ .addParameterIfAbsent(THREADPOOL_KEY,
DEFAULT_CLIENT_THREADPOOL);
+ return executorRepository.createExecutorIfAbsent(url);
+ }
Review Comment:
Should support isolated executors here.
[1] `org.apache.dubbo.rpc.executor.ExecutorSupport`
[2]
`org.apache.dubbo.remoting.transport.dispatcher.WrappedChannelHandler#getSharedExecutorService(java.lang.Object)`
[3]
`org.apache.dubbo.rpc.protocol.tri.h12.http2.GenericHttp2ServerTransportListener#initializeExecutor`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]