public boolean isFull() {
        // note that the write limit is respected only after the first record is added which ensures we can always
        // create non-empty batches (this is used to disable batching when the producer's batch size is set to 0).
        return appendStream == CLOSED_STREAM || (this.numRecords > 0 && this.writeLimit <= estimatedBytesWritten());
    }
Check if we have room for a given number of bytes.
clients/src/main/java/org/apache/kafka/common/record/MemoryRecordsBuilder.java