@Override public void operationProgressed(ChannelProgressiveFuture f, long progress, long total) { future.touch(); if (progressAsyncHandler != null && !notifyHeaders) { long lastLastProgress = lastProgress; lastProgress = progress; if (total < 0) { total = expectedTotal; } if (progress != lastLastProgress) { progressAsyncHandler.onContentWriteProgress(progress - lastLastProgress, progress, total); } } } }
private void scheduleReadTimeout(NettyResponseFuture<?> nettyResponseFuture) { TimeoutsHolder timeoutsHolder = nettyResponseFuture.getTimeoutsHolder(); if (timeoutsHolder != null) { // on very fast requests, it's entirely possible that the response has already // been completed // by the time we try to schedule the read timeout nettyResponseFuture.touch(); timeoutsHolder.startReadTimeout(); } }
private void scheduleRequestTimeout(NettyResponseFuture<?> nettyResponseFuture, InetSocketAddress originalRemoteAddress) { nettyResponseFuture.touch(); TimeoutsHolder timeoutsHolder = new TimeoutsHolder(nettyTimer, nettyResponseFuture, this, config, originalRemoteAddress); nettyResponseFuture.setTimeoutsHolder(timeoutsHolder); }
@SuppressWarnings({"rawtypes", "unchecked"}) public void replayRequest(final NettyResponseFuture<?> future, FilterContext fc, Channel channel) { Request newRequest = fc.getRequest(); future.setAsyncHandler(fc.getAsyncHandler()); future.setChannelState(ChannelState.NEW); future.touch(); LOGGER.debug("\n\nReplaying Request {}\n for Future {}\n", newRequest, future); try { future.getAsyncHandler().onRetry(); } catch (Exception e) { LOGGER.error("onRetry crashed", e); abort(channel, future, e); return; } channelManager.drainChannelAndOffer(channel, future); sendNextRequest(newRequest, future); }
void operationComplete(Channel channel, Throwable cause) { future.touch(); // The write operation failed. If the channel was cached, it means it got asynchronously closed. // Let's retry a second time. if (abortOnThrowable(channel, cause)) { return; } if (progressAsyncHandler != null) { // We need to make sure we aren't in the middle of an authorization process before publishing events as we will re-publish again the same event after the authorization, // causing unpredictable behavior. boolean startPublishing = !future.isInAuth() && !future.isInProxyAuth(); if (startPublishing) { if (notifyHeaders) { progressAsyncHandler.onHeadersWritten(); } else { progressAsyncHandler.onContentWritten(); } } } } }
future = (NettyResponseFuture<?>) attribute; future.attachChannel(null, false); future.touch();
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 void operationProgressed(ChannelFuture cf, long amount, long current, long total) { future.touch(); if (asyncHandler instanceof ProgressAsyncHandler) { ProgressAsyncHandler.class.cast(asyncHandler).onContentWriteProgress(amount, current, total); } } }
@Override public void operationProgressed(ChannelProgressiveFuture f, long progress, long total) { future.touch(); if (!notifyHeaders && asyncHandler instanceof ProgressAsyncHandler) { long lastLastProgress = lastProgress; lastProgress = progress; if (total < 0) total = expectedTotal; ProgressAsyncHandler.class.cast(asyncHandler).onContentWriteProgress(progress - lastLastProgress, progress, total); } } }
@Override public void operationProgressed(ChannelProgressiveFuture f, long progress, long total) { future.touch(); if (!notifyHeaders && asyncHandler instanceof ProgressAsyncHandler) { long lastLastProgress = lastProgress; lastProgress = progress; if (total < 0) total = expectedTotal; ProgressAsyncHandler.class.cast(asyncHandler).onContentWriteProgress(progress - lastLastProgress, progress, total); } } }
public void operationProgressed(ChannelFuture cf, long amount, long current, long total) { future.touch(); if (asyncHandler instanceof ProgressAsyncHandler) { ProgressAsyncHandler.class.cast(asyncHandler).onContentWriteProgress(amount, current, total); } } }
@SuppressWarnings({ "rawtypes", "unchecked" }) public void replayRequest(final NettyResponseFuture<?> future, FilterContext fc, Channel channel) { Request newRequest = fc.getRequest(); future.setAsyncHandler(fc.getAsyncHandler()); future.setState(NettyResponseFuture.STATE.NEW); future.touch(); LOGGER.debug("\n\nReplaying Request {}\n for Future {}\n", newRequest, future); if (future.getAsyncHandler() instanceof AsyncHandlerExtensions) AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onRetry(); channelManager.drainChannelAndOffer(channel, future); sendNextRequest(newRequest, future); }
@SuppressWarnings({ "rawtypes", "unchecked" }) public void replayRequest(final NettyResponseFuture<?> future, FilterContext fc, Channel channel) throws IOException { Request newRequest = fc.getRequest(); future.setAsyncHandler(fc.getAsyncHandler()); future.setState(NettyResponseFuture.STATE.NEW); future.touch(); LOGGER.debug("\n\nReplaying Request {}\n for Future {}\n", newRequest, future); if (future.getAsyncHandler() instanceof AsyncHandlerExtensions) AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onRetry(); channelManager.drainChannelAndOffer(channel, future); sendNextRequest(newRequest, future); }
@SuppressWarnings({ "rawtypes", "unchecked" }) public void replayRequest(final NettyResponseFuture<?> future, FilterContext fc, Channel channel) { final Request newRequest = fc.getRequest(); future.setAsyncHandler(fc.getAsyncHandler()); future.setState(NettyResponseFuture.STATE.NEW); future.touch(); LOGGER.debug("\n\nReplaying Request {}\n for Future {}\n", newRequest, future); if (future.getAsyncHandler() instanceof AsyncHandlerExtensions) AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onRetry(); channelManager.drainChannelAndOffer(channel, future); sendNextRequest(newRequest, future); return; }
@SuppressWarnings({ "rawtypes", "unchecked" }) public void replayRequest(final NettyResponseFuture<?> future, FilterContext fc, Channel channel) throws IOException { final Request newRequest = fc.getRequest(); future.setAsyncHandler(fc.getAsyncHandler()); future.setState(NettyResponseFuture.STATE.NEW); future.touch(); LOGGER.debug("\n\nReplaying Request {}\n for Future {}\n", newRequest, future); if (future.getAsyncHandler() instanceof AsyncHandlerExtensions) AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onRetry(); channelManager.drainChannelAndOffer(channel, future); sendNextRequest(newRequest, future); return; }
public void operationComplete(ChannelFuture cf) { if (!abortOnThrowable(cf.getCause(), cf.getChannel())) { future.touch(); /** * We need to make sure we aren't in the middle of an authorization process before publishing events as we will re-publish again the same event after the authorization, * causing unpredictable behavior. */ Realm realm = future.getRequest().getRealm() != null ? future.getRequest().getRealm() : config.getRealm(); boolean startPublishing = future.isInAuth() || realm == null || realm.getUsePreemptiveAuth(); if (startPublishing && asyncHandler instanceof ProgressAsyncHandler) { if (notifyHeaders) { ProgressAsyncHandler.class.cast(asyncHandler).onHeadersWritten(); } else { ProgressAsyncHandler.class.cast(asyncHandler).onContentWritten(); } } } }
private void scheduleTimeouts(NettyResponseFuture<?> nettyResponseFuture) { nettyResponseFuture.touch(); int requestTimeoutInMs = requestTimeout(config, nettyResponseFuture.getRequest()); TimeoutsHolder timeoutsHolder = new TimeoutsHolder(); if (requestTimeoutInMs != -1) { Timeout requestTimeout = newTimeout(new RequestTimeoutTimerTask(nettyResponseFuture, this, timeoutsHolder, requestTimeoutInMs), requestTimeoutInMs); timeoutsHolder.requestTimeout = requestTimeout; } int readTimeoutValue = config.getReadTimeout(); if (readTimeoutValue != -1 && readTimeoutValue < requestTimeoutInMs) { // no need to schedule a readTimeout if the requestTimeout happens first Timeout readTimeout = newTimeout(new ReadTimeoutTimerTask(nettyResponseFuture, this, timeoutsHolder, requestTimeoutInMs, readTimeoutValue), readTimeoutValue); timeoutsHolder.readTimeout = readTimeout; } nettyResponseFuture.setTimeoutsHolder(timeoutsHolder); }
private void scheduleTimeouts(NettyResponseFuture<?> nettyResponseFuture) { nettyResponseFuture.touch(); int requestTimeoutInMs = requestTimeout(config, nettyResponseFuture.getRequest()); TimeoutsHolder timeoutsHolder = new TimeoutsHolder(); if (requestTimeoutInMs != -1) { Timeout requestTimeout = newTimeout(new RequestTimeoutTimerTask(nettyResponseFuture, this, timeoutsHolder, requestTimeoutInMs), requestTimeoutInMs); timeoutsHolder.requestTimeout = requestTimeout; } int readTimeoutValue = config.getReadTimeout(); if (readTimeoutValue != -1 && readTimeoutValue < requestTimeoutInMs) { // no need for a readTimeout that's less than the requestTimeoutInMs Timeout readTimeout = newTimeout(new ReadTimeoutTimerTask(nettyResponseFuture, this, timeoutsHolder, requestTimeoutInMs, readTimeoutValue), readTimeoutValue); timeoutsHolder.readTimeout = readTimeout; } nettyResponseFuture.setTimeoutsHolder(timeoutsHolder); }
private void scheduleTimeouts(NettyResponseFuture<?> nettyResponseFuture) { nettyResponseFuture.touch(); int requestTimeoutInMs = requestTimeout(config, nettyResponseFuture.getRequest()); TimeoutsHolder timeoutsHolder = new TimeoutsHolder(); if (requestTimeoutInMs != -1) { Timeout requestTimeout = newTimeout(new RequestTimeoutTimerTask(nettyResponseFuture, this, timeoutsHolder, requestTimeoutInMs), requestTimeoutInMs); timeoutsHolder.requestTimeout = requestTimeout; } int readTimeoutValue = config.getReadTimeout(); if (readTimeoutValue != -1 && readTimeoutValue < requestTimeoutInMs) { // no need to schedule a readTimeout if the requestTimeout happens first Timeout readTimeout = newTimeout(new ReadTimeoutTimerTask(nettyResponseFuture, this, timeoutsHolder, requestTimeoutInMs, readTimeoutValue), readTimeoutValue); timeoutsHolder.readTimeout = readTimeout; } nettyResponseFuture.setTimeoutsHolder(timeoutsHolder); }