~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to solr/webapp/web/admin/threaddump.jsp

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<%@ page contentType="text/xml; charset=utf-8" pageEncoding="UTF-8" language="java" %>
2
 
<%--
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
9
 
 
10
 
     http://www.apache.org/licenses/LICENSE-2.0
11
 
 
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.
17
 
--%>
18
 
<%@ page import="org.apache.solr.core.SolrCore,
19
 
                 java.lang.management.ManagementFactory,
20
 
                 java.lang.management.ThreadMXBean,
21
 
                 java.lang.management.ThreadInfo,
22
 
                 java.io.IOException,
23
 
                 org.apache.solr.common.util.XML"%>
24
 
<%@include file="_info.jsp" %>
25
 
 
26
 
 
27
 
<?xml-stylesheet type="text/xsl" href="threaddump.xsl"?>
28
 
<%!
29
 
  static ThreadMXBean tmbean = ManagementFactory.getThreadMXBean();
30
 
%>
31
 
<solr>
32
 
  <core><%= collectionName %></core>
33
 
  <system>
34
 
  <jvm>
35
 
    <version><%=System.getProperty("java.vm.version")%></version>
36
 
    <name><%=System.getProperty("java.vm.name")%></name>
37
 
  </jvm>
38
 
  <threadCount>
39
 
    <current><%=tmbean.getThreadCount()%></current>
40
 
    <peak><%=tmbean.getPeakThreadCount()%></peak>
41
 
    <daemon><%=tmbean.getDaemonThreadCount()%></daemon>
42
 
  </threadCount>
43
 
<%
44
 
  long[] tids;
45
 
  ThreadInfo[] tinfos;
46
 
  tids = tmbean.findMonitorDeadlockedThreads();
47
 
  if (tids != null) {
48
 
      out.println("  <deadlocks>");
49
 
      tinfos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
50
 
      for (ThreadInfo ti : tinfos) {
51
 
          printThreadInfo(ti, out);
52
 
      }
53
 
      out.println("  </deadlocks>");
54
 
  }
55
 
%>
56
 
<%
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);
62
 
  }
63
 
  out.println("  </threadDump>");
64
 
%>
65
 
  </system>
66
 
</solr>
67
 
 
68
 
<%!
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>");
73
 
      out.print("      <name>");
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>");
79
 
      }
80
 
      if (ti.isSuspended()) {
81
 
          out.println("      <suspended/>");
82
 
      }
83
 
      if (ti.isInNative()) {
84
 
          out.println("      <inNative/>");
85
 
      }
86
 
      if (tmbean.isThreadCpuTimeSupported()) {
87
 
          out.println("      <cpuTime>" + formatNanos(tmbean.getThreadCpuTime(tid)) + "</cpuTime>");
88
 
          out.println("      <userTime>" + formatNanos(tmbean.getThreadUserTime(tid)) + "</userTime>");
89
 
      }
90
 
 
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>");
96
 
      }
97
 
      out.println("      <stackTrace>");
98
 
      for (StackTraceElement ste : ti.getStackTrace()) {
99
 
          out.print("        <line>");
100
 
          XML.escapeCharData("at " + ste.toString(), out);
101
 
          out.println("        </line>");
102
 
      }
103
 
      out.println("      </stackTrace>");
104
 
      out.println("    </thread>");
105
 
  }
106
 
 
107
 
  static String formatNanos(long ns) {
108
 
      return String.format("%.4fms", ns / (double) 1000000);
109
 
  }
110
 
%>