public interface KafkaResource extends ExternalResource
Modifier and Type | Method and Description |
---|---|
void |
createTopic(int replicationFactor,
int numPartitions,
String topic)
Creates a topic with the given name, replication factor and number of partitions.
|
static KafkaResource |
get(String version)
Returns the configured KafkaResource implementation, or a
LocalStandaloneKafkaResource if none is configured. |
Collection<InetSocketAddress> |
getBootstrapServerAddresses()
Returns the kafka bootstrap server addresses.
|
int |
getNumPartitions(String topic)
Returns the current number of partitions for the given topic.
|
long |
getPartitionOffset(String topic,
int partition)
Returns the current partition offset for the given partition of the given topic.
|
InetSocketAddress |
getZookeeperAddress()
Returns the address of Zookeeper.
|
List<String> |
readMessage(int maxNumMessages,
String groupId,
String topic)
Reads up to
maxNumMessages from the given topic. |
void |
sendMessages(String topic,
String... messages)
Sends the given messages to the given topic.
|
void |
setNumPartitions(int numPartitions,
String topic)
Modifies the number of partitions for the given topic.
|
afterTestFailure, afterTestSuccess, apply, before
void createTopic(int replicationFactor, int numPartitions, String topic) throws IOException
replicationFactor
- replication factornumPartitions
- number of partitionstopic
- desired topic nameIOException
void sendMessages(String topic, String... messages) throws IOException
topic
- topic namemessages
- messages to sendIOException
Collection<InetSocketAddress> getBootstrapServerAddresses()
InetSocketAddress getZookeeperAddress()
List<String> readMessage(int maxNumMessages, String groupId, String topic) throws IOException
maxNumMessages
from the given topic.maxNumMessages
- maximum number of messages that should be readgroupId
- group id to identify consumertopic
- topic nameIOException
void setNumPartitions(int numPartitions, String topic) throws IOException
numPartitions
- desired number of partitionstopic
- topic to modifyIOException
int getNumPartitions(String topic) throws IOException
topic
- topic nameIOException
long getPartitionOffset(String topic, int partition) throws IOException
topic
- topic namepartition
- topic partitionIOException
static KafkaResource get(String version)
LocalStandaloneKafkaResource
if none is configured.LocalStandaloneKafkaResource
is none is configuredCopyright © 2014–2020 The Apache Software Foundation. All rights reserved.