public final class Cluster
extends java.lang.Object
Constructor and Description |
---|
Cluster(java.lang.String clusterId,
java.util.Collection<Node> nodes,
java.util.Collection<PartitionInfo> partitions,
java.util.Set<java.lang.String> unauthorizedTopics,
java.util.Set<java.lang.String> internalTopics)
Create a new cluster with the given id, nodes and partitions
|
Cluster(java.lang.String clusterId,
java.util.Collection<Node> nodes,
java.util.Collection<PartitionInfo> partitions,
java.util.Set<java.lang.String> unauthorizedTopics,
java.util.Set<java.lang.String> internalTopics,
Node controller)
Create a new cluster with the given id, 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
|
ClusterResource |
clusterResource() |
Node |
controller() |
static Cluster |
empty()
Create an empty cluster instance with no nodes and no topic-partitions.
|
java.util.Set<java.lang.String> |
internalTopics() |
boolean |
isBootstrapConfigured() |
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() |
Cluster |
withPartitions(java.util.Map<TopicPartition,PartitionInfo> partitions)
Return a copy of this cluster combined with `partitions`.
|
public Cluster(java.lang.String clusterId, java.util.Collection<Node> nodes, java.util.Collection<PartitionInfo> partitions, java.util.Set<java.lang.String> unauthorizedTopics, java.util.Set<java.lang.String> internalTopics)
nodes
- The nodes in the clusterpartitions
- Information about a subset of the topic-partitions this cluster hostspublic Cluster(java.lang.String clusterId, java.util.Collection<Node> nodes, java.util.Collection<PartitionInfo> partitions, java.util.Set<java.lang.String> unauthorizedTopics, java.util.Set<java.lang.String> internalTopics, Node controller)
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 Cluster withPartitions(java.util.Map<TopicPartition,PartitionInfo> partitions)
public 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.lang.Integer partitionCountForTopic(java.lang.String topic)
topic
- The topic to get the number of partitions forpublic 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.util.Set<java.lang.String> topics()
public java.util.Set<java.lang.String> unauthorizedTopics()
public java.util.Set<java.lang.String> internalTopics()
public boolean isBootstrapConfigured()
public ClusterResource clusterResource()
public Node controller()
public java.lang.String toString()
toString
in class java.lang.Object