use of org.apache.kafka.common.message.DescribeProducersResponseData.ProducerState in project kafka by apache.
the class DescribeProducersHandlerTest method assertMatchingProducers.
private void assertMatchingProducers(PartitionResponse expected, PartitionProducerState actual) {
List<ProducerState> expectedProducers = expected.activeProducers();
List<org.apache.kafka.clients.admin.ProducerState> actualProducers = actual.activeProducers();
assertEquals(expectedProducers.size(), actualProducers.size());
Map<Long, ProducerState> expectedByProducerId = expectedProducers.stream().collect(Collectors.toMap(ProducerState::producerId, Function.identity()));
for (org.apache.kafka.clients.admin.ProducerState actualProducerState : actualProducers) {
ProducerState expectedProducerState = expectedByProducerId.get(actualProducerState.producerId());
assertNotNull(expectedProducerState);
assertEquals(expectedProducerState.producerEpoch(), actualProducerState.producerEpoch());
assertEquals(expectedProducerState.lastSequence(), actualProducerState.lastSequence());
assertEquals(expectedProducerState.lastTimestamp(), actualProducerState.lastTimestamp());
assertEquals(expectedProducerState.currentTxnStartOffset(), actualProducerState.currentTransactionStartOffset().orElse(-1L));
}
}
use of org.apache.kafka.common.message.DescribeProducersResponseData.ProducerState in project kafka by apache.
the class DescribeProducersHandlerTest method sampleProducerState.
private PartitionResponse sampleProducerState(TopicPartition topicPartition) {
PartitionResponse partitionResponse = new PartitionResponse().setPartitionIndex(topicPartition.partition()).setErrorCode(Errors.NONE.code());
partitionResponse.setActiveProducers(asList(new ProducerState().setProducerId(12345L).setProducerEpoch(15).setLastSequence(75).setLastTimestamp(System.currentTimeMillis()).setCurrentTxnStartOffset(-1L), new ProducerState().setProducerId(98765L).setProducerEpoch(30).setLastSequence(150).setLastTimestamp(System.currentTimeMillis() - 5000).setCurrentTxnStartOffset(5000)));
return partitionResponse;
}
Aggregations