Skip to content

Commit

Permalink
enhance comments, javadoc and logging message for (#1722)
Browse files Browse the repository at this point in the history
ExecutionChannelHandler
  • Loading branch information
beiwei30 authored May 2, 2018
1 parent 080e8ef commit b9b98c8
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -41,21 +45,22 @@ 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);
channel.send(response);
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);
Expand Down

0 comments on commit b9b98c8

Please sign in to comment.