Technoboy- commented on a change in pull request #14702:
URL: https://github.com/apache/pulsar/pull/14702#discussion_r829642912
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -89,7 +89,8 @@
public void getActiveBrokers(@Suspended final AsyncResponse asyncResponse,
@PathParam("cluster") String cluster) {
validateSuperUserAccessAsync()
- .thenCompose(__ -> validateClusterOwnershipAsync(cluster))
+ .thenCompose(__ -> cluster == null ?
CompletableFuture.completedFuture(null)
+ : validateClusterOwnershipAsync(cluster))
Review comment:
No need to modify this line.
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -104,6 +105,21 @@ 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 {
+ getActiveBrokers(asyncResponse, null);
+ }
+
Review comment:
Why add this endpoint ?
##########
File path:
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java
##########
@@ -42,14 +42,24 @@ public BrokersImpl(WebTarget web, Authentication auth, long
readTimeoutMs) {
adminBrokers = web.path("admin/v2/brokers");
}
+ @Override
+ public List<String> getActiveBrokers() throws PulsarAdminException {
+ return sync(() -> getActiveBrokersAsync(null));
+ }
+
+ @Override
+ public CompletableFuture<List<String>> getActiveBrokersAsync() {
+ return getActiveBrokersAsync(null);
+ }
+
@Override
public List<String> getActiveBrokers(String cluster) throws
PulsarAdminException {
return sync(() -> getActiveBrokersAsync(cluster));
}
@Override
public CompletableFuture<List<String>> getActiveBrokersAsync(String
cluster) {
- WebTarget path = adminBrokers.path(cluster);
+ WebTarget path = cluster == null ? adminBrokers :
adminBrokers.path(cluster);
Review comment:
Seems no need to modify
##########
File path:
pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/Brokers.java
##########
@@ -32,6 +32,41 @@
* Admin interface for brokers management.
*/
public interface Brokers {
+ /**
+ * Get the list of active brokers in the local cluster.
+ * <p/>
+ * Get the list of active brokers (web service addresses) in the local
cluster.
+ * <p/>
+ * Response Example:
+ *
+ * <pre>
+ * <code>["prod1-broker1.messaging.use.example.com:8080",
"prod1-broker2.messaging.use.example.com:8080"
+ * * * "prod1-broker3.messaging.use.example.com:8080"]</code>
+ * </pre>
+ *
+ * @return a list of (host:port)
+ * @throws NotAuthorizedException
+ * You don't have admin permission to get the list of active
brokers in the cluster
+ * @throws PulsarAdminException
+ * Unexpected error
+ */
+ List<String> getActiveBrokers() throws PulsarAdminException;
Review comment:
Yes right. But seems no need to modify other part.
--
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]