@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)); }
@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); }
@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"); } }
private byte[] threadDumpContent() { ByteArrayOutputStream contents = new ByteArrayOutputStream(); threadDump.dump(contents); return contents.toByteArray(); } }
/** * 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); }; } }
@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(); } } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/thread-dump") public String threadDump() { ByteArrayOutputStream out = new ByteArrayOutputStream(); threadDump.dump(out); return new String(out.toByteArray()); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/thread-dump") public String threadDump() { ByteArrayOutputStream out = new ByteArrayOutputStream(); threadDump.dump(out); return new String(out.toByteArray()); } }
/** * 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()); }
@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); }
@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)); }
@GET @Timed @ApiOperation(value = "Get a thread dump") @Path("/threaddump") @Produces(TEXT_PLAIN) public String 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 new String(output.toByteArray(), StandardCharsets.UTF_8); }
public Outcome threadDump() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ThreadDump( ManagementFactory.getThreadMXBean() ).dump( baos ); return outcomes().ok( baos.toByteArray() ).asTextPlain().build(); }
@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); }
/** * {@inheritDoc} */ public void generateResponse(StaplerRequest req, StaplerResponse resp, Object node) throws IOException, ServletException { resp.setStatus(HttpServletResponse.SC_OK); resp.setHeader(CACHE_CONTROL, NO_CACHE); resp.setContentType(PLAIN_TEXT_CONTENT_TYPE); final OutputStream output = resp.getOutputStream(); try { threadDump.dump(output); } finally { output.close(); } } }
@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"); } }