Technoboy- commented on code in PR #20709:
URL: https://github.com/apache/pulsar/pull/20709#discussion_r1252482006
##########
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdBrokers.java:
##########
@@ -150,8 +150,8 @@ private class ShutDownBrokerGracefully extends CliCommand {
@Override
void run() throws Exception {
-
getAdmin().brokers().shutDownBrokerGracefully(maxConcurrentUnloadPerSec,
forcedTerminateTopic);
- System.out.println("Successfully trigger broker shutdown
gracefully");
+
getAdmin().brokers().shutDownBrokerGracefully(maxConcurrentUnloadPerSec,
forcedTerminateTopic).join();
+ System.out.println("Successfully shutdown broker gracefully");
Review Comment:
I find that we have many async calls in the cli, we'd better add a `sync`
call the CmdBase:
```
protected long getReadTimeoutMs() {
PulsarAdmin pulsarAdmin = getAdmin();
if (pulsarAdmin instanceof PulsarAdminImpl) {
return ((PulsarAdminImpl)
pulsarAdmin).getClientConfigData().getReadTimeoutMs();
}
return 60000;
}
protected <T> T sync(Supplier<CompletableFuture<T>> executor) throws
PulsarAdminException {
try {
return executor.get().get(getReadTimeoutMs(),
TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new PulsarAdminException(e);
} catch (TimeoutException e) {
throw new PulsarAdminException.TimeoutException(e);
} catch (ExecutionException e) {
throw PulsarAdminException.wrap(getApiException(e.getCause()));
} catch (Exception e) {
throw PulsarAdminException.wrap(getApiException(e));
}
}
```
And change this sync:
```
sync(() ->
getAdmin().brokers().shutDownBrokerGracefully(maxConcurrentUnloadPerSec,
forcedTerminateTopic));
System.out.println("Successfully trigger broker shutdown
gracefully");
```
What's your idea ? @codelipenghui @poorbarcode @mattisonchao @coderzc
--
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]