Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ interface Reader<T> {
}

static boolean isSystemTopic(TopicName topicName) {
if (topicName.isPartitioned()) {
return EventsTopicNames.NAMESPACE_EVENTS_LOCAL_NAME
.equals(TopicName.get(topicName.getPartitionedTopicName()).getLocalName());
}

return EventsTopicNames.NAMESPACE_EVENTS_LOCAL_NAME.equals(topicName.getLocalName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.common.events.ActionType;
import org.apache.pulsar.common.events.EventType;
import org.apache.pulsar.common.events.EventsTopicNames;
import org.apache.pulsar.common.events.PulsarEvent;
import org.apache.pulsar.common.events.TopicPoliciesEvent;
import org.apache.pulsar.common.naming.NamespaceName;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.common.policies.data.ClusterData;
import org.apache.pulsar.common.policies.data.TenantInfo;
import org.apache.pulsar.common.policies.data.TopicPolicies;
Expand Down Expand Up @@ -108,6 +110,18 @@ public void testSendAndReceiveNamespaceEvents() throws Exception {
Assert.assertEquals(systemTopicClientForNamespace1.getReaders().size(), 0);
}

@Test(timeOut = 30000)
public void checkSystemTopic() throws PulsarAdminException {
final String systemTopic = "persistent://" + NAMESPACE1 + "/" + EventsTopicNames.NAMESPACE_EVENTS_LOCAL_NAME;
final String normalTopic = "persistent://" + NAMESPACE1 + "/normal_topic";
admin.topics().createPartitionedTopic(normalTopic, 3);
TopicName systemTopicName = TopicName.get(systemTopic);
TopicName normalTopicName = TopicName.get(normalTopic);

Assert.assertEquals(SystemTopicClient.isSystemTopic(systemTopicName), true);
Assert.assertEquals(SystemTopicClient.isSystemTopic(normalTopicName), false);
}

private void prepareData() throws PulsarAdminException {
admin.clusters().createCluster("test", new ClusterData(pulsar.getBrokerServiceUrl()));
admin.tenants().createTenant("system-topic",
Expand Down