Technoboy- commented on code in PR #15296:
URL: https://github.com/apache/pulsar/pull/15296#discussion_r857512289
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TransactionsBase.java:
##########
@@ -432,4 +434,35 @@ protected void validateTopicName(String property, String
namespace, String encod
throw new RestException(Response.Status.PRECONDITION_FAILED,
"Topic name is not valid");
}
}
+
+ protected void internalScaleTransactionCoordinators(int replicas, boolean
authoritative) {
+ final int maxPartitions =
pulsar().getConfig().getMaxNumPartitionsPerPartitionedTopic();
+ if (maxPartitions > 0 && replicas > maxPartitions) {
+ throw new RestException(Response.Status.NOT_ACCEPTABLE,
+ "Number of partitions should be less than or equal to " +
maxPartitions);
+ }
+
validateTopicOwnership(SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN,
authoritative);
+ CompletableFuture<Void> updatePartition = new CompletableFuture<>();
+ namespaceResources().getPartitionedTopicResources()
+
.updatePartitionedTopicAsync(SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN, p
-> {
+ if (p.partitions >= replicas) {
+ throw new
RestException(Response.Status.NOT_ACCEPTABLE, "Number of partitions should "
+ + "be more than the current number of
transaction coordinator partitions");
+ }
+ return new PartitionedTopicMetadata(replicas);
+ }).thenAccept(r ->
updatePartition.complete(null)).exceptionally(ex -> {
+ updatePartition.completeExceptionally(ex.getCause());
+ return null;
+ });
+ try {
+ updatePartition.get(DEFAULT_OPERATION_TIMEOUT_SEC,
TimeUnit.SECONDS);
Review Comment:
New REST APIs should all use the async method.
--
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]