first working version

git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@398974 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
William Au 2006-05-02 17:38:11 +00:00
parent 580baa8964
commit e16e400afb
2 changed files with 167 additions and 19 deletions

View File

@ -2,6 +2,7 @@
org.apache.solr.schema.IndexSchema,
java.io.BufferedReader,
java.io.File,
java.io.FilenameFilter,
java.io.FileReader,
java.net.InetAddress,
java.net.UnknownHostException,
@ -10,15 +11,16 @@
<%@include file="header.jsp" %>
<%
File slaveinfo = new File(cwd + "/logs/snappuller.status");
File slaveinfo = new File(cwd + "/solr/logs/snappuller.status");
StringBuffer buffer = new StringBuffer();
StringBuffer buffer2 = new StringBuffer();
String mode = "";
if (slaveinfo.canRead()) {
// Slave instance
mode = "Slave";
File slavevers = new File(cwd + "/logs/snapshot.current");
File slavevers = new File(cwd + "/solr/logs/snapshot.current");
BufferedReader inforeader = new BufferedReader(new FileReader(slaveinfo));
BufferedReader versreader = new BufferedReader(new FileReader(slavevers));
buffer.append("<tr>\n" +
@ -41,8 +43,18 @@
} else {
// Master instance
mode = "Master";
File masterdir = new File(cwd + "/logs/clients");
File[] clients = masterdir.listFiles();
File masterdir = new File(cwd + "/solr/logs/clients");
FilenameFilter sfilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith("snapshot.status");
}
};
FilenameFilter cfilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith("snapshot.current");
}
};
File[] clients = masterdir.listFiles(cfilter);
if (clients == null) {
buffer.append("<tr>\n" +
"<td>\n" +
@ -52,19 +64,24 @@
"</td>\n" +
"</tr>\n");
} else {
buffer.append("<h4>Client Snapshot In Use:</h4>\n" +
"<tr>\n" +
"<th>\n" +
"Client" +
"</th>\n" +
"<th>\n" +
"Version" +
"</th>\n" +
"</tr>\n");
int i = 0;
while (i < clients.length) {
String fileName=clients[i].toString();
int p=fileName.indexOf("snapshot.current");
String clientName=fileName.substring(p+17);
BufferedReader reader = new BufferedReader(new FileReader(clients[i]));
buffer.append("<tr>\n" +
"<td>\n" +
"Client:" +
"</td>\n" +
"<td>\n")
.append( clients[i].toString())
.append( "</td>\n" +
"</tr>\n" +
"<tr>\n" +
"<td>\n" +
clientName +
"</td>\n" +
"<td>\n")
.append( reader.readLine())
@ -74,10 +91,50 @@
"</tr>\n");
i++;
}
clients = masterdir.listFiles(sfilter);
if (clients!=null) {
buffer.append("</table>\n" +
"<h4>Client Snapshot Distribution Status:</h4>\n" +
"<table>\n" +
"<tr>\n" +
"<th>\n" +
"Client" +
"</th>\n" +
"<th>\n" +
"Status" +
"</th>\n" +
"</tr>\n");
i = 0;
while (i < clients.length) {
String fileName=clients[i].toString();
int p=fileName.indexOf("snapshot.status");
String clientName=fileName.substring(p+16);
BufferedReader reader = new BufferedReader(new FileReader(clients[i]));
buffer.append("<tr>\n" +
"<td>\n" +
clientName +
"</td>\n" +
"<td>\n")
.append( reader.readLine())
.append( "</td>\n" +
"</tr>\n" +
"<tr>\n" +
"</tr>\n");
i++;
}
}
}
}
%>
<br clear="all">
<h2>Distribution Info</h2>
<h3><%= mode %> Server</h3>
<table>
<%= buffer %>
</table>
<br><br>
<a href=".">Return to Admin Page</a>
</body>
</html>

View File

@ -1,13 +1,104 @@
<%@ page import="java.io.BufferedReader,
java.io.FileReader"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.lang.management.ManagementFactory,
java.lang.management.ThreadMXBean,
java.lang.management.ThreadInfo,
java.io.IOException"%>
<%@include file="header.jsp" %>
<%
File getinfo = new File("logs/jvm.log");
<%!
static ThreadMXBean tmbean = ManagementFactory.getThreadMXBean();
%>
<br clear="all">
<h2>Thread Dump</h2>
<table>
<tr>
<td>
<%
out.print(System.getProperty("java.vm.name") +
" " + System.getProperty("java.vm.version") + "<br>");
%>
</td>
</tr>
<tr>
<td>
<%
long[] tids;
ThreadInfo[] tinfos;
WORK IN PROGRESS: portable thread dump isn't implemented yet.
out.print("Thread Count: current=" + tmbean.getThreadCount() +
" deamon=" + tmbean.getDaemonThreadCount() +
" peak=" + tmbean.getPeakThreadCount());
%>
</td>
</tr>
<tr>
<td>
<%
tids = tmbean.findMonitorDeadlockedThreads();
if (tids == null) {
out.print("No deadlock found.");
}
else {
out.print("Deadlock found :-");
tinfos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
for (ThreadInfo ti : tinfos) {
printThreadInfo(ti, out);
}
}
%>
</td>
</tr>
<tr>
<td>
<%
out.print("Full Thread Dump:<br>");
tids = tmbean.getAllThreadIds();
tinfos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
for (ThreadInfo ti : tinfos) {
printThreadInfo(ti, out);
}
%>
</td>
</tr>
</table>
<br><br>
<a href=".">Return to Admin Page</a>
</body>
</html>
<%!
static String INDENT = "&nbsp&nbsp&nbsp&nbsp ";
static void printThreadInfo(ThreadInfo ti, JspWriter out) throws IOException {
long tid = ti.getThreadId();
StringBuilder sb = new StringBuilder("\"" + ti.getThreadName() + "\"" +
" Id=" + tid +
" in " + ti.getThreadState());
if (ti.getLockName() != null) {
sb.append(" on lock=" + ti.getLockName());
}
if (ti.isSuspended()) {
sb.append(" (suspended)");
}
if (ti.isInNative()) {
sb.append(" (running in native)");
}
if (tmbean.isThreadCpuTimeSupported()) {
sb.append(" total cpu time="
+formatNanos(tmbean.getThreadCpuTime(tid)));
sb.append(" user time="
+formatNanos(tmbean.getThreadUserTime(tid)));
}
out.print(sb.toString()+"<br>");
if (ti.getLockOwnerName() != null) {
out.print(INDENT + " owned by " + ti.getLockOwnerName() +
" Id=" + ti.getLockOwnerId()+"<br>");
}
for (StackTraceElement ste : ti.getStackTrace()) {
out.print(INDENT + "at " + ste.toString()+"<br>");
}
out.print("<br>");
}
static String formatNanos(long ns) {
return String.format("%.4fms", ns / (double) 1000000);
}
%>