public void drainChannelAndExecuteNextRequest(final Channel channel, final NettyResponseFuture<?> future, Request nextRequest) { Channels.setAttribute(channel, new OnLastHttpContentCallback(future) { @Override public void call() { sendNextRequest(nextRequest, future); } }); }
public static void setDiscard(Channel channel) { setAttribute(channel, DiscardEvent.DISCARD); }
public void drainChannelAndExecuteNextRequest(final Channel channel, final NettyResponseFuture<?> future, Request nextRequest, Future<Channel> whenHandshaked) { Channels.setAttribute(channel, new OnLastHttpContentCallback(future) { @Override public void call() { whenHandshaked.addListener(f -> { if (f.isSuccess()) { sendNextRequest(nextRequest, future); } else { future.abort(f.cause()); } } ); } }); }
@Override public void call() { Channels.setAttribute(channel, future); requestSender.writeRequest(future, channel); } });
public void drainChannelAndOffer(Channel channel, NettyResponseFuture<?> future, boolean keepAlive, Object partitionKey) { Channels.setAttribute(channel, newDrainCallback(future, channel, keepAlive, partitionKey)); }
private boolean abortAfterHandlingReactiveStreams(Channel channel, NettyResponseFuture<?> future, AsyncHandler<?> handler) { if (handler instanceof StreamedAsyncHandler) { StreamedAsyncHandler<?> streamedAsyncHandler = (StreamedAsyncHandler<?>) handler; StreamedResponsePublisher publisher = new StreamedResponsePublisher(channel.eventLoop(), channelManager, future, channel); // FIXME do we really need to pass the event loop? // FIXME move this to ChannelManager channel.pipeline().addLast(channel.eventLoop(), "streamedAsyncHandler", publisher); Channels.setAttribute(channel, publisher); return streamedAsyncHandler.onStream(publisher) == State.ABORT; } return false; }
public boolean exitAfterHandling100(final Channel channel, final NettyResponseFuture<?> future) { future.setHeadersAlreadyWrittenOnContinue(true); future.setDontWriteBodyBecauseExpectContinue(false); // directly send the body Channels.setAttribute(channel, new OnLastHttpContentCallback(future) { @Override public void call() { Channels.setAttribute(channel, future); requestSender.writeRequest(future, channel); } }); return true; } }
private void writeRequest(Channel channel) { if (futureIsAlreadyCancelled(channel)) { return; } if (LOGGER.isDebugEnabled()) { HttpRequest httpRequest = future.getNettyRequest().getHttpRequest(); LOGGER.debug("Using new Channel '{}' for '{}' to '{}'", channel, httpRequest.method(), httpRequest.uri()); } Channels.setAttribute(channel, future); channelManager.registerOpenChannel(channel); future.attachChannel(channel, false); requestSender.writeRequest(future, channel); }
Channels.setAttribute(channel, future);
Channels.setAttribute(channel, future);
public void channelInactive(ChannelHandlerContext ctx) throws Exception { if (requestSender.isClosed()) return; Channel channel = ctx.channel(); channelManager.removeAll(channel); Object attribute = Channels.getAttribute(channel); logger.debug("Channel Closed: {} with attribute {}", channel, attribute); if (attribute instanceof StreamedResponsePublisher) { // setting `attribute` to be the underlying future so that the retry // logic can kick-in attribute = ((StreamedResponsePublisher) attribute).future(); } if (attribute instanceof OnLastHttpContentCallback) { OnLastHttpContentCallback callback = (OnLastHttpContentCallback) attribute; Channels.setAttribute(channel, callback.future()); callback.call(); } else if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; future.touch(); if (hasIOExceptionFilters && requestSender.applyIoExceptionFiltersAndReplayRequest(future, ChannelClosedException.INSTANCE, channel)) return; handleChannelInactive(future); requestSender.handleUnexpectedClosedChannel(channel, future); } }
public static void setDiscard(Channel channel) { setAttribute(channel, DiscardEvent.INSTANCE); }
public static void setDiscard(Channel channel) { setAttribute(channel, DiscardEvent.INSTANCE); }
public void drainChannelAndExecuteNextRequest(final Channel channel, final NettyResponseFuture<?> future, Request nextRequest) { Channels.setAttribute(channel, newExecuteNextRequestCallback(future, nextRequest)); } }
@Override public void call() throws IOException { Channels.setAttribute(channel, future); requestSender.writeRequest(future, channel); } });
@Override public void call() throws IOException { Channels.setAttribute(channel, future); requestSender.writeRequest(future, channel); } });
public void drainChannelAndOffer(final Channel channel, final NettyResponseFuture<?> future, boolean keepAlive, Object partitionKey) { Channels.setAttribute(channel, newDrainCallback(future, channel, keepAlive, partitionKey)); }
public void drainChannelAndOffer(final Channel channel, final NettyResponseFuture<?> future, boolean keepAlive, Object partitionKey) { Channels.setAttribute(channel, newDrainCallback(future, channel, keepAlive, partitionKey)); }
private boolean exitAfterHandlingReactiveStreams(Channel channel, NettyResponseFuture<?> future, HttpResponse response, AsyncHandler<?> handler) throws IOException { if (handler instanceof StreamedAsyncHandler) { StreamedAsyncHandler<?> streamedAsyncHandler = (StreamedAsyncHandler<?>) handler; StreamedResponsePublisher publisher = new StreamedResponsePublisher(channel.eventLoop(), channelManager, future, channel); channel.pipeline().addLast(channel.eventLoop(), "streamedAsyncHandler", publisher); Channels.setAttribute(channel, publisher); if (streamedAsyncHandler.onStream(publisher) != State.CONTINUE) { finishUpdate(future, channel, HttpHeaders.isTransferEncodingChunked(response)); return true; } } return false; }
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; } future.attachChannel(channel, false); channelManager.registerOpenChannel(channel, partitionKey); requestSender.writeRequest(future, channel); }