use of org.apache.kafka.common.TopicPartition in project kafka by apache.
the class RequestResponseTest method createFetchResponse.
private FetchResponse createFetchResponse() {
LinkedHashMap<TopicPartition, FetchResponse.PartitionData> responseData = new LinkedHashMap<>();
MemoryRecords records = MemoryRecords.readableRecords(ByteBuffer.allocate(10));
responseData.put(new TopicPartition("test", 0), new FetchResponse.PartitionData(Errors.NONE, 1000000, records));
return new FetchResponse(responseData, 25);
}
use of org.apache.kafka.common.TopicPartition in project kafka by apache.
the class RequestResponseTest method createStopReplicaResponse.
private StopReplicaResponse createStopReplicaResponse() {
Map<TopicPartition, Errors> responses = new HashMap<>();
responses.put(new TopicPartition("test", 0), Errors.NONE);
return new StopReplicaResponse(Errors.NONE, responses);
}
use of org.apache.kafka.common.TopicPartition in project kafka by apache.
the class RequestResponseTest method createProduceRequest.
private ProduceRequest createProduceRequest() {
Map<TopicPartition, MemoryRecords> produceData = new HashMap<>();
produceData.put(new TopicPartition("test", 0), MemoryRecords.readableRecords(ByteBuffer.allocate(10)));
return new ProduceRequest.Builder((short) 1, 5000, produceData).build();
}
use of org.apache.kafka.common.TopicPartition in project kafka by apache.
the class RequestResponseTest method createProduceResponse.
private ProduceResponse createProduceResponse() {
Map<TopicPartition, ProduceResponse.PartitionResponse> responseData = new HashMap<>();
responseData.put(new TopicPartition("test", 0), new ProduceResponse.PartitionResponse(Errors.NONE, 10000, Record.NO_TIMESTAMP));
return new ProduceResponse(responseData, 0);
}
use of org.apache.kafka.common.TopicPartition in project kafka by apache.
the class RequestResponseTest method produceResponseVersionTest.
@Test
public void produceResponseVersionTest() {
Map<TopicPartition, ProduceResponse.PartitionResponse> responseData = new HashMap<>();
responseData.put(new TopicPartition("test", 0), new ProduceResponse.PartitionResponse(Errors.NONE, 10000, Record.NO_TIMESTAMP));
ProduceResponse v0Response = new ProduceResponse(responseData);
ProduceResponse v1Response = new ProduceResponse(responseData, 10);
ProduceResponse v2Response = new ProduceResponse(responseData, 10);
assertEquals("Throttle time must be zero", 0, v0Response.getThrottleTime());
assertEquals("Throttle time must be 10", 10, v1Response.getThrottleTime());
assertEquals("Throttle time must be 10", 10, v2Response.getThrottleTime());
assertEquals("Should use schema version 0", ApiKeys.PRODUCE.responseSchema((short) 0), v0Response.toStruct((short) 0).schema());
assertEquals("Should use schema version 1", ApiKeys.PRODUCE.responseSchema((short) 1), v1Response.toStruct((short) 1).schema());
assertEquals("Should use schema version 2", ApiKeys.PRODUCE.responseSchema((short) 2), v2Response.toStruct((short) 2).schema());
assertEquals("Response data does not match", responseData, v0Response.responses());
assertEquals("Response data does not match", responseData, v1Response.responses());
assertEquals("Response data does not match", responseData, v2Response.responses());
}
Aggregations