public static void setDiscard(Channel channel) { setAttribute(channel, DiscardEvent.INSTANCE); }
public void drainChannelAndOffer(final Channel channel, final NettyResponseFuture<?> future, boolean keepAlive, Object partitionKey) { Channels.setAttribute(channel, newDrainCallback(future, channel, keepAlive, partitionKey)); }
Channels.setAttribute(channel, future);
@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(future); requestSender.handleUnexpectedClosedChannel(channel, future); } }
private void writeRequest(Channel channel) { LOGGER.debug("Using non-cached Channel {} for {} '{}'", channel, future.getNettyRequest().getHttpRequest().getMethod(), future.getNettyRequest().getHttpRequest().getUri()); Channels.setAttribute(channel, future); if (future.isDone()) { abortChannelPreemption(); return; } if (future.getAsyncHandler() instanceof AsyncHandlerExtensions) AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onConnectionOpen(); channelManager.registerOpenChannel(channel, partitionKey); future.attachChannel(channel, false); requestSender.writeRequest(future, channel); }
public static void setDiscard(Channel channel) { setAttribute(channel, DiscardEvent.INSTANCE); }
private <T> ListenableFuture<T> sendRequestWithCachedChannel(Request request, UriComponents uri, ProxyServer proxy, NettyResponseFuture<T> future, AsyncHandler<T> asyncHandler, Channel channel) throws IOException { future.setState(NettyResponseFuture.STATE.POOLED); future.attachChannel(channel, false); LOGGER.debug("\nUsing cached Channel {}\n for request \n{}\n", channel, future.getNettyRequest().getHttpRequest()); Channels.setAttribute(channel, future); try { writeRequest(future, channel); } catch (Exception ex) { LOGGER.debug("writeRequest failure", ex); if (ex.getMessage() != null && ex.getMessage().contains("SSLEngine")) { LOGGER.debug("SSLEngine failure", ex); future = null; } else { try { asyncHandler.onThrowable(ex); } catch (Throwable t) { LOGGER.warn("doConnect.writeRequest()", t); } IOException ioe = new IOException(ex.getMessage()); ioe.initCause(ex); throw ioe; } } return future; }
public void drainChannel(final Channel channel, final NettyResponseFuture<?> future) { Channels.setAttribute(channel, newDrainCallback(future, channel, future.isKeepAlive(), getPoolKey(future))); } }
@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); } }
public final void operationComplete(ChannelFuture f) throws Exception { Channel channel = f.getChannel(); if (f.isSuccess()) { Channels.setAttribute(channel, future); final SslHandler sslHandler = ChannelManager.getSslHandler(channel.getPipeline());
Channels.setAttribute(channel, callback); else callback.call();
Channels.setAttribute(channel, callback); } else {