diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java index eeadbba1e27..0af5286126a 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java @@ -106,6 +106,8 @@ public class ConnectionPool implements Closeable, Dumpable LOG.debug("Connection {}/{} creation succeeded {}", next, maxConnections, connection); if (activate(connection)) connectionPromise.succeeded(connection); + else + connectionPromise.failed(new IllegalStateException("Active connection overflow")); } @Override diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java index d9bbae3c955..627d7e30411 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java @@ -172,7 +172,7 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint @Override public String toString() { - return String.format("%s@%x{%s<->%d,%s,%s,%s,%s,%s,%d,%s}", + return String.format("%s@%x{%s<->%d,%s,%s,%s,%s,%s,%d/%d,%s}", getClass().getSimpleName(), hashCode(), getRemoteAddress(), @@ -182,6 +182,7 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint isOutputShutdown()?"OSHUT":"out", _fillInterest.isInterested()?"R":"-", _writeFlusher.isInProgress()?"W":"-", + getIdleFor(), getIdleTimeout(), getConnection()==null?null:getConnection().getClass().getSimpleName()); } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/IdleTimeout.java b/jetty-io/src/main/java/org/eclipse/jetty/io/IdleTimeout.java index de2a86895d9..b2c8713c7df 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/IdleTimeout.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/IdleTimeout.java @@ -71,6 +71,11 @@ public abstract class IdleTimeout return _idleTimestamp; } + public long getIdleFor() + { + return System.currentTimeMillis() - getIdleTimestamp(); + } + public long getIdleTimeout() { return _idleTimeout; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ScheduledExecutorScheduler.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ScheduledExecutorScheduler.java index a812026fcc3..2cb14b5ab2f 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ScheduledExecutorScheduler.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ScheduledExecutorScheduler.java @@ -18,13 +18,17 @@ package org.eclipse.jetty.util.thread; -import java.util.concurrent.BlockingQueue; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.util.component.AbstractLifeCycle; +import org.eclipse.jetty.util.component.ContainerLifeCycle; +import org.eclipse.jetty.util.component.Dumpable; /** * Implementation of {@link Scheduler} based on JDK's {@link ScheduledThreadPoolExecutor}. @@ -34,12 +38,13 @@ import org.eclipse.jetty.util.component.AbstractLifeCycle; * queue even if the task did not fire, which provides a huge benefit in the performance * of garbage collection in young generation. */ -public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Scheduler +public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Scheduler, Dumpable { private final String name; private final boolean daemon; + private final ClassLoader classloader; private volatile ScheduledThreadPoolExecutor scheduler; - private ClassLoader classloader; + private volatile Thread thread; public ScheduledExecutorScheduler() { @@ -66,7 +71,7 @@ public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Sch @Override public Thread newThread(Runnable r) { - Thread thread = new Thread(r, name); + Thread thread = ScheduledExecutorScheduler.this.thread = new Thread(r, name); thread.setDaemon(daemon); thread.setContextClassLoader(classloader); return thread; @@ -76,8 +81,6 @@ public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Sch super.doStart(); } - - @Override protected void doStop() throws Exception { @@ -92,7 +95,24 @@ public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Sch ScheduledFuture result = scheduler.schedule(task, delay, unit); return new ScheduledFutureTask(result); } - + + @Override + public String dump() + { + return ContainerLifeCycle.dump(this); + } + + @Override + public void dump(Appendable out, String indent) throws IOException + { + ContainerLifeCycle.dumpObject(out, this); + Thread thread = this.thread; + if (thread != null) + { + List frames = Arrays.asList(thread.getStackTrace()); + ContainerLifeCycle.dump(out, indent, frames); + } + } private class ScheduledFutureTask implements Task {