Java源码示例:com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable

示例1
@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);
    }
}
 
示例2
@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);
        }
    }
 
示例3
@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) {
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
示例4
@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);
    }
}
 
示例5
@Override
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);
    }
}
 
示例6
@Override
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);
    }
}
 
示例7
@Override
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);
    }
}
 
示例8
@Override
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);
    }
}
 
示例9
@Override
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);
    }
}
 
示例10
@Override
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);
    }
}
 
示例11
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);
    }
}
 
示例12
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);
    }
}
 
示例13
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);
    }
}
 
示例14
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);
    }
}
 
示例15
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);
    }
}
 
示例16
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);
    }
}
 
示例17
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);
    }
}
 
示例18
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);
    }
}
 
示例19
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);
    }
}
 
示例20
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);
    }
}
 
示例21
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);
    }
}
 
示例22
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);
    }
}
 
示例23
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);
    }
}
 
示例24
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);
    }
}
 
示例25
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);
    }
}
 
示例26
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);
    }
}
 
示例27
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);
    }
}
 
示例28
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);
    }
}
 
示例29
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);
    }
}
 
示例30
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);
    }
}