public final class Cluster
extends java.lang.Object
Constructor and Description |
---|
Cluster(java.util.Collection<Node> nodes,
java.util.Collection<PartitionInfo> partitions,
java.util.Set<java.lang.String> unauthorizedTopics)
Create a new cluster with the given nodes and partitions
|
Modifier and Type | Method and Description |
---|---|
java.util.List<PartitionInfo> |
availablePartitionsForTopic(java.lang.String topic)
Get the list of available partitions for this topic
|
static Cluster |
bootstrap(java.util.List<java.net.InetSocketAddress> addresses)
Create a "bootstrap" cluster using the given list of host/ports
|
static Cluster |
empty()
Create an empty cluster instance with no nodes and no topic-partitions.
|
Node |
leaderFor(TopicPartition topicPartition)
Get the current leader for the given topic-partition
|
Node |
nodeById(int id)
Get the node by the node id (or null if no such node exists)
|
java.util.List<Node> |
nodes() |
PartitionInfo |
partition(TopicPartition topicPartition)
Get the metadata for the specified partition
|
java.lang.Integer |
partitionCountForTopic(java.lang.String topic)
Get the number of partitions for the given topic
|
java.util.List<PartitionInfo> |
partitionsForNode(int nodeId)
Get the list of partitions whose leader is this node
|
java.util.List<PartitionInfo> |
partitionsForTopic(java.lang.String topic)
Get the list of partitions for this topic
|
java.util.Set<java.lang.String> |
topics()
Get all topics.
|
java.lang.String |
toString() |
java.util.Set<java.lang.String> |
unauthorizedTopics() |
public Cluster(java.util.Collection<Node> nodes, java.util.Collection<PartitionInfo> partitions, java.util.Set<java.lang.String> unauthorizedTopics)
nodes
- The nodes in the clusterpartitions
- Information about a subset of the topic-partitions this cluster hostspublic static Cluster empty()
public static Cluster bootstrap(java.util.List<java.net.InetSocketAddress> addresses)
addresses
- The addressespublic java.util.List<Node> nodes()
public Node nodeById(int id)
id
- The id of the nodepublic Node leaderFor(TopicPartition topicPartition)
topicPartition
- The topic and partition we want to know the leader forpublic PartitionInfo partition(TopicPartition topicPartition)
topicPartition
- The topic and partition to fetch info forpublic java.util.List<PartitionInfo> partitionsForTopic(java.lang.String topic)
topic
- The topic namepublic java.util.List<PartitionInfo> availablePartitionsForTopic(java.lang.String topic)
topic
- The topic namepublic java.util.List<PartitionInfo> partitionsForNode(int nodeId)
nodeId
- The node idpublic java.lang.Integer partitionCountForTopic(java.lang.String topic)
topic
- The topic to get the number of partitions forpublic java.util.Set<java.lang.String> topics()
public java.util.Set<java.lang.String> unauthorizedTopics()
public java.lang.String toString()
toString
in class java.lang.Object