public final class Cluster extends Object
Constructor and Description |
---|
Cluster(String clusterId,
Collection<Node> nodes,
Collection<PartitionInfo> partitions,
Set<String> unauthorizedTopics,
Set<String> internalTopics)
Create a new cluster with the given id, nodes and partitions
|
Cluster(String clusterId,
Collection<Node> nodes,
Collection<PartitionInfo> partitions,
Set<String> unauthorizedTopics,
Set<String> internalTopics,
Node controller)
Create a new cluster with the given id, nodes and partitions
|
Cluster(String clusterId,
Collection<Node> nodes,
Collection<PartitionInfo> partitions,
Set<String> unauthorizedTopics,
Set<String> invalidTopics,
Set<String> internalTopics,
Node controller)
Create a new cluster with the given id, nodes and partitions
|
Modifier and Type | Method and Description |
---|---|
List<PartitionInfo> |
availablePartitionsForTopic(String topic)
Get the list of available partitions for this topic
|
static Cluster |
bootstrap(List<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.
|
boolean |
equals(Object o) |
int |
hashCode() |
Set<String> |
internalTopics() |
Set<String> |
invalidTopics() |
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)
|
Optional<Node> |
nodeIfOnline(TopicPartition partition,
int id)
Get the node by node id if the replica for the given partition is online
|
List<Node> |
nodes() |
PartitionInfo |
partition(TopicPartition topicPartition)
Get the metadata for the specified partition
|
Integer |
partitionCountForTopic(String topic)
Get the number of partitions for the given topic.
|
List<PartitionInfo> |
partitionsForNode(int nodeId)
Get the list of partitions whose leader is this node
|
List<PartitionInfo> |
partitionsForTopic(String topic)
Get the list of partitions for this topic
|
Set<String> |
topics()
Get all topics.
|
String |
toString() |
Set<String> |
unauthorizedTopics() |
Cluster |
withPartitions(Map<TopicPartition,PartitionInfo> partitions)
Return a copy of this cluster combined with `partitions`.
|
public Cluster(String clusterId, Collection<Node> nodes, Collection<PartitionInfo> partitions, Set<String> unauthorizedTopics, Set<String> internalTopics)
nodes
- The nodes in the clusterpartitions
- Information about a subset of the topic-partitions this cluster hostspublic Cluster(String clusterId, Collection<Node> nodes, Collection<PartitionInfo> partitions, Set<String> unauthorizedTopics, Set<String> internalTopics, Node controller)
nodes
- The nodes in the clusterpartitions
- Information about a subset of the topic-partitions this cluster hostspublic Cluster(String clusterId, Collection<Node> nodes, Collection<PartitionInfo> partitions, Set<String> unauthorizedTopics, Set<String> invalidTopics, Set<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(List<InetSocketAddress> addresses)
addresses
- The addressespublic Cluster withPartitions(Map<TopicPartition,PartitionInfo> partitions)
public Node nodeById(int id)
id
- The id of the nodepublic Optional<Node> nodeIfOnline(TopicPartition partition, int id)
partition
- id
- public 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 List<PartitionInfo> partitionsForTopic(String topic)
topic
- The topic namepublic Integer partitionCountForTopic(String topic)
topic
- The topic to get the number of partitions forpublic List<PartitionInfo> availablePartitionsForTopic(String topic)
topic
- The topic namepublic List<PartitionInfo> partitionsForNode(int nodeId)
nodeId
- The node idpublic boolean isBootstrapConfigured()
public ClusterResource clusterResource()
public Node controller()