com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.ChannelState Java Examples

The following examples show how to use com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.ChannelState. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectionOrderedChannelHandler.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = getExecutorService();
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        //fix, reject exception can not be sent to consumer because thread pool is full, resulting in consumers waiting till timeout. 修复,由于线程池已满,拒绝异常无法发送给使用者,导致使用者等待超时。
        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);
    }
}
 
Example #2
Source File: AllChannelHandler.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
    public void received(Channel channel, Object message) throws RemotingException {
//        获取缓存线程池
        ExecutorService cexecutor = getExecutorService();
        try {
//            com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run()
            cexecutor.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);
        }
    }
 
Example #3
Source File: MessageOnlyChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = executor;
    if (cexecutor == null || cexecutor.isShutdown()) {
        cexecutor = SHARED_EXECUTOR;
    }
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
Example #4
Source File: ExecutionChannelHandler.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = getExecutorService();
    if (message instanceof Request) {
        try {
            cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
        } catch (Throwable t) {
            // FIXME: when the thread pool is full, SERVER_THREADPOOL_EXHAUSTED_ERROR cannot return properly, 当线程池满时,server_threadpool_sted_error不能正确返回,
            // 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()
                            + ") 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);
        }
    } else {
        handler.received(channel, message);
    }
}
 
Example #5
Source File: AllChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = getExecutorService();
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
Example #6
Source File: AllChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void disconnected(Channel channel) throws RemotingException {
    ExecutorService cexecutor = getExecutorService(); 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.DISCONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("disconnect event", channel, getClass()+" error when process disconnected event ." , t);
    }
}
 
Example #7
Source File: AllChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void connected(Channel channel) throws RemotingException {
    ExecutorService cexecutor = getExecutorService(); 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("connect event", channel, getClass()+" error when process connected event ." , t);
    }
}
 
Example #8
Source File: ConnectionOrderedChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void disconnected(Channel channel) throws RemotingException {
    try{
        checkQueueLength();
        connectionExecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.DISCONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("disconnected event", channel, getClass()+" error when process disconnected event ." , t);
    }
}
 
Example #9
Source File: ConnectionOrderedChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = executor;
    if (cexecutor == null || cexecutor.isShutdown()) {
        cexecutor = SHARED_EXECUTOR;
    }
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
Example #10
Source File: ConnectionOrderedChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void caught(Channel channel, Throwable exception) throws RemotingException {
    ExecutorService cexecutor = executor;
    if (cexecutor == null || cexecutor.isShutdown()) { 
        cexecutor = SHARED_EXECUTOR;
    } 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CAUGHT, exception));
    }catch (Throwable t) {
        throw new ExecutionException("caught event", channel, getClass()+" error when process caught event ." , t);
    }
}
 
Example #11
Source File: AllChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void connected(Channel channel) throws RemotingException {
    ExecutorService cexecutor = getExecutorService(); 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("connect event", channel, getClass()+" error when process connected event ." , t);
    }
}
 
Example #12
Source File: AllChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void disconnected(Channel channel) throws RemotingException {
    ExecutorService cexecutor = getExecutorService(); 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.DISCONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("disconnect event", channel, getClass()+" error when process disconnected event ." , t);
    }
}
 
Example #13
Source File: AllChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = getExecutorService();
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
Example #14
Source File: AllChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void caught(Channel channel, Throwable exception) throws RemotingException {
    ExecutorService cexecutor = getExecutorService(); 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CAUGHT, exception));
    }catch (Throwable t) {
        throw new ExecutionException("caught event", channel, getClass()+" error when process caught event ." , t);
    }
}
 
Example #15
Source File: ConnectionOrderedChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void connected(Channel channel) throws RemotingException {
    try{
        checkQueueLength();
        connectionExecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("connect event", channel, getClass()+" error when process connected event ." , t);
    }
}
 
Example #16
Source File: ConnectionOrderedChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void disconnected(Channel channel) throws RemotingException {
    try{
        checkQueueLength();
        connectionExecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.DISCONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("disconnected event", channel, getClass()+" error when process disconnected event ." , t);
    }
}
 
Example #17
Source File: ConnectionOrderedChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void connected(Channel channel) throws RemotingException {
    try{
        checkQueueLength();
        connectionExecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("connect event", channel, getClass()+" error when process connected event ." , t);
    }
}
 
Example #18
Source File: ConnectionOrderedChannelHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void caught(Channel channel, Throwable exception) throws RemotingException {
    ExecutorService cexecutor = executor;
    if (cexecutor == null || cexecutor.isShutdown()) { 
        cexecutor = SHARED_EXECUTOR;
    } 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CAUGHT, exception));
    }catch (Throwable t) {
        throw new ExecutionException("caught event", channel, getClass()+" error when process caught event ." , t);
    }
}
 
Example #19
Source File: AllChannelHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void caught(Channel channel, Throwable exception) throws RemotingException {
    ExecutorService cexecutor = getExecutorService(); 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CAUGHT, exception));
    }catch (Throwable t) {
        throw new ExecutionException("caught event", channel, getClass()+" error when process caught event ." , t);
    }
}
 
Example #20
Source File: AllChannelHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = getExecutorService();
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
Example #21
Source File: AllChannelHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void disconnected(Channel channel) throws RemotingException {
    ExecutorService cexecutor = getExecutorService(); 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.DISCONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("disconnect event", channel, getClass()+" error when process disconnected event ." , t);
    }
}
 
Example #22
Source File: AllChannelHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void connected(Channel channel) throws RemotingException {
    ExecutorService cexecutor = getExecutorService(); 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("connect event", channel, getClass()+" error when process connected event ." , t);
    }
}
 
Example #23
Source File: ConnectionOrderedChannelHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void caught(Channel channel, Throwable exception) throws RemotingException {
    ExecutorService cexecutor = executor;
    if (cexecutor == null || cexecutor.isShutdown()) { 
        cexecutor = SHARED_EXECUTOR;
    } 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CAUGHT, exception));
    }catch (Throwable t) {
        throw new ExecutionException("caught event", channel, getClass()+" error when process caught event ." , t);
    }
}
 
Example #24
Source File: ConnectionOrderedChannelHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = executor;
    if (cexecutor == null || cexecutor.isShutdown()) {
        cexecutor = SHARED_EXECUTOR;
    }
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
Example #25
Source File: ConnectionOrderedChannelHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void disconnected(Channel channel) throws RemotingException {
    try{
        checkQueueLength();
        connectionExecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.DISCONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("disconnected event", channel, getClass()+" error when process disconnected event ." , t);
    }
}
 
Example #26
Source File: ConnectionOrderedChannelHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void connected(Channel channel) throws RemotingException {
    try{
        checkQueueLength();
        connectionExecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("connect event", channel, getClass()+" error when process connected event ." , t);
    }
}
 
Example #27
Source File: MessageOnlyChannelHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = executor;
    if (cexecutor == null || cexecutor.isShutdown()) {
        cexecutor = SHARED_EXECUTOR;
    }
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
Example #28
Source File: AllChannelHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void caught(Channel channel, Throwable exception) throws RemotingException {
    ExecutorService cexecutor = getExecutorService(); 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CAUGHT, exception));
    }catch (Throwable t) {
        throw new ExecutionException("caught event", channel, getClass()+" error when process caught event ." , t);
    }
}
 
Example #29
Source File: AllChannelHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = getExecutorService();
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
Example #30
Source File: AllChannelHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void disconnected(Channel channel) throws RemotingException {
    ExecutorService cexecutor = getExecutorService(); 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.DISCONNECTED));
    }catch (Throwable t) {
        throw new ExecutionException("disconnect event", channel, getClass()+" error when process disconnected event ." , t);
    }
}