1
<%@ page contentType="text/xml; charset=utf-8" pageEncoding="UTF-8" language="java" %>
3
Licensed to the Apache Software Foundation (ASF) under one or more
4
contributor license agreements. See the NOTICE file distributed with
5
this work for additional information regarding copyright ownership.
6
The ASF licenses this file to You under the Apache License, Version 2.0
7
(the "License"); you may not use this file except in compliance with
8
the License. You may obtain a copy of the License at
10
http://www.apache.org/licenses/LICENSE-2.0
12
Unless required by applicable law or agreed to in writing, software
13
distributed under the License is distributed on an "AS IS" BASIS,
14
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
See the License for the specific language governing permissions and
16
limitations under the License.
18
<%@ page import="org.apache.solr.core.SolrCore,
19
java.lang.management.ManagementFactory,
20
java.lang.management.ThreadMXBean,
21
java.lang.management.ThreadInfo,
23
org.apache.solr.common.util.XML"%>
24
<%@include file="_info.jsp" %>
27
<?xml-stylesheet type="text/xsl" href="threaddump.xsl"?>
29
static ThreadMXBean tmbean = ManagementFactory.getThreadMXBean();
32
<core><%= collectionName %></core>
35
<version><%=System.getProperty("java.vm.version")%></version>
36
<name><%=System.getProperty("java.vm.name")%></name>
39
<current><%=tmbean.getThreadCount()%></current>
40
<peak><%=tmbean.getPeakThreadCount()%></peak>
41
<daemon><%=tmbean.getDaemonThreadCount()%></daemon>
46
tids = tmbean.findMonitorDeadlockedThreads();
48
out.println(" <deadlocks>");
49
tinfos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
50
for (ThreadInfo ti : tinfos) {
51
printThreadInfo(ti, out);
53
out.println(" </deadlocks>");
57
tids = tmbean.getAllThreadIds();
58
tinfos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
59
out.println(" <threadDump>");
60
for (ThreadInfo ti : tinfos) {
61
printThreadInfo(ti, out);
63
out.println(" </threadDump>");
69
static void printThreadInfo(ThreadInfo ti, JspWriter out) throws IOException {
70
long tid = ti.getThreadId();
71
out.println(" <thread>");
72
out.println(" <id>" + tid + "</id>");
74
XML.escapeCharData(ti.getThreadName(), out);
75
out.println("</name>");
76
out.println(" <state>" + ti.getThreadState() + "</state>");
77
if (ti.getLockName() != null) {
78
out.println(" <lock>" + ti.getLockName() + "</lock>");
80
if (ti.isSuspended()) {
81
out.println(" <suspended/>");
83
if (ti.isInNative()) {
84
out.println(" <inNative/>");
86
if (tmbean.isThreadCpuTimeSupported()) {
87
out.println(" <cpuTime>" + formatNanos(tmbean.getThreadCpuTime(tid)) + "</cpuTime>");
88
out.println(" <userTime>" + formatNanos(tmbean.getThreadUserTime(tid)) + "</userTime>");
91
if (ti.getLockOwnerName() != null) {
92
out.println(" <owner>");
93
out.println(" <name>" + ti.getLockOwnerName() + "</name>");
94
out.println(" <id>" + ti.getLockOwnerId() + "</id>");
95
out.println(" </owner>");
97
out.println(" <stackTrace>");
98
for (StackTraceElement ste : ti.getStackTrace()) {
100
XML.escapeCharData("at " + ste.toString(), out);
101
out.println(" </line>");
103
out.println(" </stackTrace>");
104
out.println(" </thread>");
107
static String formatNanos(long ns) {
108
return String.format("%.4fms", ns / (double) 1000000);