public class DefaultConnectionFactory extends java.lang.Object implements org.springframework.beans.factory.InitializingBean, ConnectionFactory, org.springframework.beans.factory.DisposableBean
ConnectionFactory
Modifier and Type | Field and Description |
---|---|
static com.gs.collections.api.block.predicate.Predicate<kafka.javaapi.TopicMetadata> |
errorlessTopicMetadataPredicate |
Constructor and Description |
---|
DefaultConnectionFactory(Configuration configuration) |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
Connection |
connect(BrokerAddress brokerAddress)
Create a connection to a Kafka broker, caching it internally
|
void |
destroy() |
Configuration |
getConfiguration() |
BrokerAddress |
getLeader(Partition partition)
Return the leader for a single partition
|
java.util.Map<Partition,BrokerAddress> |
getLeaders(java.lang.Iterable<Partition> partitions)
Retrieve the leaders for a set of partitions.
|
java.util.Collection<Partition> |
getPartitions(java.lang.String topic)
Retrieves the partitions of a given topic
|
void |
refreshMetadata(java.util.Collection<java.lang.String> topics)
Refresh the cached metadata (i.e.
|
public static final com.gs.collections.api.block.predicate.Predicate<kafka.javaapi.TopicMetadata> errorlessTopicMetadataPredicate
public DefaultConnectionFactory(Configuration configuration)
public Configuration getConfiguration()
public void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
public void destroy() throws java.lang.Exception
destroy
in interface org.springframework.beans.factory.DisposableBean
java.lang.Exception
public java.util.Map<Partition,BrokerAddress> getLeaders(java.lang.Iterable<Partition> partitions)
ConnectionFactory
getLeaders
in interface ConnectionFactory
partitions
- whose leaders are queriedConnectionFactory.getLeaders(Iterable)
public BrokerAddress getLeader(Partition partition)
ConnectionFactory
getLeader
in interface ConnectionFactory
partition
- the partition whose leader is queriedConnectionFactory.getLeader(Partition)
public Connection connect(BrokerAddress brokerAddress)
ConnectionFactory
connect
in interface ConnectionFactory
brokerAddress
- a broker addressConnectionFactory.connect(BrokerAddress)
public void refreshMetadata(java.util.Collection<java.lang.String> topics)
ConnectionFactory
refreshMetadata
in interface ConnectionFactory
topics
- the topics for which to refresh the leadersConnectionFactory.refreshMetadata(Collection)
public java.util.Collection<Partition> getPartitions(java.lang.String topic)
ConnectionFactory
getPartitions
in interface ConnectionFactory
topic
- the topic to query forConnectionFactory.getPartitions(String)