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/06/09 17:11:57 UTC
[GitHub] [pulsar] lhotari commented on a change in pull request #10254: [Broker] Remove possible error case for system topic name checking
lhotari commented on a change in pull request #10254:
URL: https://github.com/apache/pulsar/pull/10254#discussion_r648510777
##########
File path: pulsar-common/src/main/java/org/apache/pulsar/common/events/EventsTopicNames.java
##########
@@ -18,29 +18,34 @@
*/
package org.apache.pulsar.common.events;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
/**
- * System topic name for the event type.
+ * System topic names for each {@link EventType}.
*/
public class EventsTopicNames {
+ /**
+ * All event topics are system topics, and currently, they all have this prefix.
+ */
+ private static final String SYSTEM_TOPIC_LOCAL_NAME_PREFIX = "__";
/**
* Local topic name for the namespace events.
*/
- public static final String NAMESPACE_EVENTS_LOCAL_NAME = "__change_events";
+ public static final String NAMESPACE_EVENTS_LOCAL_NAME = SYSTEM_TOPIC_LOCAL_NAME_PREFIX + "change_events";
/**
* Local topic name for the namespace events.
*/
- public static final String TRANSACTION_BUFFER_SNAPSHOT = "__transaction_buffer_snapshot";
+ public static final String TRANSACTION_BUFFER_SNAPSHOT =
+ SYSTEM_TOPIC_LOCAL_NAME_PREFIX + "transaction_buffer_snapshot";
- public static boolean checkTopicIsEventsNames(String topicName) {
- if (topicName.endsWith(NAMESPACE_EVENTS_LOCAL_NAME)) {
- return true;
- } else if (topicName.endsWith(TRANSACTION_BUFFER_SNAPSHOT)) {
- return true;
- } else {
- return false;
- }
- }
+ /**
+ * The set of all events topic names.
+ */
+ public static final Set<String> EVENTS_TOPIC_NAMES =
+ new HashSet<>(Arrays.asList(NAMESPACE_EVENTS_LOCAL_NAME, TRANSACTION_BUFFER_SNAPSHOT));
Review comment:
this should be wrapped with `Collections.unmodifiableSet` to make the `Set` immutable.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org