New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Transaction] Fix transaction system topic create in loop. #12749
Changes from 2 commits
0f5c031
9758347
f4cfa0a
a46ab12
5e17dcb
55fbbd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1649,14 +1649,21 @@ public void shutdownNow() { | |
} | ||
|
||
|
||
private static boolean isTransactionSystemTopic(TopicName topicName) { | ||
public static boolean isTransactionSystemTopic(TopicName topicName) { | ||
String topic = topicName.toString(); | ||
return topic.startsWith(TopicName.TRANSACTION_COORDINATOR_ASSIGN.toString()) | ||
|| topic.startsWith(TopicName.get(TopicDomain.persistent.value(), | ||
NamespaceName.SYSTEM_NAMESPACE, TRANSACTION_LOG_PREFIX).toString()) | ||
|| topic.endsWith(MLPendingAckStore.PENDING_ACK_STORE_SUFFIX); | ||
} | ||
|
||
public static boolean isNotAllowedToCreateTopic(TopicName topicName) { | ||
String topic = topicName.toString(); | ||
return topic.startsWith(TopicName.get(TopicDomain.persistent.value(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about creating a constant for this ? "TopicName.get(TopicDomain.persistent.value(), NamespaceName.SYSTEM_NAMESPACE, TRANSACTION_LOG_PREFIX).toString()" |
||
NamespaceName.SYSTEM_NAMESPACE, TRANSACTION_LOG_PREFIX).toString()) | ||
|| topic.endsWith(MLPendingAckStore.PENDING_ACK_STORE_SUFFIX); | ||
} | ||
|
||
@VisibleForTesting | ||
protected BrokerService newBrokerService(PulsarService pulsar) throws Exception { | ||
return new BrokerService(pulsar, ioEventLoopGroup); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
*/ | ||
package org.apache.pulsar.broker.admin.impl; | ||
|
||
import static org.apache.pulsar.broker.PulsarService.isNotAllowedToCreateTopic; | ||
import static org.apache.pulsar.broker.resources.PulsarResources.DEFAULT_OPERATION_TIMEOUT_SEC; | ||
import static org.apache.pulsar.common.events.EventsTopicNames.checkTopicIsTransactionCoordinatorAssign; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
|
@@ -244,6 +245,13 @@ protected void validateAdminAndClientPermission() { | |
} | ||
} | ||
|
||
protected void validateTopicAllowdToCreate(TopicName topicName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: validateCreateTopic |
||
if (isNotAllowedToCreateTopic(topicName)) { | ||
log.warn("Try to create a topic in the system topic format! {}", topicName); | ||
throw new RestException(Status.CONFLICT, "Cannot create topic in system topic format!"); | ||
} | ||
} | ||
|
||
public void validateAdminOperationOnTopic(boolean authoritative) { | ||
validateAdminAccessForTenant(topicName.getTenant()); | ||
validateTopicOwnership(topicName, authoritative); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about naming this method
isTransactionInternalName
?the meaning is that this is a reserved name
I see that you are using this method while listing the topic names, so "Create" is not good in that place