private void writeToChannel() throws IOException {
    if (closed) {
      throw new IOException("Already closed: " + id);
    }

    takeWriteResources(1);
    chc.writeAndFlush(buf.copy()).addListener(writeListener);
    buf.clear();
  }
OutputStream to write to the Netty Channel
ql/src/java/org/apache/hadoop/hive/llap/ChannelOutputStream.java