JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1250113352
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java:
##########
@@ -545,16 +545,27 @@ public void shutDownBrokerGracefully(
@ApiParam(name = "maxConcurrentUnloadPerSec",
value = "if the value absent(value=0) means no concurrent
limitation.")
@QueryParam("maxConcurrentUnloadPerSec") int
maxConcurrentUnloadPerSec,
- @QueryParam("forcedTerminateTopic") @DefaultValue("true") boolean
forcedTerminateTopic
+ @QueryParam("forcedTerminateTopic") @DefaultValue("true") boolean
forcedTerminateTopic,
+ @Suspended final AsyncResponse asyncResponse
) {
validateSuperUserAccess();
- doShutDownBrokerGracefully(maxConcurrentUnloadPerSec,
forcedTerminateTopic);
+ doShutDownBrokerGracefullyAsync(maxConcurrentUnloadPerSec,
forcedTerminateTopic, asyncResponse);
}
- private void doShutDownBrokerGracefully(int maxConcurrentUnloadPerSec,
- boolean forcedTerminateTopic) {
+ private void doShutDownBrokerGracefullyAsync(int
maxConcurrentUnloadPerSec, boolean forcedTerminateTopic,
+ AsyncResponse
asyncResponse) {
pulsar().getBrokerService().unloadNamespaceBundlesGracefully(maxConcurrentUnloadPerSec,
forcedTerminateTopic);
- pulsar().closeAsync();
+ CompletableFuture
+ .runAsync(
+ () -> {
+ pulsar().closeAsync();
+ LOG.info("Broker graceful shutdown successfully");
+ })
+ .exceptionally(ex -> {
+ LOG.error("Broker graceful shutdown failed", ex);
+ return null;
+ });
+ asyncResponse.resume(Response.noContent().build());
Review Comment:
Yes, adding a flag can be done and also previously suggested by
https://github.com/apache/pulsar/pull/20651#discussion_r1243567246. But such
sounds like an additional functionality that can be done in separate PR.
This PR is targeted to do the following
1. fix the shutdown command exiting before request is sent
2. maintain the overall working sequence of shutdown API
--
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]