@Override
  public void channelInactive(ChannelHandlerContext ctx) {
    logger.trace("Channel {} inactive", ctx.channel());
    nettyMetrics.channelDestructionRate.mark();
    if (request != null && request.isOpen()) {
      logger.error("Request {} was aborted because the channel {} became inactive", request.getUri(), ctx.channel());
      onRequestAborted(Utils.convertToClientTerminationException(new ClosedChannelException()));
    } else {
      close();
    }
  }
Netty calls this function when channel becomes inactive. The channel becomes inactive AFTER it is closed (either by
the server or the remote end). Any tasks that are performed at this point in time cannot communicate with the
client.
<p/>
This is called exactly once in the lifetime of the channel. If there is no keepalive, this will be called
after one request (since the channel lives to serve exactly one request). If there is keepalive, this will be
called once all the requests are done (the channel is closed).
<p/>
At this point we can perform state cleanup.
@param ctx The {@link ChannelHandlerContext} that can be used to perform operations on the channel.
ambry-rest/src/main/java/com/github/ambry/rest/NettyMessageProcessor.java