poorbarcode commented on code in PR #25443:
URL: https://github.com/apache/pulsar/pull/25443#discussion_r3196435992
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -4136,6 +4153,38 @@ public void
setPulsarChannelInitializerFactory(PulsarChannelInitializer.Factory
this.pulsarChannelInitFactory = factory;
}
+ /**
+ * @return Triple [namespace policies, global topic policies, topic
policies].
+ */
+ public CompletableFuture<Boolean> isCurrentClusterAllowed(@NonNull
TopicName topicName) {
+ final String cluster = getPulsar().getConfig().getClusterName();
+ return getCombinedTopicPolicies(topicName).thenApply(triple -> {
+ Optional<TopicPolicies> topicP = triple.getRight();
+ Optional<TopicPolicies> globalTopicP = triple.getMiddle();
+ Optional<Policies> nsPolicies = triple.getLeft();
+ // Disabled a cluster for a namespace manually.
+ if (nsPolicies.isPresent() &&
!isCurrentClusterAllowed(topicName.getNamespaceObject(), nsPolicies.get())) {
Review Comment:
> Possible regression: isCurrentClusterAllowed(NamespaceName, Policies)
returns false when namespace replication_clusters excludes the current cluster
(with empty allowed_clusters). But topic-level replicationClusters is supposed
to override namespace-level defaults — e.g. ns replication_clusters=[c1], topic
replicationClusters=[c1,c2] should be allowed on c2, but this short-circuit
returns false.
This situation does not exist. Let's review all possible use cases:
1. Both clusters use a shared metadata store
a. The topic will never be allowed to be accessed by the current cluster,
even if the topic-level replication policy contains `{current cluster}`.
b. The [PIP-321 Introduce `allowed-cluster` at the namespace
level](https://github.com/apache/pulsar/pull/21648/changes#diff-01b14c55e65a5acb0c710b4eb0d45e039f43a2d5f54ec4740ee64f069ef6abc6R29-R30)
introduces concept `namespace level allowed_clusters` to let clusters that
using shared metadata store can enable topic level replication.
2. Both clusters use their own metadata store
a. All namespace-level `replication_clutsers` will contain the current
cluster, and namespace-level `replication cluster` can not be set to a empty
value.
b. No one will remove `current cluster` from namespace-level
`replication_clusters`, which is meaningless
--
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]