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:51:35 UTC
[GitHub] [pulsar] aahmed-se commented on a change in pull request #10962: [WIP] Add v2 health admin endpoint
aahmed-se commented on a change in pull request #10962:
URL: https://github.com/apache/pulsar/pull/10962#discussion_r653924762
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -290,19 +292,19 @@ 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 {
+ private void healthCheck(AsyncResponse asyncResponse,
+ TopicVersion topicVersion) throws PulsarServerException {
+
validateSuperUserAccess();
- String heartbeatNamespace = NamespaceService.getHeartbeatNamespace(
+ String topic;
+
+ if (topicVersion == TopicVersion.V1) {
+ String heartbeatNamespace = NamespaceService.getHeartbeatNamespace(
pulsar().getAdvertisedAddress(), pulsar().getConfiguration());
- String topic = String.format("persistent://%s/healthcheck", heartbeatNamespace);
+ topic = String.format("persistent://%s/healthcheck", heartbeatNamespace);
+ } else {
+ topic = ""; // TODO
Review comment:
Still have to implement it, looking to see what's the simplest way to do it.
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -371,6 +373,31 @@ public void healthcheck(@Suspended AsyncResponse asyncResponse) throws Exception
asyncResponse.resume("ok");
}
});
+
+ }
+
+ @GET
+ @Path("/healthv2")
Review comment:
done
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -371,6 +373,19 @@ public void healthcheck(@Suspended AsyncResponse asyncResponse) throws Exception
asyncResponse.resume("ok");
}
});
+
+ }
+
+ @GET
+ @Path("/health")
Review comment:
that was there originally don't want to change the default behavior.
##########
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:
sure will keep them as deprecated
##########
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:
done
##########
File path: pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java
##########
@@ -366,8 +368,31 @@ public void healthcheck() throws PulsarAdminException {
}
@Override
+ @Deprecated
public CompletableFuture<Void> healthcheckAsync() {
+ return healthcheckAsync("V1");
+ }
+
+ @Override
+ public void healthcheck(String topicVersion) throws PulsarAdminException {
Review comment:
sure where would be put the TopicVersion class that client, broker and tools package can share it.
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -290,21 +295,30 @@ 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 = null;
+ PulsarClient client = null;
+ try {
+ validateSuperUserAccess();
+
+ if (topicVersion == TopicVersion.V1) {
+ String heartbeatNamespace = NamespaceService.getHeartbeatNamespace(
+ pulsar().getAdvertisedAddress(), pulsar().getConfiguration());
+ topic = String.format("persistent://%s/healthcheck", heartbeatNamespace);
+ } else {
+ LOG.info("Using healthCheck with V2 topic name");
Review comment:
done
##########
File path: pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java
##########
@@ -352,9 +353,10 @@ public void failed(Throwable throwable) {
}
@Override
+ @Deprecated
public void healthcheck() throws PulsarAdminException {
try {
- healthcheckAsync().get(this.readTimeoutMs, TimeUnit.MILLISECONDS);
+ healthcheckAsync("V1").get(this.readTimeoutMs, TimeUnit.MILLISECONDS);
Review comment:
done
##########
File path: pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java
##########
@@ -366,8 +368,31 @@ public void healthcheck() throws PulsarAdminException {
}
@Override
+ @Deprecated
public CompletableFuture<Void> healthcheckAsync() {
+ return healthcheckAsync("V1");
Review comment:
done
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -373,6 +387,26 @@ public void healthcheck(@Suspended AsyncResponse asyncResponse) throws Exception
});
}
+ @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")})
+ @ApiParam(value = "Topic Version")
+ public void healthcheck(@Suspended AsyncResponse asyncResponse,
+ @QueryParam("topicversion") TopicVersion topicVersion) throws Exception {
+ if (Objects.isNull(topicVersion) || topicVersion == TopicVersion.V1) {
Review comment:
done
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -373,6 +391,26 @@ public void healthcheck(@Suspended AsyncResponse asyncResponse) throws Exception
});
}
+ @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")})
+ @ApiParam(value = "Topic Version")
+ public void healthcheck(@Suspended AsyncResponse asyncResponse,
+ @QueryParam("topicversion") TopicVersion topicVersion) throws Exception {
+ if (Objects.isNull(topicVersion) || topicVersion == TopicVersion.V1) {
+ healthCheck(asyncResponse, TopicVersion.V1);
+ } else if (topicVersion == TopicVersion.V2) {
Review comment:
it doesn't handle null , this method is needed to handle that.
##########
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:
No reason can change to using the operator.
##########
File path: pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java
##########
@@ -366,8 +380,11 @@ public void healthcheck() throws PulsarAdminException {
}
@Override
- public CompletableFuture<Void> healthcheckAsync() {
+ public CompletableFuture<Void> healthcheckAsync(TopicVersion topicVersion) {
WebTarget path = adminBrokers.path("health");
+ if (Objects.nonNull(topicVersion)) {
Review comment:
No reason can change to using the operator.
##########
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:
Will chang it
##########
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:
Ok
##########
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:
Will change it
##########
File path: pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BrokersImpl.java
##########
@@ -366,8 +380,11 @@ public void healthcheck() throws PulsarAdminException {
}
@Override
- public CompletableFuture<Void> healthcheckAsync() {
+ public CompletableFuture<Void> healthcheckAsync(TopicVersion topicVersion) {
WebTarget path = adminBrokers.path("health");
+ if (Objects.nonNull(topicVersion)) {
Review comment:
done
##########
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:
done
##########
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:
done
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -373,6 +391,26 @@ public void healthcheck(@Suspended AsyncResponse asyncResponse) throws Exception
});
}
+ @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")})
+ @ApiParam(value = "Topic Version")
+ public void healthcheck(@Suspended AsyncResponse asyncResponse,
+ @QueryParam("topicversion") TopicVersion topicVersion) throws Exception {
+ if (Objects.isNull(topicVersion) || topicVersion == TopicVersion.V1) {
+ healthCheck(asyncResponse, TopicVersion.V1);
+ } else if (topicVersion == TopicVersion.V2) {
Review comment:
ok
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -373,6 +391,26 @@ public void healthcheck(@Suspended AsyncResponse asyncResponse) throws Exception
});
}
+ @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")})
+ @ApiParam(value = "Topic Version")
+ public void healthcheck(@Suspended AsyncResponse asyncResponse,
+ @QueryParam("topicversion") TopicVersion topicVersion) throws Exception {
+ if (Objects.isNull(topicVersion) || topicVersion == TopicVersion.V1) {
+ healthCheck(asyncResponse, TopicVersion.V1);
+ } else if (topicVersion == TopicVersion.V2) {
Review comment:
changed 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org