Class SystemTopicBasedTopicPoliciesService

java.lang.Object
org.apache.pulsar.broker.service.SystemTopicBasedTopicPoliciesService
All Implemented Interfaces:
AutoCloseable, TopicPoliciesService

public class SystemTopicBasedTopicPoliciesService extends Object implements TopicPoliciesService
Cached topic policies service will cache the system topic reader and the topic policies While reader cache for the namespace was removed, the topic policies will remove automatically.
  • Constructor Details

    • SystemTopicBasedTopicPoliciesService

      public SystemTopicBasedTopicPoliciesService(PulsarService pulsarService)
  • Method Details

    • deleteTopicPoliciesAsync

      public CompletableFuture<Void> deleteTopicPoliciesAsync(org.apache.pulsar.common.naming.TopicName topicName)
      Description copied from interface: TopicPoliciesService
      Delete policies for a topic asynchronously.
      Specified by:
      deleteTopicPoliciesAsync in interface TopicPoliciesService
      Parameters:
      topicName - topic name
    • updateTopicPoliciesAsync

      public CompletableFuture<Void> updateTopicPoliciesAsync(org.apache.pulsar.common.naming.TopicName topicName, org.apache.pulsar.common.policies.data.TopicPolicies policies)
      Description copied from interface: TopicPoliciesService
      Update policies for a topic asynchronously.
      Specified by:
      updateTopicPoliciesAsync in interface TopicPoliciesService
      Parameters:
      topicName - topic name
      policies - policies for the topic name
    • getTopicPoliciesAsync

      public CompletableFuture<Optional<org.apache.pulsar.common.policies.data.TopicPolicies>> getTopicPoliciesAsync(org.apache.pulsar.common.naming.TopicName topicName, TopicPoliciesService.GetType type)
      Description copied from interface: TopicPoliciesService
      Retrieve the topic policies.
      Specified by:
      getTopicPoliciesAsync in interface TopicPoliciesService
    • addOwnedNamespaceBundleAsync

      public void addOwnedNamespaceBundleAsync(NamespaceBundle namespaceBundle)
    • createSystemTopicClient

      protected CompletableFuture<SystemTopicClient.Reader<org.apache.pulsar.common.events.PulsarEvent>> createSystemTopicClient(org.apache.pulsar.common.naming.NamespaceName namespace)
    • start

      public void start(PulsarService pulsarService)
      Description copied from interface: TopicPoliciesService
      Start the topic policy service.
      Specified by:
      start in interface TopicPoliciesService
    • getEventKey

      public static String getEventKey(org.apache.pulsar.common.events.PulsarEvent event)
    • getEventKey

      public static String getEventKey(org.apache.pulsar.common.naming.TopicName topicName)
    • getPoliciesCacheInit

      public CompletableFuture<Void> getPoliciesCacheInit(org.apache.pulsar.common.naming.NamespaceName namespaceName)
    • registerListener

      public boolean registerListener(org.apache.pulsar.common.naming.TopicName topicName, TopicPolicyListener listener)
      Description copied from interface: TopicPoliciesService
      Registers a listener for topic policies updates.

      The listener will receive the latest topic policies when they are updated. If the policies are removed, the listener will receive a null value. Note that not every update is guaranteed to trigger the listener. For instance, if the policies change from A -> B -> null -> C in quick succession, only the final state (C) is guaranteed to be received by the listener. In summary, the listener is guaranteed to receive only the latest value.

      Specified by:
      registerListener in interface TopicPoliciesService
      Returns:
      true if the listener is registered successfully
    • unregisterListener

      public void unregisterListener(org.apache.pulsar.common.naming.TopicName topicName, TopicPolicyListener listener)
      Description copied from interface: TopicPoliciesService
      Unregister the topic policies listener.
      Specified by:
      unregisterListener in interface TopicPoliciesService
    • getPoliciesCache

      protected Map<org.apache.pulsar.common.naming.TopicName,org.apache.pulsar.common.policies.data.TopicPolicies> getPoliciesCache()
    • getListeners

      protected Map<org.apache.pulsar.common.naming.TopicName,List<TopicPolicyListener>> getListeners()
    • getWriterCaches

      protected com.github.benmanes.caffeine.cache.AsyncLoadingCache<org.apache.pulsar.common.naming.NamespaceName,SystemTopicClient.Writer<org.apache.pulsar.common.events.PulsarEvent>> getWriterCaches()
    • close

      public void close() throws Exception
      Description copied from interface: TopicPoliciesService
      Close the resources if necessary.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface TopicPoliciesService
      Throws:
      Exception