/** * Registers {@link com.codahale.metrics.servlets.ThreadDumpServlet} with the application. This provides * an endpoint to capture JVM thread dump * * @return */ @Bean public ServletRegistrationBean threadDumpServletRegistrationBean() { ThreadDumpServlet threadDumpServlet = new ThreadDumpServlet(); ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(threadDumpServlet, monitoringServletsPath + "/threads"); LOGGER.info("Codahale ThreadDumpServlet registered"); return servletRegistrationBean; }
/** * Start the web server including setup. * @throws Exception */ public void start() throws Exception { if (embeddedJetty == null) { return; } final ServerConnector serverConnector; if (config.getBoolean(ExecConstants.HTTP_ENABLE_SSL)) { serverConnector = createHttpsConnector(); } else { serverConnector = createHttpConnector(); } embeddedJetty.addConnector(serverConnector); // Add resources final ErrorHandler errorHandler = new ErrorHandler(); errorHandler.setShowStacks(true); errorHandler.setShowMessageInTitle(true); final ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); servletContextHandler.setErrorHandler(errorHandler); servletContextHandler.setContextPath("/"); embeddedJetty.setHandler(servletContextHandler); final ServletHolder servletHolder = new ServletHolder(new ServletContainer(new DrillRestServer(workManager))); servletHolder.setInitOrder(1); servletContextHandler.addServlet(servletHolder, "/*"); servletContextHandler.addServlet( new ServletHolder(new MetricsServlet(metrics)), "/status/metrics"); servletContextHandler.addServlet(new ServletHolder(new ThreadDumpServlet()), "/status/threads"); final ServletHolder staticHolder = new ServletHolder("static", DefaultServlet.class); staticHolder.setInitParameter("resourceBase", Resource.newClassPathResource("/rest/static").toString()); staticHolder.setInitParameter("dirAllowed","false"); staticHolder.setInitParameter("pathInfoOnly","true"); servletContextHandler.addServlet(staticHolder,"/static/*"); embeddedJetty.start(); }
private void registerMetricsServlets(final ServletContextHandler context) { context.addEventListener(new ExampleHealthCheckServletContextListener()); context.addEventListener(new ExampleMetricsServletContextListener()); context.addServlet(AdminServlet.class, "/admin"); context.addServlet(HealthCheckServlet.class, "/admin/healthcheck"); context.addServlet(MetricsServlet.class, "/admin/metrics"); context.addServlet(PingServlet.class, "/admin/ping"); context.addServlet(ThreadDumpServlet.class, "/admin/threads"); }