Package org.apache.kafka.common
Class Cluster
java.lang.Object
org.apache.kafka.common.Cluster
An immutable representation of a subset of the nodes, topics, and partitions in the Kafka cluster.
- 
Constructor SummaryConstructorsConstructorDescriptionCluster(String clusterId, Collection<Node> nodes, Collection<PartitionInfo> partitions, Set<String> unauthorizedTopics, Set<String> internalTopics) Create a new cluster with the given id, nodes and partitionsCluster(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 partitionsCluster(String clusterId, Collection<Node> nodes, Collection<PartitionInfo> partitions, Set<String> unauthorizedTopics, Set<String> invalidTopics, Set<String> internalTopics, Node controller, Map<String, Uuid> topicIds) Create a new cluster with the given id, nodes, partitions and topicIdsCluster(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
- 
Method SummaryModifier and TypeMethodDescriptionGet the list of available partitions for this topicstatic Clusterbootstrap(List<InetSocketAddress> addresses) Create a "bootstrap" cluster using the given list of host/portsstatic Clusterempty()Create an empty cluster instance with no nodes and no topic-partitions.booleaninthashCode()booleanleaderFor(TopicPartition topicPartition) Get the current leader for the given topic-partitionnodeById(int id) Get the node by the node id (or null if the node is not online or does not exist)nodeIfOnline(TopicPartition partition, int id) Get the node by node id if the replica for the given partition is onlinenodes()partition(TopicPartition topicPartition) Get the metadata for the specified partitionpartitionCountForTopic(String topic) Get the number of partitions for the given topic.partitionsForNode(int nodeId) Get the list of partitions whose leader is this nodepartitionsForTopic(String topic) Get the list of partitions for this topictopicIds()topics()Get all topics.toString()withPartitions(Map<TopicPartition, PartitionInfo> partitions) Return a copy of this cluster combined with `partitions`.
- 
Constructor Details- 
Clusterpublic 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- Parameters:
- nodes- The nodes in the cluster
- partitions- Information about a subset of the topic-partitions this cluster hosts
 
- 
Clusterpublic 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- Parameters:
- nodes- The nodes in the cluster
- partitions- Information about a subset of the topic-partitions this cluster hosts
 
- 
Clusterpublic 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- Parameters:
- nodes- The nodes in the cluster
- partitions- Information about a subset of the topic-partitions this cluster hosts
 
- 
Clusterpublic Cluster(String clusterId, Collection<Node> nodes, Collection<PartitionInfo> partitions, Set<String> unauthorizedTopics, Set<String> invalidTopics, Set<String> internalTopics, Node controller, Map<String, Uuid> topicIds) Create a new cluster with the given id, nodes, partitions and topicIds- Parameters:
- nodes- The nodes in the cluster
- partitions- Information about a subset of the topic-partitions this cluster hosts
 
 
- 
- 
Method Details- 
emptyCreate an empty cluster instance with no nodes and no topic-partitions.
- 
bootstrapCreate a "bootstrap" cluster using the given list of host/ports- Parameters:
- addresses- The addresses
- Returns:
- A cluster for these hosts/ports
 
- 
withPartitionsReturn a copy of this cluster combined with `partitions`.
- 
nodes- Returns:
- The known set of nodes
 
- 
nodeByIdGet the node by the node id (or null if the node is not online or does not exist)- Parameters:
- id- The id of the node
- Returns:
- The node, or null if the node is not online or does not exist
 
- 
nodeIfOnlineGet the node by node id if the replica for the given partition is online- Parameters:
- partition-
- id-
- Returns:
- the node
 
- 
leaderForGet the current leader for the given topic-partition- Parameters:
- topicPartition- The topic and partition we want to know the leader for
- Returns:
- The node that is the leader for this topic-partition, or null if there is currently no leader
 
- 
partitionGet the metadata for the specified partition- Parameters:
- topicPartition- The topic and partition to fetch info for
- Returns:
- The metadata about the given topic and partition, or null if none is found
 
- 
partitionsForTopicGet the list of partitions for this topic- Parameters:
- topic- The topic name
- Returns:
- A list of partitions
 
- 
partitionCountForTopicGet the number of partitions for the given topic.- Parameters:
- topic- The topic to get the number of partitions for
- Returns:
- The number of partitions or null if there is no corresponding metadata
 
- 
availablePartitionsForTopicGet the list of available partitions for this topic- Parameters:
- topic- The topic name
- Returns:
- A list of partitions
 
- 
partitionsForNodeGet the list of partitions whose leader is this node- Parameters:
- nodeId- The node id
- Returns:
- A list of partitions
 
- 
topicsGet all topics.- Returns:
- a set of all topics
 
- 
unauthorizedTopics
- 
invalidTopics
- 
internalTopics
- 
isBootstrapConfiguredpublic boolean isBootstrapConfigured()
- 
clusterResource
- 
controller
- 
topicIds
- 
topicId
- 
topicName
- 
toString
- 
equals
- 
hashCodepublic int hashCode()
 
-