Package org.apache.pulsar.broker.service
Class SystemTopicBasedTopicPoliciesService
java.lang.Object
org.apache.pulsar.broker.service.SystemTopicBasedTopicPoliciesService
- All Implemented Interfaces:
AutoCloseable,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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.pulsar.broker.service.TopicPoliciesService
TopicPoliciesService.GetType, TopicPoliciesService.TopicPoliciesServiceDisabled -
Field Summary
Fields inherited from interface org.apache.pulsar.broker.service.TopicPoliciesService
DISABLED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOwnedNamespaceBundleAsync(NamespaceBundle namespaceBundle) voidclose()Close the resources if necessary.protected CompletableFuture<SystemTopicClient.Reader<org.apache.pulsar.common.events.PulsarEvent>>createSystemTopicClient(org.apache.pulsar.common.naming.NamespaceName namespace) deleteTopicPoliciesAsync(org.apache.pulsar.common.naming.TopicName topicName) Delete policies for a topic asynchronously.static StringgetEventKey(org.apache.pulsar.common.events.PulsarEvent event) static StringgetEventKey(org.apache.pulsar.common.naming.TopicName topicName) protected Map<org.apache.pulsar.common.naming.TopicName,List<TopicPolicyListener>> protected Map<org.apache.pulsar.common.naming.TopicName,org.apache.pulsar.common.policies.data.TopicPolicies> getPoliciesCacheInit(org.apache.pulsar.common.naming.NamespaceName namespaceName) CompletableFuture<Optional<org.apache.pulsar.common.policies.data.TopicPolicies>>getTopicPoliciesAsync(org.apache.pulsar.common.naming.TopicName topicName, TopicPoliciesService.GetType type) Retrieve the topic policies.protected com.github.benmanes.caffeine.cache.AsyncLoadingCache<org.apache.pulsar.common.naming.NamespaceName,SystemTopicClient.Writer<org.apache.pulsar.common.events.PulsarEvent>> booleanregisterListener(org.apache.pulsar.common.naming.TopicName topicName, TopicPolicyListener listener) Registers a listener for topic policies updates.voidstart(PulsarService pulsarService) Start the topic policy service.voidunregisterListener(org.apache.pulsar.common.naming.TopicName topicName, TopicPolicyListener listener) Unregister the topic policies listener.updateTopicPoliciesAsync(org.apache.pulsar.common.naming.TopicName topicName, org.apache.pulsar.common.policies.data.TopicPolicies policies) Update policies for a topic asynchronously.
-
Constructor Details
-
SystemTopicBasedTopicPoliciesService
-
-
Method Details
-
deleteTopicPoliciesAsync
public CompletableFuture<Void> deleteTopicPoliciesAsync(org.apache.pulsar.common.naming.TopicName topicName) Description copied from interface:TopicPoliciesServiceDelete policies for a topic asynchronously.- Specified by:
deleteTopicPoliciesAsyncin interfaceTopicPoliciesService- 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:TopicPoliciesServiceUpdate policies for a topic asynchronously.- Specified by:
updateTopicPoliciesAsyncin interfaceTopicPoliciesService- Parameters:
topicName- topic namepolicies- 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:TopicPoliciesServiceRetrieve the topic policies.- Specified by:
getTopicPoliciesAsyncin interfaceTopicPoliciesService
-
addOwnedNamespaceBundleAsync
-
createSystemTopicClient
protected CompletableFuture<SystemTopicClient.Reader<org.apache.pulsar.common.events.PulsarEvent>> createSystemTopicClient(org.apache.pulsar.common.naming.NamespaceName namespace) -
start
Description copied from interface:TopicPoliciesServiceStart the topic policy service.- Specified by:
startin interfaceTopicPoliciesService
-
getEventKey
-
getEventKey
-
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:TopicPoliciesServiceRegisters 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:
registerListenerin interfaceTopicPoliciesService- 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:TopicPoliciesServiceUnregister the topic policies listener.- Specified by:
unregisterListenerin interfaceTopicPoliciesService
-
getPoliciesCache
protected Map<org.apache.pulsar.common.naming.TopicName,org.apache.pulsar.common.policies.data.TopicPolicies> getPoliciesCache() -
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
Description copied from interface:TopicPoliciesServiceClose the resources if necessary.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceTopicPoliciesService- Throws:
Exception
-