@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { boolean download = Boolean.parseBoolean(req.getParameter("download")); if (download) { resp.addHeader(CONTENT_DISPOSITION, "attachment; filename='threads.txt'"); } super.doGet(req, resp); } }
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { final String uri = req.getPathInfo(); if (uri == null || uri.equals("/")) { super.service(req, resp); } else if (uri.equals(healthcheckUri)) { healthCheckServlet.service(req, resp); } else if (uri.startsWith(metricsUri)) { metricsServlet.service(req, resp); } else if (uri.equals(pingUri)) { pingServlet.service(req, resp); } else if (uri.equals(threadsUri)) { threadDumpServlet.service(req, resp); } else { resp.sendError(HttpServletResponse.SC_NOT_FOUND); } }
@Activate protected void activate() throws NamespaceException, ServletException { httpService.registerServlet(METRICS_URI, new MetricsServlet(metricRegistry), null, null); httpService.registerServlet(HEALTH_URI, new HealthCheckServlet(healthCheckRegistry), null, null); httpService.registerServlet(PING_URI, new PingServlet(), null, null); httpService.registerServlet(THREADS_URI, new ThreadDumpServlet(), null, null); }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); this.healthCheckServlet = new HealthCheckServlet(); healthCheckServlet.init(config); this.metricsServlet = new MetricsServlet(); metricsServlet.init(config); this.pingServlet = new PingServlet(); pingServlet.init(config); this.threadDumpServlet = new ThreadDumpServlet(); threadDumpServlet.init(config); this.metricsUri = getParam(config.getInitParameter("metrics-uri"), DEFAULT_METRICS_URI); this.pingUri = getParam(config.getInitParameter("ping-uri"), DEFAULT_PING_URI); this.threadsUri = getParam(config.getInitParameter("threads-uri"), DEFAULT_THREADS_URI); this.healthcheckUri = getParam(config.getInitParameter("healthcheck-uri"), DEFAULT_HEALTHCHECK_URI); this.serviceName = getParam(config.getInitParameter("service-name"), null); }
serve(SYSTEM_METRICS).with(new MetricsServlet(monitoring.getMetrics())); serve(SYSTEM_PING).with(new PingServlet()); serve(SYSTEM_THREADS).with(new ThreadDumpServlet());
serve(SYSTEM_METRICS).with(new MetricsServlet(monitoring.getMetrics())); serve(SYSTEM_PING).with(new PingServlet()); serve(SYSTEM_THREADS).with(new ThreadDumpServlet());
servletContextHandler.addServlet(new ServletHolder(new ThreadDumpServlet()), STATUS_THREADS_PATH);