You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/03/17 02:08:57 UTC
[GitHub] [pulsar] wangjialing218 commented on a change in pull request #14702: [PulsarAdmin] add get active brokers api without cluster name
wangjialing218 commented on a change in pull request #14702:
URL: https://github.com/apache/pulsar/pull/14702#discussion_r828668102
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -104,6 +104,30 @@ public void getActiveBrokers(@Suspended final AsyncResponse asyncResponse,
});
}
+ @GET
+ @Path("/")
+ @ApiOperation(
+ value = "Get the list of active brokers (web service addresses) in the local cluster."
+ + "If authorization is not enabled",
+ response = String.class,
+ responseContainer = "Set")
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = 401, message = "Authentication required"),
+ @ApiResponse(code = 403, message = "This operation requires super-user access") })
+ public void getActiveBrokers(@Suspended final AsyncResponse asyncResponse) throws Exception {
+ validateSuperUserAccessAsync()
+ .thenCompose(__ -> pulsar().getLoadManager().get().getAvailableBrokersAsync())
+ .thenAccept(activeBrokers -> {
+ LOG.info("[{}] Successfully to get active brokers", clientAppId());
+ asyncResponse.resume(activeBrokers);
+ }).exceptionally(ex -> {
+ LOG.error("[{}] Fail to get active brokers", clientAppId(), ex);
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
+ return null;
+ });
Review comment:
Good suggestion, I removed duplicated code
--
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