andrasbeni commented on code in PR #16062:
URL: https://github.com/apache/pulsar/pull/16062#discussion_r906179748
##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java:
##########
@@ -110,4 +123,34 @@ public CompletableFuture<Void>
clearTenantPersistence(String tenant) {
}
});
}
+
+ void handleNotification(Notification notification) {
+ if (notification.getPath().startsWith(MANAGED_LEDGER_PATH)
+ && EnumSet.of(NotificationType.Created,
NotificationType.Deleted).contains(notification.getType())) {
+ for (Map.Entry<BiConsumer<String, NotificationType>, Pattern>
entry :
+ new HashMap<>(topicListeners).entrySet()) {
+ Matcher matcher =
entry.getValue().matcher(notification.getPath());
+ if (matcher.matches()) {
+ TopicName topicName = TopicName.get(
+ matcher.group(2),
NamespaceName.get(matcher.group(1)), matcher.group(3));
+ entry.getKey().accept(topicName.toString(),
notification.getType());
+ }
+ }
+ }
+ }
+
+ Pattern namespaceNameToTopicNamePattern(NamespaceName namespaceName) {
Review Comment:
That would improve performance indeed. The only problem I'd have with it is
that we'd be referring to a relatively low-level detail (the managed ledger
path) in a very general and high-level class. To me, it feels like breaking
encapsulation/abstraction.
What do you think about caching the patterns in this class instead?
Something along the lines of `NamespaceName.cache`.
--
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]