diff --git a/common/src/main/java/ctbrec/io/HttpClient.java b/common/src/main/java/ctbrec/io/HttpClient.java index e90a6b79..200983dd 100644 --- a/common/src/main/java/ctbrec/io/HttpClient.java +++ b/common/src/main/java/ctbrec/io/HttpClient.java @@ -37,6 +37,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; @Slf4j public abstract class HttpClient { + @Getter private static final ConnectionPool GLOBAL_HTTP_CONN_POOL = new ConnectionPool(10, 2, TimeUnit.MINUTES); @Getter diff --git a/server/src/main/java/ctbrec/recorder/server/DebugServlet.java b/server/src/main/java/ctbrec/recorder/server/DebugServlet.java index dfe776ee..97eef9de 100644 --- a/server/src/main/java/ctbrec/recorder/server/DebugServlet.java +++ b/server/src/main/java/ctbrec/recorder/server/DebugServlet.java @@ -1,6 +1,7 @@ package ctbrec.recorder.server; import ctbrec.Config; +import ctbrec.io.HttpClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.json.JSONObject; @@ -24,6 +25,7 @@ public class DebugServlet extends AbstractCtbrecServlet { public static final String BASE_URL = "/debug"; private static final Pattern URL_PATTERN_DEBUG_STACK = Pattern.compile(BASE_URL + "/stack(/.*?)"); + private static final Pattern URL_PATTERN_DEBUG_STATS = Pattern.compile(BASE_URL + "/stats"); public DebugServlet() {} @@ -57,9 +59,18 @@ public class DebugServlet extends AbstractCtbrecServlet { } }); - log.debug("Stacks Request {} - {}", threadUrl, stacks); + log.debug("Stacks Request {}", threadUrl); resp.setContentType("text/plain"); sendResponse(resp, SC_OK, box.text); + } else if ((m = URL_PATTERN_DEBUG_STATS.matcher(requestURI)).matches()) { + String text = ""; + text += String.format("GLOBAL_HTTP_CONN_POOL: connectionCount=%d, idleConnectionCount=%d\n", + HttpClient.getGLOBAL_HTTP_CONN_POOL().connectionCount(), + HttpClient.getGLOBAL_HTTP_CONN_POOL().idleConnectionCount()); + + log.debug("Stats Request"); + resp.setContentType("text/plain"); + sendResponse(resp, SC_OK, text); } else sendResponse(resp, SC_NOT_FOUND, ""); } catch (Exception e) {