You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/10/11 04:47:27 UTC

[GitHub] [pulsar] 315157973 opened a new pull request #8234: Modify the occasion of triggering listeners

315157973 opened a new pull request #8234:
URL: https://github.com/apache/pulsar/pull/8234


   ### Motivation
   When we use `SystemTopicBasedTopicPoliciesService#updateTopicPoliciesAsync` to update Topic-level policies, `Listener.onUpdate()` will be triggered;
   Now this approach will cause 2 problems:
   1) Because `updateTopicPoliciesAsync` only sends the message to the system topic, it has not been consumed yet. Therefore, the policy data in the cache is still old. When listeners are triggered, they cannot get the policies directly through the cache. They have to modify the existing interface and pass the policies through parameters.
   2) When the broker restarts, some topic-level policies will no longer take effect, because they rely on the `onUpdate` method to take effect
   
   ### Modifications
   1)The trigger occasion of `listener.onUpdate` is changed to when the reader consumes the event
   2)fix some npe
   
   ### Verifying this change
   
   TopicPoliciesTest#testRestart


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] codelipenghui merged pull request #8234: Modify the occasion of triggering listeners

Posted by GitBox <gi...@apache.org>.
codelipenghui merged pull request #8234:
URL: https://github.com/apache/pulsar/pull/8234


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] 315157973 commented on a change in pull request #8234: Modify the occasion of triggering listeners

Posted by GitBox <gi...@apache.org>.
315157973 commented on a change in pull request #8234:
URL: https://github.com/apache/pulsar/pull/8234#discussion_r502871966



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -2427,14 +2427,8 @@ public void onUpdate(TopicPolicies policies) {
         }
     }
 
-    private Optional<Policies> getNamespacePolicies(){
-        try {
-            return Optional.ofNullable(brokerService.pulsar().getAdminClient().namespaces()
-                    .getPolicies(TopicName.get(topic).getNamespace()));
-        } catch (Exception e) {
-            log.error("get namespace policies fail", e);
-        }
-        return Optional.empty();
+    private Optional<Policies> getNamespacePolicies() {
+        return DispatchRateLimiter.getPolicies(brokerService, topic);

Review comment:
       This is a static tool method, and has nothing to do with whether DispatchRateLimiter is enabled




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] codelipenghui commented on a change in pull request #8234: Modify the occasion of triggering listeners

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #8234:
URL: https://github.com/apache/pulsar/pull/8234#discussion_r502871661



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -2427,14 +2427,8 @@ public void onUpdate(TopicPolicies policies) {
         }
     }
 
-    private Optional<Policies> getNamespacePolicies(){
-        try {
-            return Optional.ofNullable(brokerService.pulsar().getAdminClient().namespaces()
-                    .getPolicies(TopicName.get(topic).getNamespace()));
-        } catch (Exception e) {
-            log.error("get namespace policies fail", e);
-        }
-        return Optional.empty();
+    private Optional<Policies> getNamespacePolicies() {
+        return DispatchRateLimiter.getPolicies(brokerService, topic);

Review comment:
       Why do we need to get the namespace policy from the DispatchRateLimiter? If we don't enable the dispatch rate limiter, is it possible to get the namespace policy?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] codelipenghui commented on a change in pull request #8234: Modify the occasion of triggering listeners

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #8234:
URL: https://github.com/apache/pulsar/pull/8234#discussion_r502872164



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -2427,14 +2427,8 @@ public void onUpdate(TopicPolicies policies) {
         }
     }
 
-    private Optional<Policies> getNamespacePolicies(){
-        try {
-            return Optional.ofNullable(brokerService.pulsar().getAdminClient().namespaces()
-                    .getPolicies(TopicName.get(topic).getNamespace()));
-        } catch (Exception e) {
-            log.error("get namespace policies fail", e);
-        }
-        return Optional.empty();
+    private Optional<Policies> getNamespacePolicies() {
+        return DispatchRateLimiter.getPolicies(brokerService, topic);

Review comment:
       Ok




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org