@GET @Path("/threaddump") @Produces(MediaType.TEXT_PLAIN) @Timed @ApiOperation(value = "Get a thread dump as plain text") public StreamingOutput threadDumpAsText() { checkPermission(RestPermissions.THREADS_DUMP, serverStatus.getNodeId().toString()); return output -> new ThreadDump(ManagementFactory.getThreadMXBean()).dump(output); }
@Override public void handle(final Request req, final Response rsp) throws Throwable { Object data; Status status; if (threadDump == null) { data = "Sorry your runtime environment does not allow to dump threads."; status = Status.NOT_IMPLEMENTED; } else { final ByteArrayOutputStream output = new ByteArrayOutputStream(); threadDump.dump(output); data = output.toByteArray(); status = Status.OK; } rsp.type(MediaType.plain) .status(status) .header("Cache-Control", "must-revalidate,no-cache,no-store") .send(data); }
public ThreadDumpHandler() { try { // some PaaS like Google App Engine blacklist "java.lang.management" package threadDump = new ThreadDump(ManagementFactory.getThreadMXBean()); } catch (NoClassDefFoundError e) { log.warn("Thread dump isn't available", e); } }
@Override public void handle(RouteContext routeContext) { Response response = routeContext.getResponse().noCache().text(); if (threadDump != null) { threadDump.dump(response.getOutputStream()); } else { response.internalError().send("Sorry your runtime environment does not allow to dump threads"); } }
/** * Constructs an instance. */ public ThreadsHandler() { this.threadDump = new ThreadDump(getThreadMXBean()); }
@GET @Timed @ApiOperation(value = "Get a thread dump") @Path("/threaddump") public SystemThreadDumpResponse threaddump() { checkPermission(RestPermissions.THREADS_DUMP, serverStatus.getNodeId().toString()); // The ThreadDump is built by internal codahale.metrics servlet library we are abusing. final ThreadDump threadDump = new ThreadDump(ManagementFactory.getThreadMXBean()); final ByteArrayOutputStream output = new ByteArrayOutputStream(); threadDump.dump(output); return SystemThreadDumpResponse.create(new String(output.toByteArray(), StandardCharsets.UTF_8)); }
private byte[] threadDumpContent() { ByteArrayOutputStream contents = new ByteArrayOutputStream(); threadDump.dump(contents); return contents.toByteArray(); } }
@Override public void init() throws ServletException { this.threadDump = new ThreadDump(ManagementFactory.getThreadMXBean()); }
/** * Immediately exits the process with the ordinal value of the provided {@link ProcessExit}. */ @SuppressWarnings("DM_EXIT") public static void exit(Code code) { String message = String.format( "Process exiting immediately with code: %s[%d]", code, code.getValue()); System.err.println(message); System.out.println(message); // SUPPRESS CHECKSTYLE RegexpSinglelineJava System.err.println("Printing final thread state..."); new ThreadDump(ManagementFactory.getThreadMXBean()).dump(System.err); System.exit(code.getValue()); }
/** * Renders the current threads and thread state of the scheduler. */ @GET @Produces(MediaType.TEXT_PLAIN) @Path("threads") public StreamingOutput getThreads() { return output -> { threadDump.dump(output); }; } }
public ThreadDumpHandler() { try { // some PaaS like Google App Engine blacklist "java.lang.management" package threadDump = new ThreadDump(ManagementFactory.getThreadMXBean()); } catch (NoClassDefFoundError e) { log.warn("Thread dump isn't available", e); } }
public Outcome threadDump() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ThreadDump( ManagementFactory.getThreadMXBean() ).dump( baos ); return outcomes().ok( baos.toByteArray() ).asTextPlain().build(); }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType(CONTENT_TYPE); resp.setHeader("Cache-Control", "must-revalidate,no-cache,no-store"); final OutputStream output = resp.getOutputStream(); try { threadDump.dump(output); } finally { output.close(); } } }
/** * Web binding for {@literal /threads} * * @return the response */ @Restricted(NoExternalUse.class) // only for use by stapler web binding public HttpResponse doThreads() { return new ThreadDumpResponse(new ThreadDump(ManagementFactory.getThreadMXBean())); }
@GET @Path("/threaddump") @Produces(MediaType.TEXT_PLAIN) @Timed @ApiOperation(value = "Get a thread dump as plain text") public StreamingOutput threadDumpAsText() { checkPermission(RestPermissions.THREADS_DUMP, serverStatus.getNodeId().toString()); return output -> new ThreadDump(ManagementFactory.getThreadMXBean()).dump(output); }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/thread-dump") public String threadDump() { ByteArrayOutputStream out = new ByteArrayOutputStream(); threadDump.dump(out); return new String(out.toByteArray()); } }
public MetricsResource(restx.common.metrics.api.MetricRegistry metricRegistry, restx.common.metrics.api.health.HealthCheckRegistry healthCheckRegistry) { if (!(metricRegistry instanceof CodahaleMetricRegistry)){ throw new IllegalStateException("restx-monitor-admin expects that module restx-monitor-codahale is loaded"); } CodahaleMetricRegistry codahaleMetricRegistry = (CodahaleMetricRegistry) metricRegistry; CodahaleHealthCheckRegistry codahaleHealthCheckRegistry = (CodahaleHealthCheckRegistry) healthCheckRegistry; this.metrics = codahaleMetricRegistry.getCodahaleMetricRegistry(); this.healthChecks = codahaleHealthCheckRegistry.getCodahaleHealthCheckRegistry(); threadDump = new ThreadDump(ManagementFactory.getThreadMXBean()); }
@GET @Timed @ApiOperation(value = "Get a thread dump") @Path("/threaddump") public SystemThreadDumpResponse threaddump() { checkPermission(RestPermissions.THREADS_DUMP, serverStatus.getNodeId().toString()); // The ThreadDump is built by internal codahale.metrics servlet library we are abusing. final ThreadDump threadDump = new ThreadDump(ManagementFactory.getThreadMXBean()); final ByteArrayOutputStream output = new ByteArrayOutputStream(); threadDump.dump(output); return SystemThreadDumpResponse.create(new String(output.toByteArray(), StandardCharsets.UTF_8)); }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/thread-dump") public String threadDump() { ByteArrayOutputStream out = new ByteArrayOutputStream(); threadDump.dump(out); return new String(out.toByteArray()); } }
public MetricsResource(restx.common.metrics.api.MetricRegistry metricRegistry, restx.common.metrics.api.health.HealthCheckRegistry healthCheckRegistry) { if (!(metricRegistry instanceof CodahaleMetricRegistry)){ throw new IllegalStateException("restx-monitor-admin expects that module restx-monitor-codahale is loaded"); } CodahaleMetricRegistry codahaleMetricRegistry = (CodahaleMetricRegistry) metricRegistry; CodahaleHealthCheckRegistry codahaleHealthCheckRegistry = (CodahaleHealthCheckRegistry) healthCheckRegistry; this.metrics = codahaleMetricRegistry.getCodahaleMetricRegistry(); this.healthChecks = codahaleHealthCheckRegistry.getCodahaleHealthCheckRegistry(); threadDump = new ThreadDump(ManagementFactory.getThreadMXBean()); }