public class KafkaUtils extends Object implements AutoCloseable
Modifier and Type | Field and Description |
---|---|
protected kafka.admin.AdminClient |
adminClient |
protected Properties |
adminProperties |
protected static long |
ALL_CONSUMERS_CACHE_TIMEOUT_MS |
protected List<String> |
allConsumers |
protected long |
allConsumersTime |
static String |
BOOTSTRAP_SERVERS_PROP |
static String |
DEFAULT_BOOTSTRAP_SERVERS |
protected org.apache.kafka.clients.admin.AdminClient |
newAdminClient |
Constructor and Description |
---|
KafkaUtils() |
KafkaUtils(Properties adminProperties) |
Modifier and Type | Method and Description |
---|---|
protected static List<List<LogPartition>> |
assignments(org.apache.kafka.clients.consumer.internals.PartitionAssignor assignor,
int threads,
Map<String,Integer> streams) |
void |
close() |
void |
createTopic(String topic,
int partitions,
short replicationFactor) |
void |
createTopicWithoutReplication(String topic,
int partitions) |
protected kafka.admin.AdminClient |
getAdminClient() |
static String |
getBootstrapServers() |
protected List<String> |
getConsumerTopics(String group) |
static Properties |
getDefaultAdminProperties() |
protected org.apache.kafka.clients.admin.AdminClient |
getNewAdminClient() |
int |
getNumberOfPartitions(String topic) |
protected static Collection<org.apache.kafka.common.PartitionInfo> |
getPartsFor(String topic,
int partitions) |
static boolean |
kafkaDetected() |
List<String> |
listAllConsumers() |
List<String> |
listConsumers(String topic) |
Set<String> |
listTopics() |
void |
markTopicForDeletion(String topic)
Work only if delete.topic.enable is true which is not the default
|
int |
partitions(String topic) |
static List<List<LogPartition>> |
rangeAssignments(int threads,
Map<String,Integer> streams) |
static List<List<LogPartition>> |
roundRobinAssignments(int threads,
Map<String,Integer> streams) |
boolean |
topicExists(String topic) |
public static final String BOOTSTRAP_SERVERS_PROP
public static final String DEFAULT_BOOTSTRAP_SERVERS
protected final Properties adminProperties
protected kafka.admin.AdminClient adminClient
protected org.apache.kafka.clients.admin.AdminClient newAdminClient
protected List<String> allConsumers
protected long allConsumersTime
protected static final long ALL_CONSUMERS_CACHE_TIMEOUT_MS
public KafkaUtils()
public KafkaUtils(Properties adminProperties)
public static Properties getDefaultAdminProperties()
public static String getBootstrapServers()
public static boolean kafkaDetected()
public static List<List<LogPartition>> rangeAssignments(int threads, Map<String,Integer> streams)
public static List<List<LogPartition>> roundRobinAssignments(int threads, Map<String,Integer> streams)
protected static List<List<LogPartition>> assignments(org.apache.kafka.clients.consumer.internals.PartitionAssignor assignor, int threads, Map<String,Integer> streams)
protected static Collection<org.apache.kafka.common.PartitionInfo> getPartsFor(String topic, int partitions)
public void createTopicWithoutReplication(String topic, int partitions)
public void createTopic(String topic, int partitions, short replicationFactor)
public boolean topicExists(String topic)
public int partitions(String topic)
public Set<String> listTopics()
public List<String> listConsumers(String topic)
protected List<String> getConsumerTopics(String group)
protected org.apache.kafka.clients.admin.AdminClient getNewAdminClient()
protected kafka.admin.AdminClient getAdminClient()
public List<String> listAllConsumers()
public void markTopicForDeletion(String topic)
public int getNumberOfPartitions(String topic)
public void close()
close
in interface AutoCloseable
Copyright © 2018 Nuxeo. All rights reserved.