Source:
public void channelRead0(ChannelHandlerContext ctx, HttpObject in) { long currentChunkReceiveTime = System.currentTimeMillis(); boolean recognized = false; if (in instanceof HttpResponse) { recognized = true; long responseReceiveStart = currentChunkReceiveTime - requestStartTime; perfClientMetrics.timeToFirstResponseChunkInMs.update(responseReceiveStart); logger.trace("Response receive has started on channel {}. Took ms", ctx.channel(), responseReceiveStart); response = (HttpResponse) in; if (response.status() != HttpResponseStatus.OK) { logger.error("Got Response code and header was {}", response.status().code(), response.headers()); } } if (in instanceof HttpContent) { recognized = true; perfClientMetrics.delayBetweenChunkReceiveInMs.update(currentChunkReceiveTime - lastChunkReceiveTime); chunksReceived++; int bytesReceivedThisTime = ((HttpContent) in).content().readableBytes(); sizeReceived += bytesReceivedThisTime; perfClientMetrics.bytesReceiveRate.mark(bytesReceivedThisTime); if (in instanceof LastHttpContent) { long requestRoundTripTime = currentChunkReceiveTime - requestStartTime; perfClientMetrics.requestRoundTripTimeInMs.update(requestRoundTripTime); perfClientMetrics.getContentSizeInBytes.update(sizeReceived); perfClientMetrics.getChunkCount.update(chunksReceived); logger.trace( "Final content received on channel {}. Took ms. Total chunks received - {}. Total size received - {}", ctx.channel(), requestRoundTripTime, chunksReceived, sizeReceived); if (HttpUtil.isKeepAlive(response) && isRunning) { logger.trace("Sending new request on channel {}", ctx.channel()); sendRequest(ctx); } else if (!isRunning) { logger.info("Closing channel because NettyPerfClient has been shutdown", ctx.channel()); ctx.close(); } else { perfClientMetrics.requestResponseError.inc(); logger.error("Channel not kept alive. Last response status was and header was {}", ctx.channel(), response.status(), response.headers()); ctx.close(); } } } if (!recognized) { throw new IllegalStateException("Unexpected HttpObject - " + in.getClass()); } lastChunkReceiveTime = currentChunkReceiveTime; }

Target:
public void channelRead0(ChannelHandlerContext ctx, HttpObject in) { long currentChunkReceiveTime = System.currentTimeMillis(); boolean recognized = false; if (in instanceof HttpResponse) { recognized = true; long responseReceiveStart = currentChunkReceiveTime - requestStartTime; perfClientMetrics.timeToFirstResponseChunkInMs.update(responseReceiveStart); logger.trace("Response receive has started on channel {}. Took ms", ctx.channel(), responseReceiveStart); response = (HttpResponse) in; if (response.status() != HttpResponseStatus.OK) { logger.error("Got Response code and headers were {}", response.status().code(), response.headers()); } } if (in instanceof HttpContent) { recognized = true; perfClientMetrics.delayBetweenChunkReceiveInMs.update(currentChunkReceiveTime - lastChunkReceiveTime); chunksReceived++; int bytesReceivedThisTime = ((HttpContent) in).content().readableBytes(); sizeReceived += bytesReceivedThisTime; perfClientMetrics.bytesReceiveRate.mark(bytesReceivedThisTime); if (in instanceof LastHttpContent) { long requestRoundTripTime = currentChunkReceiveTime - requestStartTime; perfClientMetrics.requestRoundTripTimeInMs.update(requestRoundTripTime); perfClientMetrics.getContentSizeInBytes.update(sizeReceived); perfClientMetrics.getChunkCount.update(chunksReceived); logger.trace( "Final content received on channel {}. Took ms. Total chunks received - {}. Total size received - {}", ctx.channel(), requestRoundTripTime, chunksReceived, sizeReceived); if (HttpUtil.isKeepAlive(response) && isRunning) { logger.trace("Sending new request on channel {}", ctx.channel()); sendRequest(ctx); } else if (!isRunning) { logger.info("Closing channel because NettyPerfClient has been shutdown", ctx.channel()); ctx.close(); } else { perfClientMetrics.requestResponseError.inc(); logger.error("Channel not kept alive. Last response status was and header was {}", ctx.channel(), response.status(), response.headers()); ctx.close(); } } } if (!recognized) { throw new IllegalStateException("Unexpected HttpObject - " + in.getClass()); } lastChunkReceiveTime = currentChunkReceiveTime; }