public void abort(Channel channel, NettyResponseFuture<?> future, Throwable t) { if (channel != null) channelManager.closeChannel(channel); if (!future.isDone()) { LOGGER.debug("Aborting Future {}\n", future); LOGGER.debug(t.getMessage(), t); future.abort(t); } }
public void handleUnexpectedClosedChannel(Channel channel, NettyResponseFuture<?> future) { if (future.isDone()) channelManager.closeChannel(channel); else if (!retry(future)) abort(channel, future, REMOTELY_CLOSED_EXCEPTION); }
public final void tryToOfferChannelToPool(Channel channel, boolean keepAlive, Object partitionKey) { if (channel.isConnected() && keepAlive && channel.isReadable()) { LOGGER.debug("Adding key: {} for channel {}", partitionKey, channel); Channels.setDiscard(channel); if (channelPool.offer(channel, partitionKey)) { if (maxConnectionsPerHostEnabled) channelId2PartitionKey.putIfAbsent(channel.getId(), partitionKey); } else { // rejected by pool closeChannel(channel); } } else { // not offered closeChannel(channel); } }
channelManager.closeChannel(channel); return;
channelManager.closeChannel(channel); ctx.sendUpstream(e);
future.setReuseChannel(true); } else { channelManager.closeChannel(channel);
future.setReuseChannel(true); } else { channelManager.closeChannel(channel);
public void abort(NettyResponseFuture<?> future, Throwable t) { Channel channel = future.channel(); if (channel != null) channelManager.closeChannel(channel); if (!future.isDone()) { LOGGER.debug("Aborting Future {}\n", future); LOGGER.debug(t.getMessage(), t); } future.abort(t); }
private void markAsDone(NettyResponseFuture<?> future, final Channel channel) { // We need to make sure everything is OK before adding the // connection back to the pool. try { future.done(); } catch (Throwable t) { // Never propagate exception once we know we are done. logger.debug(t.getMessage(), t); } if (!future.isKeepAlive() || !channel.isConnected()) { channelManager.closeChannel(channel); } }
channelManager.closeChannel(channel);
public final void tryToOfferChannelToPool(Channel channel, boolean keepAlive, String poolKey) { if (keepAlive && channel.isReadable()) { LOGGER.debug("Adding key: {} for channel {}", poolKey, channel); channelPool.offer(channel, poolKey); if (maxConnectionsPerHostEnabled) channelId2KeyPool.putIfAbsent(channel.getId(), poolKey); Channels.setDiscard(channel); } else { // not offered closeChannel(channel); } }
@Override public void handle(final Channel channel, final NettyResponseFuture<?> future, final Object e) throws Exception { future.touch(); // The connect timeout occurred. if (future.isDone()) { channelManager.closeChannel(channel); return; } AsyncHandler<?> handler = future.getAsyncHandler(); try { if (e instanceof HttpResponse && handleHttpResponse((HttpResponse) e, channel, future, handler)) return; if (e instanceof HttpChunk) handleChunk((HttpChunk) e, channel, future, handler); } catch (Exception t) { if (hasIOExceptionFilters// && t instanceof IOException// && requestSender.applyIoExceptionFiltersAndReplayRequest(future, IOException.class.cast(t), channel)) { return; } try { requestSender.abort(future, t); } catch (Exception abortException) { logger.debug("Abort failed", abortException); } finally { finishUpdate(future, channel, false); } throw t; } }
channelManager.closeChannel(channel); ctx.sendUpstream(e);
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { if (requestSender.isClosed()) return; Channel channel = ctx.getChannel(); channelManager.removeAll(channel); try { super.channelClosed(ctx, e); } catch (Exception ex) { LOGGER.trace("super.channelClosed", ex); } Object attribute = Channels.getAttribute(channel); LOGGER.debug("Channel Closed: {} with attribute {}", channel, attribute); if (attribute instanceof Callback) { Callback callback = (Callback) attribute; Channels.setAttribute(channel, callback.future()); callback.call(); } else if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; future.touch(); if (!config.getIOExceptionFilters().isEmpty() && requestSender.applyIoExceptionFiltersAndReplayRequest(future, CHANNEL_CLOSED_EXCEPTION, channel)) return; protocol.onClose(channel); if (future == null || future.isDone()) channelManager.closeChannel(channel); else if (!requestSender.retry(future, ctx.getChannel())) requestSender.abort(future, REMOTELY_CLOSED_EXCEPTION); } }