public static List<ProducerRecord<byte[], byte[]>> generateRecords(String topicName, int numRecords, int numPartitions) {
        List<ProducerRecord<byte[], byte[]>> records = new ArrayList<>();
        int cnt = 0;
        for (int r = 0; r < numRecords; r++) {
            for (int p = 0; p < numPartitions; p++) {
                String value = "value-" + cnt;
                String key = "key-" + cnt;
                cnt++;
                records.add(new ProducerRecord<>(topicName, p, key.getBytes(), value.getBytes()));
            }
        }
        return records;
    }
Assemble a collection of records evenly distributed across some partitions of the specified topic
@param topicName Destination topic
@param numRecords count of records to produce to each partition
@param numPartitions number of partitions within the topic to write records to.
@return A batch of records that can be sent to a producer.
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/TestUtils.java