Issue #5201 - simplify the QueuedThreadPool detailed dump
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
001def4905
commit
0a59a2b090
|
@ -701,74 +701,39 @@ public class QueuedThreadPool extends ContainerLifeCycle implements ThreadFactor
|
||||||
public void dump(Appendable out, String indent) throws IOException
|
public void dump(Appendable out, String indent) throws IOException
|
||||||
{
|
{
|
||||||
List<Object> threads = new ArrayList<>(getMaxThreads());
|
List<Object> threads = new ArrayList<>(getMaxThreads());
|
||||||
for (final Thread thread : _threads)
|
for (Thread thread : _threads)
|
||||||
{
|
{
|
||||||
final StackTraceElement[] trace = thread.getStackTrace();
|
StackTraceElement[] trace = thread.getStackTrace();
|
||||||
String knownMethod = "";
|
String known = getKnownMethod(trace);
|
||||||
for (StackTraceElement t : trace)
|
String baseThreadInfo = String.format("%s %s %s %d", thread.getId(), thread.getName(), thread.getState(), thread.getPriority());
|
||||||
{
|
|
||||||
if ("idleJobPoll".equals(t.getMethodName()) && t.getClassName().equals(Runner.class.getName()))
|
|
||||||
{
|
|
||||||
knownMethod = "IDLE ";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("reservedWait".equals(t.getMethodName()) && t.getClassName().endsWith("ReservedThread"))
|
if (!StringUtil.isBlank(known))
|
||||||
{
|
threads.add(baseThreadInfo + " " + known);
|
||||||
knownMethod = "RESERVED ";
|
else if (isDetailedDump())
|
||||||
break;
|
threads.add((Dumpable)(o, i) -> Dumpable.dumpObjects(o, i, baseThreadInfo, (Object[])trace));
|
||||||
}
|
|
||||||
|
|
||||||
if ("select".equals(t.getMethodName()) && t.getClassName().endsWith("SelectorProducer"))
|
|
||||||
{
|
|
||||||
knownMethod = "SELECTING ";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("accept".equals(t.getMethodName()) && t.getClassName().contains("ServerConnector"))
|
|
||||||
{
|
|
||||||
knownMethod = "ACCEPTING ";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final String known = knownMethod;
|
|
||||||
|
|
||||||
if (isDetailedDump())
|
|
||||||
{
|
|
||||||
threads.add(new Dumpable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void dump(Appendable out, String indent) throws IOException
|
|
||||||
{
|
|
||||||
if (StringUtil.isBlank(known))
|
|
||||||
Dumpable.dumpObjects(out, indent, String.format("%s %s %s %d", thread.getId(), thread.getName(), thread.getState(), thread.getPriority()), (Object[])trace);
|
|
||||||
else
|
|
||||||
Dumpable.dumpObjects(out, indent, String.format("%s %s %s %s %d", thread.getId(), thread.getName(), known, thread.getState(), thread.getPriority()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String dump()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
threads.add(baseThreadInfo + " @ " + (trace.length > 0 ? trace[0].toString() : "???"));
|
||||||
int p = thread.getPriority();
|
|
||||||
threads.add(thread.getId() + " " + thread.getName() + " " + known + thread.getState() + " @ " + (trace.length > 0 ? trace[0] : "???") + (p == Thread.NORM_PRIORITY ? "" : (" prio=" + p)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dumpObjects(out, indent, new DumpableCollection("threads", threads));
|
||||||
if (isDetailedDump())
|
if (isDetailedDump())
|
||||||
|
dumpObjects(out, indent, new DumpableCollection("jobs", new ArrayList<>(getQueue())));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getKnownMethod(StackTraceElement[] trace)
|
||||||
|
{
|
||||||
|
for (StackTraceElement t : trace)
|
||||||
{
|
{
|
||||||
List<Runnable> jobs = new ArrayList<>(getQueue());
|
if ("idleJobPoll".equals(t.getMethodName()) && t.getClassName().equals(Runner.class.getName()))
|
||||||
dumpObjects(out, indent, new DumpableCollection("threads", threads), new DumpableCollection("jobs", jobs));
|
return "IDLE";
|
||||||
}
|
if ("reservedWait".equals(t.getMethodName()) && t.getClassName().endsWith("ReservedThread"))
|
||||||
else
|
return "RESERVED";
|
||||||
{
|
if ("select".equals(t.getMethodName()) && t.getClassName().endsWith("SelectorProducer"))
|
||||||
dumpObjects(out, indent, new DumpableCollection("threads", threads));
|
return "SELECTING";
|
||||||
|
if ("accept".equals(t.getMethodName()) && t.getClassName().contains("ServerConnector"))
|
||||||
|
return "ACCEPTING";
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue