Search in sources :

Example 1 with DumpableCollection

use of org.eclipse.jetty.util.component.DumpableCollection in project jetty.project by eclipse.

the class QueuedThreadPool method dump.

@Override
public void dump(Appendable out, String indent) throws IOException {
    List<Object> threads = new ArrayList<>(getMaxThreads());
    for (final Thread thread : _threads) {
        final StackTraceElement[] trace = thread.getStackTrace();
        boolean inIdleJobPoll = false;
        for (StackTraceElement t : trace) {
            if ("idleJobPoll".equals(t.getMethodName())) {
                inIdleJobPoll = true;
                break;
            }
        }
        final boolean idle = inIdleJobPoll;
        if (isDetailedDump()) {
            threads.add(new Dumpable() {

                @Override
                public void dump(Appendable out, String indent) throws IOException {
                    out.append(String.valueOf(thread.getId())).append(' ').append(thread.getName()).append(' ').append(thread.getState().toString()).append(idle ? " IDLE" : "");
                    if (thread.getPriority() != Thread.NORM_PRIORITY)
                        out.append(" prio=").append(String.valueOf(thread.getPriority()));
                    out.append(System.lineSeparator());
                    if (!idle)
                        ContainerLifeCycle.dump(out, indent, Arrays.asList(trace));
                }

                @Override
                public String dump() {
                    return null;
                }
            });
        } else {
            int p = thread.getPriority();
            threads.add(thread.getId() + " " + thread.getName() + " " + thread.getState() + " @ " + (trace.length > 0 ? trace[0] : "???") + (idle ? " IDLE" : "") + (p == Thread.NORM_PRIORITY ? "" : (" prio=" + p)));
        }
    }
    List<Runnable> jobs = Collections.emptyList();
    if (isDetailedDump())
        jobs = new ArrayList<>(getQueue());
    ContainerLifeCycle.dumpObject(out, this);
    ContainerLifeCycle.dump(out, indent, threads, Collections.singletonList(new DumpableCollection("jobs", jobs)));
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) DumpableCollection(org.eclipse.jetty.util.component.DumpableCollection) Dumpable(org.eclipse.jetty.util.component.Dumpable) ManagedObject(org.eclipse.jetty.util.annotation.ManagedObject)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ManagedObject (org.eclipse.jetty.util.annotation.ManagedObject)1 Dumpable (org.eclipse.jetty.util.component.Dumpable)1 DumpableCollection (org.eclipse.jetty.util.component.DumpableCollection)1