From 377853e0486dc10c1350396212f6520d8c11f175 Mon Sep 17 00:00:00 2001 From: qct Date: Sat, 10 Mar 2018 08:14:10 +0000 Subject: [PATCH 1/2] fixes #1089, make ExecutionDispatcher meets dubbo-user-book --- .../execution/ExecutionChannelHandler.java | 56 ++++++++----------- 1 file changed, 22 insertions(+), 34 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 2cb46348608..69caf698e5b 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 @@ -35,42 +35,30 @@ public ExecutionChannelHandler(ChannelHandler handler, URL url) { super(handler, url); } - @Override - public void connected(Channel channel) throws RemotingException { - executor.execute(new ChannelEventRunnable(channel, handler, ChannelState.CONNECTED)); - } - - @Override - public void disconnected(Channel channel) throws RemotingException { - executor.execute(new ChannelEventRunnable(channel, handler, ChannelState.DISCONNECTED)); - } - @Override 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 - if(message instanceof Request && - 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(); - Response response = new Response(request.getId(), request.getVersion()); - response.setStatus(Response.SERVER_THREADPOOL_EXHAUSTED_ERROR); - response.setErrorMessage(msg); - channel.send(response); - return; - } - } - throw new ExecutionException(message, channel, getClass() + " error when process received event .", t); + if (message instanceof Request && !((Request) message).isHeartbeat()) { + 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 + 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(); + Response response = new Response(request.getId(), request.getVersion()); + response.setStatus(Response.SERVER_THREADPOOL_EXHAUSTED_ERROR); + response.setErrorMessage(msg); + channel.send(response); + return; + } + } + throw new ExecutionException(message, channel, getClass() + " error when process received event .", t); + } + } else { + handler.received(channel, message); } } - - @Override - public void caught(Channel channel, Throwable exception) throws RemotingException { - executor.execute(new ChannelEventRunnable(channel, handler, ChannelState.CAUGHT, exception)); - } - } From d4382396a2d5b36d5df002c24d8fe320a05cb127 Mon Sep 17 00:00:00 2001 From: qct Date: Wed, 14 Mar 2018 06:26:19 +0000 Subject: [PATCH 2/2] remove heartbeat condition --- .../transport/dispatcher/execution/ExecutionChannelHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 69caf698e5b..91b58043174 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 @@ -37,7 +37,7 @@ public ExecutionChannelHandler(ChannelHandler handler, URL url) { @Override public void received(Channel channel, Object message) throws RemotingException { - if (message instanceof Request && !((Request) message).isHeartbeat()) { + if (message instanceof Request) { try { executor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message)); } catch (Throwable t) {