Added jobs to detailed dump.
This commit is contained in:
parent
bdafea3e96
commit
30fd8323f4
|
@ -22,6 +22,7 @@ package org.eclipse.jetty.util.thread;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
@ -51,7 +52,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
|
|||
private final AtomicInteger _threadsStarted = new AtomicInteger();
|
||||
private final AtomicInteger _threadsIdle = new AtomicInteger();
|
||||
private final AtomicLong _lastShrink = new AtomicLong();
|
||||
private final ConcurrentHashSet<Thread> _threads=new ConcurrentHashSet<Thread>();
|
||||
private final ConcurrentHashSet<Thread> _threads=new ConcurrentHashSet<>();
|
||||
private final Object _joinLock = new Object();
|
||||
private final BlockingQueue<Runnable> _jobs;
|
||||
private final ThreadGroup _threadGroup;
|
||||
|
@ -126,13 +127,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
|
|||
jobs.clear();
|
||||
|
||||
// Fill job Q with noop jobs to wakeup idle
|
||||
Runnable noop = new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
}
|
||||
};
|
||||
Runnable noop = () -> {};
|
||||
for (int i = _threadsStarted.get(); i-- > 0; )
|
||||
jobs.offer(noop);
|
||||
|
||||
|
@ -487,7 +482,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
|
|||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
List<Object> dump = new ArrayList<>(getMaxThreads());
|
||||
List<Object> threads = new ArrayList<>(getMaxThreads());
|
||||
for (final Thread thread : _threads)
|
||||
{
|
||||
final StackTraceElement[] trace = thread.getStackTrace();
|
||||
|
@ -504,7 +499,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
|
|||
|
||||
if (isDetailedDump())
|
||||
{
|
||||
dump.add(new Dumpable()
|
||||
threads.add(new Dumpable()
|
||||
{
|
||||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
|
@ -527,12 +522,16 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
|
|||
else
|
||||
{
|
||||
int p=thread.getPriority();
|
||||
dump.add(thread.getId() + " " + thread.getName() + " " + thread.getState() + " @ " + (trace.length > 0 ? trace[0] : "???") + (idle ? " IDLE" : "")+ (p==Thread.NORM_PRIORITY?"":(" prio="+p)));
|
||||
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, dump);
|
||||
ContainerLifeCycle.dump(out, indent, threads, jobs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -664,7 +663,9 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
|
|||
|
||||
/**
|
||||
* @param queue the job queue
|
||||
* @deprecated pass the queue to the constructor instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setQueue(BlockingQueue<Runnable> queue)
|
||||
{
|
||||
throw new UnsupportedOperationException("Use constructor injection");
|
||||
|
|
Loading…
Reference in New Issue