private NettyRpcServer createRpcServer(Configuration conf, int flushAfter) throws IOException {
    String name = "testRpcServer";
    ArrayList<RpcServer.BlockingServiceAndInterface> services =
      Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(SERVICE, null));

    InetSocketAddress bindAddress = new InetSocketAddress("localhost", 0);
    FifoRpcScheduler scheduler = new FifoRpcScheduler(conf, 1);

    AtomicInteger writeCount = new AtomicInteger(0);

    return new NettyRpcServer(null, name, services, bindAddress, conf, scheduler, true) {
      @Override
      protected NettyServerRpcConnection createNettyServerRpcConnection(Channel channel) {
        return new NettyServerRpcConnection(this, channel) {
          @Override
          protected void doRespond(RpcResponse resp) {
            if (writeCount.incrementAndGet() >= flushAfter) {
              super.doRespond(resp);
            } else {
              channel.write(resp);
            }
          }
        };
      }
    };
  }
Test that our fatal watermark is honored, which requires artificially causing some queueing so
that pendingOutboundBytes increases.
hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java