@Override
  public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
    throws Exception {
    if (handleFatalThreshold(ctx)) {
      promise.setFailure(
        new ConnectionClosedException("Channel outbound bytes exceeded fatal threshold"));
      if (msg instanceof RpcResponse) {
        ((RpcResponse) msg).done();
      } else {
        ReferenceCountUtil.release(msg);
      }
      return;
    }
    ctx.write(msg, promise);
  }
Handler to enforce writability protections on our server channels: <br>
- Responds to channel writability events, which are triggered when the total pending bytes for a
channel passes configured high and low watermarks. When high watermark is exceeded, the channel
is setAutoRead(false). This way, we won't accept new requests from the client until some pending
outbound bytes are successfully received by the client.<br>
- Pre-processes any channel write requests. If the total pending outbound bytes exceeds a fatal
threshold, the channel is forcefully closed and the write is set to failed. This handler should
be the last handler in the pipeline so that it's the first handler to receive any messages sent
to channel.write() or channel.writeAndFlush().
hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServerChannelWritabilityHandler.java