Search in sources :

Example 1 with ExecutionException

use of org.apache.dubbo.remoting.ExecutionException in project dubbo by alibaba.

the class AllChannelHandler2 method received.

@Override
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService executor = getPreferredExecutorService(message);
    try {
        Future<?> future = executor.submit(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
        long timeout = this.url.getParameter("timeout", 1000) + 90;
        TIME_OUT_TIMER.newTimeout(t -> {
            if (!future.isDone() && (!future.isCancelled())) {
                try {
                    future.cancel(true);
                } catch (Throwable ex) {
                // ignore
                }
            }
        }, timeout, TimeUnit.MILLISECONDS);
    } catch (Throwable t) {
        if (message instanceof Request && t instanceof RejectedExecutionException) {
            sendFeedback(channel, (Request) message, t);
            return;
        }
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) Request(org.apache.dubbo.remoting.exchange.Request) ChannelEventRunnable(org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(org.apache.dubbo.remoting.ExecutionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 2 with ExecutionException

use of org.apache.dubbo.remoting.ExecutionException in project dubbo by alibaba.

the class ConnectionOrderedChannelHandler method disconnected.

@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);
    }
}
Also used : ChannelEventRunnable(org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(org.apache.dubbo.remoting.ExecutionException)

Example 3 with ExecutionException

use of org.apache.dubbo.remoting.ExecutionException in project dubbo by alibaba.

the class ConnectionOrderedChannelHandler method connected.

@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);
    }
}
Also used : ChannelEventRunnable(org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(org.apache.dubbo.remoting.ExecutionException)

Example 4 with ExecutionException

use of org.apache.dubbo.remoting.ExecutionException in project dubbo by alibaba.

the class HeaderExchangeHandler method caught.

@Override
public void caught(Channel channel, Throwable exception) throws RemotingException {
    if (exception instanceof ExecutionException) {
        ExecutionException e = (ExecutionException) exception;
        Object msg = e.getRequest();
        if (msg instanceof Request) {
            Request req = (Request) msg;
            if (req.isTwoWay() && !req.isHeartbeat()) {
                Response res = new Response(req.getId(), req.getVersion());
                res.setStatus(Response.SERVER_ERROR);
                res.setErrorMessage(StringUtils.toString(e));
                channel.send(res);
                return;
            }
        }
    }
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        handler.caught(exchangeChannel, exception);
    } finally {
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
Also used : Response(org.apache.dubbo.remoting.exchange.Response) Request(org.apache.dubbo.remoting.exchange.Request) ExchangeChannel(org.apache.dubbo.remoting.exchange.ExchangeChannel) ExecutionException(org.apache.dubbo.remoting.ExecutionException)

Aggregations

ExecutionException (org.apache.dubbo.remoting.ExecutionException)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)3 ChannelEventRunnable (org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable)3 Request (org.apache.dubbo.remoting.exchange.Request)2 ExecutorService (java.util.concurrent.ExecutorService)1 ExchangeChannel (org.apache.dubbo.remoting.exchange.ExchangeChannel)1 Response (org.apache.dubbo.remoting.exchange.Response)1