public static int write(final OutputStream dos, final Message header, final Message param,
    final ByteBuf cellBlock) throws IOException {
    // Must calculate total size and write that first so other side can read it all in in one
    // swoop. This is dictated by how the server is currently written. Server needs to change
    // if we are to be able to write without the length prefixing.
    int totalSize = IPCUtil.getTotalSizeWhenWrittenDelimited(header, param);
    if (cellBlock != null) {
      totalSize += cellBlock.readableBytes();
    }
    return write(dos, header, param, cellBlock, totalSize);
  }
Write out header, param, and cell block if there is one.
@param dos       Stream to write into
@param header    to write
@param param     to write
@param cellBlock to write
@return Total number of bytes written.
@throws IOException if write action fails
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java