public synchronized List<ApiMessageAndVersion> allRecords() {
            List<ApiMessageAndVersion> allRecords = new ArrayList<>();
            for (LocalBatch batch : batches.values()) {
                if (batch instanceof LocalRecordBatch) {
                    LocalRecordBatch recordBatch = (LocalRecordBatch) batch;
                    allRecords.addAll(recordBatch.records);
                }
            }
            return allRecords;
        }
Return all records in the log as a list.
metadata/src/test/java/org/apache/kafka/metalog/LocalLogManager.java