use of org.apache.kafka.common.record.MemoryRecordsBuilder in project starlight-for-kafka by datastax.
the class GroupMetadataManagerTest method appendTransactionalOffsetCommits.
private int appendTransactionalOffsetCommits(ByteBuffer buffer, long producerId, short producerEpoch, long baseOffset, Map<TopicPartition, Long> offsets, String namespacePrefix) {
MemoryRecordsBuilder builder = MemoryRecords.builder(buffer, CompressionType.NONE, baseOffset, producerId, producerEpoch, 0, true);
List<SimpleRecord> commitRecords = createCommittedOffsetRecords(offsets, groupId, namespacePrefix);
commitRecords.forEach(builder::append);
builder.build();
return offsets.size();
}
use of org.apache.kafka.common.record.MemoryRecordsBuilder in project starlight-for-kafka by datastax.
the class GroupMetadataManagerTest method completeTransactionalOffsetCommit.
private int completeTransactionalOffsetCommit(ByteBuffer buffer, long producerId, short producerEpoch, long baseOffset, boolean isCommit) {
MemoryRecordsBuilder builder = MemoryRecords.builder(buffer, RecordBatch.MAGIC_VALUE_V2, CompressionType.NONE, TimestampType.LOG_APPEND_TIME, baseOffset, Time.SYSTEM.milliseconds(), producerId, producerEpoch, 0, true, true, RecordBatch.NO_PARTITION_LEADER_EPOCH);
ControlRecordType controlRecordType;
if (isCommit) {
controlRecordType = ControlRecordType.COMMIT;
} else {
controlRecordType = ControlRecordType.ABORT;
}
builder.appendEndTxnMarker(Time.SYSTEM.milliseconds(), new EndTransactionMarker(controlRecordType, 0));
builder.build();
return 1;
}
use of org.apache.kafka.common.record.MemoryRecordsBuilder in project starlight-for-kafka by datastax.
the class PartitionLogTest method buildIdempotentRecords.
private MemoryRecords buildIdempotentRecords(int[] batchSizes) {
ByteBuffer buffer = ByteBuffer.allocate(1024);
int baseOffset = 0;
for (int batchSize : batchSizes) {
MemoryRecordsBuilder builder = MemoryRecords.idempotentBuilder(buffer, CompressionType.NONE, baseOffset, 0, (short) 0, 0);
for (int i = 0; i < batchSize; i++) {
builder.append(0L, "a".getBytes(), "1".getBytes());
}
builder.close();
}
buffer.flip();
return MemoryRecords.readableRecords(buffer);
}
use of org.apache.kafka.common.record.MemoryRecordsBuilder in project starlight-for-kafka by datastax.
the class PartitionLogTest method buildMemoryRecords.
private MemoryRecords buildMemoryRecords(int[] batchSizes, CompressionType compressionType, int valueSize) {
int totalBatchSize = 0;
for (int batchSize : batchSizes) {
totalBatchSize += batchSize;
}
ByteBuffer buffer = ByteBuffer.allocate(valueSize * totalBatchSize * 2);
int baseOffset = 0;
for (int batchSize : batchSizes) {
MemoryRecordsBuilder builder = MemoryRecords.builder(buffer, RecordBatch.CURRENT_MAGIC_VALUE, compressionType, TimestampType.LOG_APPEND_TIME, baseOffset);
for (int i = 0; i < batchSize; i++) {
builder.append(0L, "a".getBytes(), new byte[valueSize]);
}
builder.close();
}
buffer.flip();
return MemoryRecords.readableRecords(buffer);
}
use of org.apache.kafka.common.record.MemoryRecordsBuilder in project starlight-for-kafka by datastax.
the class KafkaApisTest method newAbortTxnMarker.
private static MemoryRecords newAbortTxnMarker() {
final MemoryRecordsBuilder builder = MemoryRecords.builder(ByteBuffer.allocate(1024), RecordBatch.CURRENT_MAGIC_VALUE, CompressionType.NONE, TimestampType.CREATE_TIME, 0L, 0L, System.currentTimeMillis(), (short) 0, 0, true, true, /* isControlBatch */
0);
builder.appendEndTxnMarker(System.currentTimeMillis(), new EndTransactionMarker(ControlRecordType.ABORT, 0));
return builder.build();
}
Aggregations