Class CreateTopicPolicy

java.lang.Object
io.confluent.kafka.server.plugins.policy.CreateTopicPolicy
All Implemented Interfaces:
AutoCloseable, org.apache.kafka.common.Configurable, org.apache.kafka.common.Reconfigurable, org.apache.kafka.metadata.ConfluentPartitionsPerTopicListener, org.apache.kafka.server.interceptor.Monitorable, org.apache.kafka.server.multitenant.MultiTenantMetadataPublisher, org.apache.kafka.server.policy.CreateTopicPolicy

public class CreateTopicPolicy extends Object implements org.apache.kafka.server.policy.CreateTopicPolicy, org.apache.kafka.metadata.ConfluentPartitionsPerTopicListener, org.apache.kafka.server.interceptor.Monitorable, org.apache.kafka.server.multitenant.MultiTenantMetadataPublisher, org.apache.kafka.common.Reconfigurable
  • Constructor Details

    • CreateTopicPolicy

      public CreateTopicPolicy()
  • Method Details

    • configure

      public void configure(Map<String,?> configs)
      Specified by:
      configure in interface org.apache.kafka.common.Configurable
    • registerMetrics

      public void registerMetrics(org.apache.kafka.common.metrics.Metrics metrics)
      Specified by:
      registerMetrics in interface org.apache.kafka.server.interceptor.Monitorable
    • validate

      public void validate(org.apache.kafka.server.policy.CreateTopicPolicy.RequestMetadata reqMetadata) throws org.apache.kafka.common.errors.PolicyViolationException
      Specified by:
      validate in interface org.apache.kafka.server.policy.CreateTopicPolicy
      Throws:
      org.apache.kafka.common.errors.PolicyViolationException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • fullUpdate

      public void fullUpdate(Iterator<Map.Entry<String,Integer>> iterator, Map<Integer,Integer> brokersToNumReplicas, Set<String> compactedTopics)
      Specified by:
      fullUpdate in interface org.apache.kafka.metadata.ConfluentPartitionsPerTopicListener
    • partialUpdate

      public void partialUpdate(String topicName, int numPartitionsAddedOrDeleted, int numTopicsAddedOrDeleted, Map<Integer, List<Integer>> partitionIdToReplicasAdded, Map<Integer, List<Integer>> partitionIdToReplicasDeleted, boolean pending, boolean isCompacted)
      Specified by:
      partialUpdate in interface org.apache.kafka.metadata.ConfluentPartitionsPerTopicListener
    • clearPending

      public void clearPending()
      Specified by:
      clearPending in interface org.apache.kafka.metadata.ConfluentPartitionsPerTopicListener
    • name

      public String name()
      Specified by:
      name in interface org.apache.kafka.server.multitenant.MultiTenantMetadataPublisher
    • onMetadataUpdate

      public void onMetadataUpdate(Map<String, ? extends org.apache.kafka.server.multitenant.LogicalClusterMetadata> multiTenantMetadataDelta)
      Specified by:
      onMetadataUpdate in interface org.apache.kafka.server.multitenant.MultiTenantMetadataPublisher
    • reconfigurableConfigs

      public Set<String> reconfigurableConfigs()
      Specified by:
      reconfigurableConfigs in interface org.apache.kafka.common.Reconfigurable
    • validateReconfiguration

      public void validateReconfiguration(Map<String,?> configs) throws org.apache.kafka.common.config.ConfigException
      Specified by:
      validateReconfiguration in interface org.apache.kafka.common.Reconfigurable
      Throws:
      org.apache.kafka.common.config.ConfigException
    • reconfigure

      public void reconfigure(Map<String,?> configs)
      Specified by:
      reconfigure in interface org.apache.kafka.common.Reconfigurable
    • updateTopicPartitionsOnCompactConfigChange

      public void updateTopicPartitionsOnCompactConfigChange(String topicName, String oldValue, String newValue, int numPartitions)
      This file keeps track of a few tenant level andtopic level counters. tenantToNumCompactedPartitions -> Map of tenant to number of compacted partitions each tenant has for tracking purposes compactedPartitionsByTenantMetrics -> Map of tenant to compacted partition count gauge metric for metric reporting purposes pendingTenantCompactedPartitionsAddedOrDeleted -> Map of tenants to partition counts that are in pending state pendingTopicsToPartitions -> Map of topic to partition counts that are in pending state This function gets invoked when a topic's cleanup policy gets updated from delete to compact and vice versa Based on the topic config change, the above-mentioned counters are updated accordingly For example, if a topic's cleanup policy gets updated from compact to delete, then the counters have to be decremented and if the topic's policy gets updated from delete to compact, then the counters have to be incremented.
      Specified by:
      updateTopicPartitionsOnCompactConfigChange in interface org.apache.kafka.metadata.ConfluentPartitionsPerTopicListener
      Parameters:
      topicName - The topic name.
      oldValue - Old value of the topic's clean up policy
      newValue - Updated value of the topic's clean up policy
      numPartitions - Number of partitions the topic has
    • topicPolicyConfig

      public TopicPolicyConfig topicPolicyConfig()
    • frequencies

      public static <E> Map<E,Integer> frequencies(Collection<List<E>> items, Function<E,Integer> mapper)