public int maxAllowedBytes() {
        return this.writeLimit - this.batchHeaderSizeInBytes;
    }
Check if we have room for a given number of bytes.
clients/src/main/java/org/apache/kafka/common/record/MemoryRecordsBuilder.java