eolivelli commented on code in PR #19097:
URL: https://github.com/apache/pulsar/pull/19097#discussion_r1058811705
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -3157,42 +3157,38 @@ public CompletableFuture<Boolean>
isAllowAutoTopicCreationAsync(final String top
TopicName topicName = TopicName.get(topic);
return isAllowAutoTopicCreationAsync(topicName);
}
-
public CompletableFuture<Boolean> isAllowAutoTopicCreationAsync(final
TopicName topicName) {
- Optional<Policies> policies =
- pulsar.getPulsarResources().getNamespaceResources()
- .getPoliciesIfCached(topicName.getNamespaceObject());
- return isAllowAutoTopicCreationAsync(topicName, policies);
- }
-
- private CompletableFuture<Boolean> isAllowAutoTopicCreationAsync(final
TopicName topicName,
- final
Optional<Policies> policies) {
- if (policies.isPresent() && policies.get().deleted) {
- log.info("Preventing AutoTopicCreation on a namespace that is
being deleted {}",
- topicName.getNamespaceObject());
- return CompletableFuture.completedFuture(false);
- }
- //System topic can always be created automatically
- if (pulsar.getConfiguration().isSystemTopicEnabled() &&
isSystemTopic(topicName)) {
- return CompletableFuture.completedFuture(true);
- }
- final boolean allowed;
- AutoTopicCreationOverride autoTopicCreationOverride =
getAutoTopicCreationOverride(topicName, policies);
- if (autoTopicCreationOverride != null) {
- allowed = autoTopicCreationOverride.isAllowAutoTopicCreation();
- } else {
- allowed = pulsar.getConfiguration().isAllowAutoTopicCreation();
- }
-
- if (allowed && topicName.isPartitioned()) {
- // cannot re-create topic while it is being deleted
- return
pulsar.getPulsarResources().getNamespaceResources().getPartitionedTopicResources()
- .isPartitionedTopicBeingDeletedAsync(topicName)
- .thenApply(beingDeleted -> !beingDeleted);
- } else {
- return CompletableFuture.completedFuture(allowed);
- }
-
+ return pulsar.getPulsarResources().getNamespaceResources()
+ .getPoliciesAsync(topicName.getNamespaceObject(), true)
Review Comment:
I think that there maybe some case in which it is good to use the local
version of the Policies object.
We need to use "refresh" only when we reach here from a HTTP API call,
I know that is looks pretty convoluted, but with this change in the current
form we are going to use "refresh" (that is a heavyweight operation) probably
in code paths that don't need it
--
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]