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 2021/07/13 06:52:41 UTC

[GitHub] [pulsar] 315157973 opened a new pull request #11294: Fix using partitioned topic name to get Policy

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


   ### Motivation
   In the master branch, the REST API no longer allows the topic name of the partition to be used to set the topic policy, but there are still many places where it will be used internally.
   
   Suppose we set a Topic policy for `persistent://tenant/namespace/topic`
   However, the policy cannot be obtained through `persistent://tenant/namespace/topic-partition-0`, which causes the policy to become invalid.
   
   For example:PersistentTopic.checkSubscriptionTypesEnable
   
   ### Modifications
   Convert the name in SystemTopicBasedTopicPoliciesService
   
   ### Verifying this change
   
   
   
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar] sijie merged pull request #11294: Fix using partitioned topic name to get Policy

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


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar] eolivelli commented on a change in pull request #11294: Fix using partitioned topic name to get Policy

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



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java
##########
@@ -2144,6 +2143,29 @@ public void testAutoCreationDisabled() throws Exception {
         assertNull(admin.topics().getMessageTTL(topic));
     }
 
+    @Test
+    public void testSubscriptionTypesWithPartitionedTopic() throws Exception {
+        final String topic = "persistent://" + myNamespace + "/test-" + UUID.randomUUID();
+        System.out.println(TopicName.get(topic).getLocalName());

Review comment:
       nit: use logger or drop this line

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java
##########
@@ -2144,6 +2143,29 @@ public void testAutoCreationDisabled() throws Exception {
         assertNull(admin.topics().getMessageTTL(topic));
     }
 
+    @Test
+    public void testSubscriptionTypesWithPartitionedTopic() throws Exception {
+        final String topic = "persistent://" + myNamespace + "/test-" + UUID.randomUUID();
+        System.out.println(TopicName.get(topic).getLocalName());
+        admin.topics().createPartitionedTopic(topic, 1);
+        pulsarClient.newConsumer().topic(topic).subscriptionName("test").subscribe().close();
+        Awaitility.await()
+                .until(() -> pulsar.getTopicPoliciesService().cacheIsInitialized(TopicName.get(topic)));
+        Set<SubscriptionType> subscriptionTypeSet = new HashSet<>();
+        subscriptionTypeSet.add(SubscriptionType.Key_Shared);
+        admin.topics().setSubscriptionTypesEnabled(topic, subscriptionTypeSet);
+        Awaitility.await().untilAsserted(() -> assertNotNull(admin.topics().getSubscriptionTypesEnabled(topic)));
+
+        PersistentTopic persistentTopic = (PersistentTopic) pulsar.getBrokerService()
+                .getTopicReference(TopicName.get(topic).getPartition(0).toString()).get();
+        Set<String> old = new HashSet<>(pulsar.getConfiguration().getSubscriptionTypesEnabled());
+        pulsar.getConfiguration().getSubscriptionTypesEnabled().clear();
+        boolean res = persistentTopic.checkSubscriptionTypesEnable(CommandSubscribe.SubType.Key_Shared);
+        //restore
+        pulsar.getConfiguration().getSubscriptionTypesEnabled().addAll(old);

Review comment:
       is it better to do this in a "finally" block ?




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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