public class TenantPartitionAssignor
extends java.lang.Object
CreateTopicsRequest and CreatePartitionsRequest are processed only on the controller. So only one broker computes assignments at any one time. To avoid reading all topics from ZooKeeper for every request, we use the cluster obtained from MetadataCache. If cluster/topic information is not available, we fallback to default assignment in the broker.
Note: Delays in propagating metadata can result in slightly imbalanced assignments.
This assignor attempts to distribute partitions of each topic across available brokers, taking racks into account for replica placement. Assignment algorithm for partitions that are a multiple of the number of brokers is similar to the default replica assignment used by brokers. For the remainder of the partitions, current tenant assignments are taken into account to achieve balanced allocation for tenants.
Modifier and Type | Class and Description |
---|---|
static class |
TenantPartitionAssignor.TopicInfo
Topic details from new topic or partition create request.
|
Constructor and Description |
---|
TenantPartitionAssignor() |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.Integer>>> |
assignPartitionsForExistingTopics(java.lang.String tenant,
java.util.Map<java.lang.String,java.lang.Integer> partitionCounts)
Assign partitions for a CreatePartitions request.
|
java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.Integer>>> |
assignPartitionsForNewTopics(java.lang.String tenant,
java.util.Map<java.lang.String,TenantPartitionAssignor.TopicInfo> newTopics)
Assign partitions for a CreateTopics request.
|
void |
updateClusterMetadata(org.apache.kafka.common.Cluster cluster) |
public void updateClusterMetadata(org.apache.kafka.common.Cluster cluster)
public java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.Integer>>> assignPartitionsForNewTopics(java.lang.String tenant, java.util.Map<java.lang.String,TenantPartitionAssignor.TopicInfo> newTopics)
tenant
- Tenant corresponding to the requestnewTopics
- Topic metadata for new topics including partition count and replication factorpublic java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.Integer>>> assignPartitionsForExistingTopics(java.lang.String tenant, java.util.Map<java.lang.String,java.lang.Integer> partitionCounts)
tenant
- Tenant corresponding to the requestpartitionCounts
- Total partition count for each topic after partitions are created.