Merged branch 'jetty-9.2.x' into 'master'.

This commit is contained in:
Simone Bordet 2015-02-09 17:39:16 +01:00
commit cb5541b58e
4 changed files with 36 additions and 8 deletions

View File

@ -106,6 +106,8 @@ public class ConnectionPool implements Closeable, Dumpable
LOG.debug("Connection {}/{} creation succeeded {}", next, maxConnections, connection); LOG.debug("Connection {}/{} creation succeeded {}", next, maxConnections, connection);
if (activate(connection)) if (activate(connection))
connectionPromise.succeeded(connection); connectionPromise.succeeded(connection);
else
connectionPromise.failed(new IllegalStateException("Active connection overflow"));
} }
@Override @Override

View File

@ -172,7 +172,7 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
@Override @Override
public String toString() 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(), getClass().getSimpleName(),
hashCode(), hashCode(),
getRemoteAddress(), getRemoteAddress(),
@ -182,6 +182,7 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
isOutputShutdown()?"OSHUT":"out", isOutputShutdown()?"OSHUT":"out",
_fillInterest.isInterested()?"R":"-", _fillInterest.isInterested()?"R":"-",
_writeFlusher.isInProgress()?"W":"-", _writeFlusher.isInProgress()?"W":"-",
getIdleFor(),
getIdleTimeout(), getIdleTimeout(),
getConnection()==null?null:getConnection().getClass().getSimpleName()); getConnection()==null?null:getConnection().getClass().getSimpleName());
} }

View File

@ -71,6 +71,11 @@ public abstract class IdleTimeout
return _idleTimestamp; return _idleTimestamp;
} }
public long getIdleFor()
{
return System.currentTimeMillis() - getIdleTimestamp();
}
public long getIdleTimeout() public long getIdleTimeout()
{ {
return _idleTimeout; return _idleTimeout;

View File

@ -18,13 +18,17 @@
package org.eclipse.jetty.util.thread; 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.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.util.component.AbstractLifeCycle; 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}. * 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 * queue even if the task did not fire, which provides a huge benefit in the performance
* of garbage collection in young generation. * 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 String name;
private final boolean daemon; private final boolean daemon;
private final ClassLoader classloader;
private volatile ScheduledThreadPoolExecutor scheduler; private volatile ScheduledThreadPoolExecutor scheduler;
private ClassLoader classloader; private volatile Thread thread;
public ScheduledExecutorScheduler() public ScheduledExecutorScheduler()
{ {
@ -66,7 +71,7 @@ public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Sch
@Override @Override
public Thread newThread(Runnable r) public Thread newThread(Runnable r)
{ {
Thread thread = new Thread(r, name); Thread thread = ScheduledExecutorScheduler.this.thread = new Thread(r, name);
thread.setDaemon(daemon); thread.setDaemon(daemon);
thread.setContextClassLoader(classloader); thread.setContextClassLoader(classloader);
return thread; return thread;
@ -76,8 +81,6 @@ public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Sch
super.doStart(); super.doStart();
} }
@Override @Override
protected void doStop() throws Exception protected void doStop() throws Exception
{ {
@ -92,7 +95,24 @@ public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Sch
ScheduledFuture<?> result = scheduler.schedule(task, delay, unit); ScheduledFuture<?> result = scheduler.schedule(task, delay, unit);
return new ScheduledFutureTask(result); 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<StackTraceElement> frames = Arrays.asList(thread.getStackTrace());
ContainerLifeCycle.dump(out, indent, frames);
}
}
private class ScheduledFutureTask implements Task private class ScheduledFutureTask implements Task
{ {