From b9b98c83cf7e6e27caef3d7b65967f2e8394f762 Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Wed, 2 May 2018 14:26:39 +0800 Subject: [PATCH] enhance comments, javadoc and logging message for (#1722) ExecutionChannelHandler --- .../execution/ExecutionChannelHandler.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionChannelHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionChannelHandler.java index 91b58043174..8a19bdd5a3d 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionChannelHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionChannelHandler.java @@ -29,6 +29,10 @@ import java.util.concurrent.RejectedExecutionException; +/** + * Only request message will be dispatched to thread pool. Other messages like response, connect, disconnect, + * heartbeat will be directly executed by I/O thread. + */ public class ExecutionChannelHandler extends WrappedChannelHandler { public ExecutionChannelHandler(ChannelHandler handler, URL url) { @@ -41,13 +45,14 @@ public void received(Channel channel, Object message) throws RemotingException { try { executor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message)); } catch (Throwable t) { - //TODO A temporary solution to the problem that the exception information can not be sent to the opposite end after the thread pool is full. Need a refactoring - //fix The thread pool is full, refuses to call, does not return, and causes the consumer to wait for time out + // FIXME: when the thread pool is full, SERVER_THREADPOOL_EXHAUSTED_ERROR cannot return properly, + // therefore the consumer side has to wait until gets timeout. This is a temporary solution to prevent + // this scenario from happening, but a better solution should be considered later. if (t instanceof RejectedExecutionException) { Request request = (Request) message; if (request.isTwoWay()) { String msg = "Server side(" + url.getIp() + "," + url.getPort() - + ") threadpool is exhausted ,detail msg:" + t.getMessage(); + + ") thread pool is exhausted, detail msg:" + t.getMessage(); Response response = new Response(request.getId(), request.getVersion()); response.setStatus(Response.SERVER_THREADPOOL_EXHAUSTED_ERROR); response.setErrorMessage(msg); @@ -55,7 +60,7 @@ public void received(Channel channel, Object message) throws RemotingException { return; } } - throw new ExecutionException(message, channel, getClass() + " error when process received event .", t); + throw new ExecutionException(message, channel, getClass() + " error when process received event.", t); } } else { handler.received(channel, message);