public class KafkaTestUtils extends Object implements Logging
The reason to put Kafka test utility class in src is to test Python related Kafka APIs.
Constructor and Description |
---|
KafkaTestUtils() |
Modifier and Type | Method and Description |
---|---|
String |
brokerAddress() |
void |
createTopic(String topic)
Create a Kafka topic and wait until it propagated to the whole cluster
|
<T> T |
eventually(Time timeout,
Time interval,
scala.Function0<T> func) |
void |
sendMessages(String topic,
java.util.Map<String,Integer> messageToFreq)
Java-friendly function for sending messages to the Kafka broker
|
void |
sendMessages(String topic,
scala.collection.immutable.Map<String,Object> messageToFreq)
Send the messages to the Kafka broker
|
void |
sendMessages(String topic,
String[] messages)
Send the array of messages to the Kafka broker
|
void |
setup()
setup the whole embedded servers, including Zookeeper and Kafka brokers
|
void |
teardown()
Teardown the whole servers, including Kafka broker and Zookeeper
|
void |
waitUntilLeaderOffset(String topic,
int partition,
long offset)
Wait until the leader offset for the given topic/partition equals the specified offset
|
String |
zkAddress() |
org.I0Itec.zkclient.ZkClient |
zookeeperClient() |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
public String zkAddress()
public String brokerAddress()
public org.I0Itec.zkclient.ZkClient zookeeperClient()
public void setup()
public void teardown()
public void createTopic(String topic)
public void sendMessages(String topic, java.util.Map<String,Integer> messageToFreq)
public void sendMessages(String topic, scala.collection.immutable.Map<String,Object> messageToFreq)
public void sendMessages(String topic, String[] messages)
public void waitUntilLeaderOffset(String topic, int partition, long offset)