Grabs a snapshot of all JVM thread states and formats it in a manner to be displayed via API. @param query The query to respond to
(final HttpQuery query)
| 182 | * @param query The query to respond to |
| 183 | */ |
| 184 | private void printThreadStats(final HttpQuery query) { |
| 185 | final Set<Thread> threads = Thread.getAllStackTraces().keySet(); |
| 186 | final List<Map<String, Object>> output = |
| 187 | new ArrayList<Map<String, Object>>(threads.size()); |
| 188 | for (final Thread thread : threads) { |
| 189 | final Map<String, Object> status = new HashMap<String, Object>(); |
| 190 | status.put("threadID", thread.getId()); |
| 191 | status.put("name", thread.getName()); |
| 192 | status.put("state", thread.getState().toString()); |
| 193 | status.put("interrupted", thread.isInterrupted()); |
| 194 | status.put("priority", thread.getPriority()); |
| 195 | |
| 196 | final List<String> stack = |
| 197 | new ArrayList<String>(thread.getStackTrace().length); |
| 198 | for (final StackTraceElement element: thread.getStackTrace()) { |
| 199 | stack.add(element.toString()); |
| 200 | } |
| 201 | status.put("stack", stack); |
| 202 | output.add(status); |
| 203 | } |
| 204 | query.sendReply(query.serializer().formatThreadStatsV1(output)); |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Yield (chiefly memory-related) stats about this OpenTSDB instance's JVM. |
no test coverage detected