codelipenghui commented on code in PR #25443:
URL: https://github.com/apache/pulsar/pull/25443#discussion_r3192488356
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -550,30 +551,45 @@ private CompletableFuture<Set<String>>
getReplicationClusters() {
}
protected void internalCreateMissedPartitions(AsyncResponse asyncResponse)
{
- getPartitionedTopicMetadataAsync(topicName, false,
false).thenAccept(metadata -> {
- if (metadata != null && metadata.partitions > 0) {
- validateNamespaceOperationAsync(topicName.getNamespaceObject(),
- NamespaceOperation.CREATE_TOPIC)
- .thenCompose(__ ->
tryCreatePartitionsAsync(metadata.partitions)).thenAccept(v -> {
- asyncResponse.resume(Response.noContent().build());
- }).exceptionally(e -> {
- log.error()
- .attr("topic", topicName)
- .log("Failed to create partitions for topic");
- resumeAsyncResponseExceptionally(asyncResponse, e);
- return null;
- });
- } else {
- throw new RestException(Status.NOT_FOUND, String.format("Topic
%s does not exist", topicName));
- }
- }).exceptionally(ex -> {
+ Consumer<Throwable> errorHandler = ex -> {
// If the exception is not redirect exception we need to log it.
if (!isRedirectException(ex)) {
log.error()
.attr("topic", topicName)
.log("Failed to create partitions for topic");
}
resumeAsyncResponseExceptionally(asyncResponse, ex);
+ };
+
pulsar().getBrokerService().isCurrentClusterAllowed(topicName).thenAccept(allowed
-> {
+ if (!allowed) {
+ resumeAsyncResponseExceptionally(asyncResponse,
+ new RestException(Status.BAD_REQUEST, String.format("Topic
[%s] is not allowed to be loaded"
Review Comment:
Two nits: typo `polices` → `policies`; and "loaded up" misdescribes the
action — this is `createMissedPartitions`, not topic loading. Including the
current cluster name in the message would help operators identify which cluster
rejected the request.
--
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]