Jason918 commented on code in PR #23620:
URL: https://github.com/apache/pulsar/pull/23620#discussion_r1868631593
##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java:
##########
@@ -3702,6 +3702,12 @@ public double
getLoadBalancerBandwidthOutResourceWeight() {
doc = "SSL Factory plugin configuration parameters used by
internal client.")
private String brokerClientSslFactoryPluginParams = "";
+ @FieldContext(category = CATEGORY_SERVER, dynamic = true,
+ doc = "If automatic topic creation is enabled and the name of the
topic contains 'cluster', "
+ + "the topic cannot be automatically created"
+ )
+ private boolean allowAutoTopicCreationWithLegacyNamingScheme = false;
Review Comment:
Same here, better to put this field after `allowAutoTopicCreation`.
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceAutoTopicCreationTest.java:
##########
@@ -587,4 +587,23 @@ public void
testExtensibleLoadManagerImplInternalTopicAutoCreations()
}
+ @Test
+ public void testAutoPartitionedTopicNameWithClusterName() throws Exception
{
+ pulsar.getConfiguration().setAllowAutoTopicCreation(true);
+
pulsar.getConfiguration().setAllowAutoTopicCreationType(TopicType.PARTITIONED);
+ pulsar.getConfiguration().setDefaultNumPartitions(3);
+
+ final String topicString = "persistent://prop/ns-abc/testTopic/1";
+
+ // When allowAutoTopicCreationWithLegacyNamingScheme as the default
value is false,
+ // four-paragraph topic cannot be created.
+ Assert.assertThrows(PulsarClientException.NotFoundException.class,
+ ()-> pulsarClient.newProducer().topic(topicString).create());
+
+
pulsar.getConfiguration().setAllowAutoTopicCreationWithLegacyNamingScheme(true);
+ Producer
producer=pulsarClient.newProducer().topic(topicString).create();
Review Comment:
Please close this `producer` in the end.
##########
conf/broker.conf:
##########
@@ -1966,3 +1966,7 @@ brokerInterceptors=
# Enable or disable the broker interceptor, which is only used for testing for
now
disableBrokerInterceptors=true
+
+# If automatic topic creation is enabled and the name of the topic contains
'cluster',
Review Comment:
```suggestion
# If `allowAutoTopicCreation` is true and the name of the topic contains
'cluster',
```
##########
conf/broker.conf:
##########
@@ -1966,3 +1966,7 @@ brokerInterceptors=
# Enable or disable the broker interceptor, which is only used for testing for
now
disableBrokerInterceptors=true
+
+# If automatic topic creation is enabled and the name of the topic contains
'cluster',
+# the topic cannot be automatically created.
+allowAutoTopicCreationWithLegacyNamingScheme=false
Review Comment:
It's better to put this config after `allowAutoTopicCreationType`. These
configs are grouped by use cases in this file.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]