Cluster

Cluster represents a subset of the nodes and topic partitions in a Kafka cluster.

Note
org.apache.kafka.common.Cluster is a public final class.

A special variant of a cluster is boostrap cluster that is made up of the bootstrap brokers that are mandatory (and specified explicitly) when Kafka clients are created, i.e. KafkaAdminClient, AdminClient, KafkaConsumer and KafkaProducer.

Note
A bootstrap cluster does not hold all information about the cluster.

Cluster is created when:

Table 1. Cluster’s Internal Properties (e.g. Registries, Counters and Flags)
Name Description

isBootstrapConfigured

Flag…​FIXME

Used when…​FIXME

partitionsByTopic

bootstrap Factory Method

static Cluster bootstrap(List<InetSocketAddress> addresses)

bootstrap…​FIXME

Note
bootstrap is used when KafkaAdminClient, KafkaConsumer and KafkaProducer are created (and update their internal metadata).

isBootstrapConfigured Method

boolean isBootstrapConfigured()

isBootstrapConfigured gives isBootstrapConfigured internal flag.

Note
isBootstrapConfigured is used when…​FIXME

Getting Partitions for Topic — partitionsForTopic Method

List<PartitionInfo> partitionsForTopic(String topic)

partitionsForTopic returns a collection of zero or more partition of the input topic from partitionsByTopic internal lookup table.

Note

partitionsForTopic is used when:

availablePartitionsForTopic Method

List<PartitionInfo> availablePartitionsForTopic(String topic)

availablePartitionsForTopic…​FIXME

Note
availablePartitionsForTopic is used when…​FIXME

Creating Cluster Instance

Cluster takes the following when created:

  • Cluster ID

  • isBootstrapConfigured flag

  • Kafka Nodes (Collection<Node>)

  • Kafka PartitionInfos (Collection<PartitionInfo>)

  • Names of the unauthorized topics

  • Names of the invalid topics

  • Names of the internal topics

  • Controller (as a Kafka Node)

Cluster initializes the internal registries and counters.

Creating Empty Cluster Metadata — empty Factory Method

static Cluster empty()

empty…​FIXME

Note

empty is used when:

Creating Cluster Metadata With Given Partitions — withPartitions Method

Cluster withPartitions(Map<TopicPartition, PartitionInfo> partitions)

withPartitions…​FIXME

withPartitions is used exclusively when Kafka Streams' StreamsPartitionAssignor is requested to assign and onAssignment.

results matching ""

    No results matching ""