mchades commented on code in PR #10840:
URL: https://github.com/apache/gravitino/pull/10840#discussion_r3123215403


##########
server/src/main/java/org/apache/gravitino/server/web/rest/HealthOperations.java:
##########
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.server.web.rest;
+
+import com.codahale.metrics.annotation.ResponseMetered;
+import com.codahale.metrics.annotation.Timed;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.servlet.http.HttpServlet;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.gravitino.Entity.EntityType;
+import org.apache.gravitino.EntityStore;
+import org.apache.gravitino.GravitinoEnv;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.dto.HealthCheckDTO;
+import org.apache.gravitino.dto.responses.HealthResponse;
+import org.apache.gravitino.metrics.MetricNames;
+import org.apache.gravitino.server.ServerConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Health check endpoints following MicroProfile Health semantics. Exposes 
separate liveness,
+ * readiness, and aggregate endpoints so Kubernetes probes, load balancers, 
and global traffic
+ * managers can distinguish "restart this pod" from "route traffic elsewhere."
+ *
+ * <ul>
+ *   <li>{@code GET /api/health/live} — liveness, 200 as long as the HTTP 
thread can respond
+ *   <li>{@code GET /api/health/ready} — readiness, 200 when entity store is 
reachable
+ *   <li>{@code GET /api/health} — aggregate, 200 when both pass
+ * </ul>
+ *
+ * All endpoints return 503 with a JSON body describing the failed check(s) 
when unhealthy.
+ */
+@Path("/health")
+@Produces(MediaType.APPLICATION_JSON)
+public class HealthOperations extends HttpServlet {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(HealthOperations.class);
+
+  private static final AtomicInteger PROBE_THREAD_COUNTER = new 
AtomicInteger();
+
+  private static final ExecutorService HEALTH_PROBE_EXECUTOR =
+      new ThreadPoolExecutor(
+          1,
+          4,
+          60L,

Review Comment:
   Could you please add short comments for these parameters? Or use static 
variables.



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

Reply via email to