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 2021/06/18 20:50:20 UTC

[GitHub] [pulsar] cckellogg commented on a change in pull request #10962: [WIP] Add v2 health admin endpoint

cckellogg commented on a change in pull request #10962:
URL: https://github.com/apache/pulsar/pull/10962#discussion_r654031958



##########
File path: pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/Brokers.java
##########
@@ -268,12 +268,12 @@
      *
      * @throws PulsarAdminException if the healthcheck fails.
      */
-    void healthcheck() throws PulsarAdminException;
+    void healthcheck(String topicVersion) throws PulsarAdminException;

Review comment:
       Maybe keep these old methods `healthcheck() and healthcheckAsync()` and add deprecated annotations? Then add the new ones.  Keeps the api compatibility. 

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -290,21 +295,34 @@ public void isReady(@Suspended AsyncResponse asyncResponse) {
         }
     }
 
-    @GET
-    @Path("/health")
-    @ApiOperation(value = "Run a healthcheck against the broker")
-    @ApiResponses(value = {
-        @ApiResponse(code = 200, message = "Everything is OK"),
-        @ApiResponse(code = 403, message = "Don't have admin permission"),
-        @ApiResponse(code = 404, message = "Cluster doesn't exist"),
-        @ApiResponse(code = 500, message = "Internal server error")})
-    public void healthcheck(@Suspended AsyncResponse asyncResponse) throws Exception {
-        validateSuperUserAccess();
-        String heartbeatNamespace = NamespaceService.getHeartbeatNamespace(
-                pulsar().getAdvertisedAddress(), pulsar().getConfiguration());
-        String topic = String.format("persistent://%s/healthcheck", heartbeatNamespace);
+    protected void healthCheck(final AsyncResponse asyncResponse,
+                               final TopicVersion topicVersion) throws PulsarServerException {
+
+        String topic;
+        PulsarClient client;
+        try {
+            validateSuperUserAccess();
+            String heartbeatNamespace;
+
+            heartbeatNamespace = (topicVersion == TopicVersion.V1)

Review comment:
       I would make the check against v2 so the default is always the v1 format.

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -290,21 +295,34 @@ public void isReady(@Suspended AsyncResponse asyncResponse) {
         }
     }
 
-    @GET
-    @Path("/health")
-    @ApiOperation(value = "Run a healthcheck against the broker")
-    @ApiResponses(value = {
-        @ApiResponse(code = 200, message = "Everything is OK"),
-        @ApiResponse(code = 403, message = "Don't have admin permission"),
-        @ApiResponse(code = 404, message = "Cluster doesn't exist"),
-        @ApiResponse(code = 500, message = "Internal server error")})
-    public void healthcheck(@Suspended AsyncResponse asyncResponse) throws Exception {
-        validateSuperUserAccess();
-        String heartbeatNamespace = NamespaceService.getHeartbeatNamespace(
-                pulsar().getAdvertisedAddress(), pulsar().getConfiguration());
-        String topic = String.format("persistent://%s/healthcheck", heartbeatNamespace);
+    protected void healthCheck(final AsyncResponse asyncResponse,
+                               final TopicVersion topicVersion) throws PulsarServerException {
+
+        String topic;
+        PulsarClient client;
+        try {
+            validateSuperUserAccess();
+            String heartbeatNamespace;
+
+            heartbeatNamespace = (topicVersion == TopicVersion.V1)
+                    ?
+                    NamespaceService.getHeartbeatNamespace(
+                            pulsar().getAdvertisedAddress(),
+                            pulsar().getConfiguration())
+                    :
+                    NamespaceService.getHeartbeatNamespaceV2(
+                            pulsar().getAdvertisedAddress(),
+                            pulsar().getConfiguration());
+
+            topic = String.format("persistent://%s/healthcheck", heartbeatNamespace);
+
+            LOG.info("Doing healthCheck for {}", topic);

Review comment:
       `Running healthcheck topic={}`




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org