Package com.linkedin.venice.unit.kafka
Class InMemoryKafkaBroker
java.lang.Object
com.linkedin.venice.unit.kafka.InMemoryKafkaBroker
Used in unit tests in order to avoid spinning a full Kafka broker with network stack
and disk IO.
Instead, this Kafka broker keeps messages in memory. It can be used via the following
mock classes:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
createTopic
(String topicName, int partitionCount) endOffsets
(String topicName, int partition) int
getPartitionCount
(String topicName) long
produce
(String topicName, int partition, InMemoryKafkaMessage message)
-
Constructor Details
-
InMemoryKafkaBroker
-
-
Method Details
-
createTopic
-
produce
- Parameters:
topicName
- The name of the topic in which to produce.partition
- The partition in which to produce a message.message
- TheInMemoryKafkaMessage
to produce into the partition.- Returns:
- the offset of the produced message
- Throws:
IllegalArgumentException
- if the topic or partition does not exist.
-
consume
public Optional<InMemoryKafkaMessage> consume(String topicName, int partition, long offset) throws IllegalArgumentException - Parameters:
topicName
- The name of the topic from which to consume.partition
- The partition from which to produce a message.- Returns:
- Some
InMemoryKafkaMessage
instance, or theOptional.empty()
instance if that partition is drained. - Throws:
IllegalArgumentException
- if the topic or partition does not exist.
-
getPartitionCount
-
getKafkaBootstrapServer
- Returns:
- an synthetic broker server url.
-
endOffsets
-