You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "JooHyukKim (via GitHub)" <gi...@apache.org> on 2023/06/26 15:16:56 UTC
[GitHub] [pulsar] JooHyukKim opened a new pull request, #20651: [improve][admin] call POST `/brokers/shutdown` synchronously from `Brokers` API
JooHyukKim opened a new pull request, #20651:
URL: https://github.com/apache/pulsar/pull/20651
Fixes : #20617
### Motivation
Currently admin api invokes `Brokers.shutDownBrokerGracefully()` asynchronously, thereby failing to ensure that shutdown request is successfully sent before return.
Since the graceful shutdown Broker shutdown already runs asynchronously as shown in...
https://github.com/apache/pulsar/blob/2b01f83ea4f3ab7b22f4ea2b0290cc183e79bbb8/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java#L554-L558
... so I believe that we can synchronize REST API call on the client side.
### Modifications
- call POST `/brokers/shutdown` synchronously from `Brokers` API and let Brokerย handle asynchronicity.
### Verifying this change
- [x] Make sure that the change passes the CI checks.
### Does this pull request potentially affect one of the following parts:
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
*If the box was checked, please highlight the changes*
- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: https://github.com/JooHyukKim/pulsar/pull/12
<!--
After opening this PR, the build in apache/pulsar will fail and instructions will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed in
a forked repository.
The tests will be run in the forked repository until all PR review comments have
been handled, the tests pass and the PR is approved by a reviewer.
-->
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codecov-commenter commented on pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#issuecomment-1618521187
## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/20651?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#20651](https://app.codecov.io/gh/apache/pulsar/pull/20651?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (837fee2) into [master](https://app.codecov.io/gh/apache/pulsar/commit/0e603405c2a6faaa50a47881916a2c1268de9830?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (0e60340) will **increase** coverage by `0.01%`.
> The diff coverage is `81.81%`.
[](https://app.codecov.io/gh/apache/pulsar/pull/20651?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #20651 +/- ##
============================================
+ Coverage 72.60% 72.61% +0.01%
- Complexity 32018 32099 +81
============================================
Files 1855 1859 +4
Lines 138569 138802 +233
Branches 15250 15270 +20
============================================
+ Hits 100605 100795 +190
- Misses 29945 29984 +39
- Partials 8019 8023 +4
```
| Flag | Coverage ฮ | |
|---|---|---|
| inttests | `24.20% <0.00%> (+0.09%)` | :arrow_up: |
| unittests | `72.38% <81.81%> (+0.02%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://app.codecov.io/gh/apache/pulsar/pull/20651?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage ฮ | |
|---|---|---|
| [...g/apache/pulsar/broker/admin/impl/BrokersBase.java](https://app.codecov.io/gh/apache/pulsar/pull/20651?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL0Jyb2tlcnNCYXNlLmphdmE=) | `70.61% <80.00%> (+0.15%)` | :arrow_up: |
| [...ache/pulsar/client/admin/internal/BrokersImpl.java](https://app.codecov.io/gh/apache/pulsar/pull/20651?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWNsaWVudC1hZG1pbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9hZG1pbi9pbnRlcm5hbC9Ccm9rZXJzSW1wbC5qYXZh) | `83.07% <100.00%> (+0.26%)` | :arrow_up: |
... and [87 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/20651/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1250269269
##########
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:
What do you think, @liangyepianzhou , @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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243145903
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
@labuladong Can you elaborate a bit more on how should the broker be changed?
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243340329
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
@labuladong Right, sounds like the problem ๐๐ป Plus as suspected, `closeAsync()` method is not so "async" after all. Will do after work, in a few hours.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#issuecomment-1618385016
/pulsarbot rerun-failure-checks
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#issuecomment-1619214026
Sorry, I messed up version control by merging from remote, not upstream. Drafted until fixed.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243576957
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
Whereas with this PR, when users calls graceful shutdown and the process exits/or returns succesfully, they "know" that the shutdown is properly returns.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#issuecomment-1619154207
/pulsarbot rerun-failure-checks
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#issuecomment-1617112801
> From what I understand, you want to add a flag to control whether to wait for the broker shutdown to complete. However, I only see that you have explicitly overridden the existing asynchronous methods. Can you please help me clarify this?
@liangyepianzhou Thank you for pointing out ๐๐ผ The description is really outdated at the moment.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] 315157973 commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "315157973 (via GitHub)" <gi...@apache.org>.
315157973 commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243567246
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
Why not add a param in CLI to switch between sync and async
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "liangyepianzhou (via GitHub)" <gi...@apache.org>.
liangyepianzhou commented on PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#issuecomment-1617105864
>Add CLI option to "shutdown" command to configure if caller should wait for broker response or not
From what I understand, you want to add a flag to control whether to wait for the broker shutdown to complete. However, I only see that you have explicitly overridden the existing asynchronous methods. Can you please help me clarify this?
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim closed pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim closed pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
URL: https://github.com/apache/pulsar/pull/20651
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou closed pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "liangyepianzhou (via GitHub)" <gi...@apache.org>.
liangyepianzhou closed pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
URL: https://github.com/apache/pulsar/pull/20651
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1250068304
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java:
##########
@@ -157,9 +157,6 @@ public void testShutDownWithMaxConcurrentUnload() throws Exception {
assertEquals(list.size(), 1);
admin.brokers().shutDownBrokerGracefully(1, false);
//We can only unload one bundle per second, so it takes at least 2 seconds.
- Awaitility.await().atLeast(bundleNum - 1, TimeUnit.SECONDS).untilAsserted(() -> {
Review Comment:
> Why delete this?
Because by this PR's changes, by the time `admin.brokers().shutDownBrokerGracefully(1, false);` in line 158 returns, closeAsync is already running and `pulsar.getBrokerService()` will return `null` in most cases.
> And the notes should be deleted too?
True
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] coderzc commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1250103544
##########
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:
Why not respond after close?
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] labuladong commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "labuladong (via GitHub)" <gi...@apache.org>.
labuladong commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243144380
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
It seems the broker side doesn't respond to this request. I think the broker side should be changed too?
<img width="1022" alt="image" src="https://github.com/apache/pulsar/assets/37220920/7f8e6c05-e4cd-4934-8d93-a9b4a0507a64">
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243340595
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
Thanks again, for the follow up!
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "liangyepianzhou (via GitHub)" <gi...@apache.org>.
liangyepianzhou commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1250105698
##########
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:
I have the same question. Why do not add the flag to control it?
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "liangyepianzhou (via GitHub)" <gi...@apache.org>.
liangyepianzhou commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1250525320
##########
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:
Look good to me.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#issuecomment-1619228329
Moving to https://github.com/apache/pulsar/pull/20709
My apologies ๐๐ผ๐๐ผ Due to messed up merge status, I will close this one and open PR #20709 instead, for clean merge state.
Thanks in advance, @liangyepianzhou, @labuladong @coderzc @315157973
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] call POST `/brokers/shutdown` synchronously from `Brokers` API
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1242365623
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java:
##########
@@ -157,9 +157,6 @@ public void testShutDownWithMaxConcurrentUnload() throws Exception {
assertEquals(list.size(), 1);
admin.brokers().shutDownBrokerGracefully(1, false);
//We can only unload one bundle per second, so it takes at least 2 seconds.
- Awaitility.await().atLeast(bundleNum - 1, TimeUnit.SECONDS).untilAsserted(() -> {
- assertEquals(pulsar.getBrokerService().getTopics().size(), 0);
- });
Review Comment:
At this point `pulsar.getBrokerService()` returns null (As tested by line 160~162, broker is already closed when line 158 returns)
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243454061
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
@labuladong WDYT?
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243574638
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
@315157973 I am concern that such configuration to allow async invocation will have less control of "how" the graceful shutdown work.
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
@315157973 I am concerned that such configuration to allow async invocation will have less control of "how" the graceful shutdown work.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] labuladong commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "labuladong (via GitHub)" <gi...@apache.org>.
labuladong commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243156941
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
I mean the broker doesn't handle the shutdown request properly now. For example, you can try this command to the local standalone pulsar:
```bash
curl -X POST localhost:8080/admin/v2/brokers/shutdown
```
The expected behavior is the post request finished successfully, but the actual behavior is the post request stucks and gets a timeout error.
I think broker side may need to add a `@Suspended AsyncResponse asyncResponse` and use `asyncResponse.resume` to give client a response, like other async APIs.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1242365623
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java:
##########
@@ -157,9 +157,6 @@ public void testShutDownWithMaxConcurrentUnload() throws Exception {
assertEquals(list.size(), 1);
admin.brokers().shutDownBrokerGracefully(1, false);
//We can only unload one bundle per second, so it takes at least 2 seconds.
- Awaitility.await().atLeast(bundleNum - 1, TimeUnit.SECONDS).untilAsserted(() -> {
- assertEquals(pulsar.getBrokerService().getTopics().size(), 0);
- });
Review Comment:
At this point `pulsar.getBrokerService()` returns null (As tested by line 160~162, broker is already closed when line 158 returns)
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
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 functionality 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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "liangyepianzhou (via GitHub)" <gi...@apache.org>.
liangyepianzhou commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1250023852
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java:
##########
@@ -157,9 +157,6 @@ public void testShutDownWithMaxConcurrentUnload() throws Exception {
assertEquals(list.size(), 1);
admin.brokers().shutDownBrokerGracefully(1, false);
//We can only unload one bundle per second, so it takes at least 2 seconds.
- Awaitility.await().atLeast(bundleNum - 1, TimeUnit.SECONDS).untilAsserted(() -> {
Review Comment:
Why delete this?
And the notes should be deleted too?
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1250116275
##########
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:
In short, I think the issue #20617 should be resolved by modifying the sychronize mechanism. And not by adding a flag and let users to use it.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243576957
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
Whereas with this PR, when users calls graceful shutdown and the process exits/or returns succesfully, they "know" that the shutdown is actually invoked.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #20651: [improve][admin] Gracefully shutdown does not work with admin cli in standalone
Posted by "JooHyukKim (via GitHub)" <gi...@apache.org>.
JooHyukKim commented on code in PR #20651:
URL: https://github.com/apache/pulsar/pull/20651#discussion_r1243584128
##########
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java:
##########
@@ -215,7 +215,13 @@ public CompletableFuture<Void> shutDownBrokerGracefully(int maxConcurrentUnloadP
WebTarget path = adminBrokers.path("shutdown")
.queryParam("maxConcurrentUnloadPerSec", maxConcurrentUnloadPerSec)
.queryParam("forcedTerminateTopic", forcedTerminateTopic);
- return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ try {
+ sync(() -> asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON)));
Review Comment:
> Why not add a param in CLI to switch between sync and async
@315157973 Looking back, your suggestion seems reasonable since we are keeping the original behavior. I will try implementing.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org