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 |
static String |
DEFAULT_ZK_SERVERS |
protected org.apache.kafka.clients.admin.AdminClient |
newAdminClient |
static int |
ZK_CONNECTION_TIMEOUT_MS |
static String |
ZK_SERVERS_PROP |
static int |
ZK_TIMEOUT_MS |
protected org.I0Itec.zkclient.ZkClient |
zkClient |
protected kafka.utils.ZkUtils |
zkUtils |
Constructor and Description |
---|
KafkaUtils() |
KafkaUtils(String zkServers,
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 static org.I0Itec.zkclient.ZkClient |
createZkClient(String zkServers) |
protected static kafka.utils.ZkUtils |
createZkUtils(String zkServers,
org.I0Itec.zkclient.ZkClient zkClient) |
protected kafka.admin.AdminClient |
getAdminClient() |
static String |
getBootstrapServers() |
Set<String> |
getBrokerEndPoints() |
protected List<String> |
getConsumerTopics(String group) |
static Properties |
getDefaultAdminProperties() |
String |
getDefaultBootstrapServers() |
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 String |
getZkServers() |
static boolean |
kafkaDetected() |
static boolean |
kafkaDetected(String zkServers) |
List<String> |
listAllConsumers() |
List<String> |
listConsumers(String topic) |
List<String> |
listTopics() |
void |
markTopicForDeletion(String topic)
Work only if delete.topic.enable is true which is not the default
|
static List<List<LogPartition>> |
rangeAssignments(int threads,
Map<String,Integer> streams) |
void |
resetConsumerStates(String topic) |
static List<List<LogPartition>> |
roundRobinAssignments(int threads,
Map<String,Integer> streams) |
boolean |
topicExists(String topic) |
public static final String ZK_SERVERS_PROP
public static final String DEFAULT_ZK_SERVERS
public static final String BOOTSTRAP_SERVERS_PROP
public static final String DEFAULT_BOOTSTRAP_SERVERS
public static final int ZK_TIMEOUT_MS
public static final int ZK_CONNECTION_TIMEOUT_MS
protected final org.I0Itec.zkclient.ZkClient zkClient
protected final kafka.utils.ZkUtils zkUtils
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(String zkServers, Properties adminProperties)
public static Properties getDefaultAdminProperties()
public static String getZkServers()
public static String getBootstrapServers()
public static boolean kafkaDetected()
public static boolean kafkaDetected(String zkServers)
protected static kafka.utils.ZkUtils createZkUtils(String zkServers, org.I0Itec.zkclient.ZkClient zkClient)
protected static org.I0Itec.zkclient.ZkClient createZkClient(String zkServers)
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 List<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 resetConsumerStates(String topic)
public Set<String> getBrokerEndPoints()
public String getDefaultBootstrapServers()
public void close()
close
in interface AutoCloseable
Copyright © 2018 Nuxeo. All rights reserved.