scwhittle commented on code in PR #30211:
URL: https://github.com/apache/beam/pull/30211#discussion_r1481335479
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/status/ChannelzServlet.java:
##########
@@ -0,0 +1,245 @@
+package org.apache.beam.runners.dataflow.worker.status;
+
+import org.apache.beam.vendor.grpc.v1p60p1.io.grpc.channelz.v1.*;
+import
org.apache.beam.vendor.grpc.v1p60p1.io.grpc.protobuf.services.ChannelzService;
+import org.apache.beam.vendor.grpc.v1p60p1.io.grpc.stub.StreamObserver;
+import
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.SettableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/** Respond to /channelz with the GRPC channelz data. */
+@SuppressWarnings({
+ "nullness" // TODO(https://github.com/apache/beam/issues/20497)
+})
+public class ChannelzServlet extends BaseStatusServlet implements
DebugCapture.Capturable {
+ private static final String PATH = "/channelz";
+ private static final Logger LOG =
LoggerFactory.getLogger(ChannelzServlet.class);
+ private static final int MAX_TOP_CHANNELS_TO_RETURN = 100;
+
+ private final ChannelzService channelzService =
ChannelzService.newInstance(MAX_TOP_CHANNELS_TO_RETURN);
+
+ public ChannelzServlet() {
+ super(PATH);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException {
+ response.setStatus(HttpServletResponse.SC_OK);
+ PrintWriter writer = response.getWriter();
+ captureData(writer);
+ }
+
+ @Override
+ public String pageName() {
+ return PATH;
+ }
+
+ @Override
+ public void captureData(PrintWriter writer) {
+ writer.println("<html>");
+ writer.println("<h1>Channelz</h1>");
+ appendTopChannels(writer);
+ writer.println("</html>");
+ }
+
+ // channelz proto says there may not be cycles in the ref graph
+ // we track visited ids to prevent any accidental cycles,
+ static class VisitedSets {
+ Set<Long> channels = new HashSet<>();
+ Set<Long> subchannels = new HashSet<>();
+ }
+
+ private void appendTopChannels(PrintWriter writer) {
+ SettableFuture<GetTopChannelsResponse> future =
SettableFuture.create();
+ channelzService.getTopChannels(
+ GetTopChannelsRequest.newBuilder()
Review Comment:
I think in that case we could choose to display ipv6 addresses or ipv4
addresses matching some regexp.
You could also just punt on that for now and just match the streaming
endpoint. We can figure out what targets appear like in direct path mode once
it's running.
--
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]