jetty-9 improved onOpen onclose handling

This commit is contained in:
Greg Wilkins 2012-09-20 11:05:20 +10:00
parent 851de69d9d
commit 0d2627b6e9
16 changed files with 149 additions and 282 deletions

View File

@ -42,7 +42,7 @@ public abstract class AbstractConnection implements Connection
private final List<Listener> listeners = new CopyOnWriteArrayList<>();
private final AtomicReference<State> _state = new AtomicReference<>(State.IDLE);
// private final long _created=System.currentTimeMillis();
private final long _created=System.currentTimeMillis();
private final EndPoint _endPoint;
private final Executor _executor;
private final Callback<Void> _readCallback;
@ -218,7 +218,7 @@ public abstract class AbstractConnection implements Connection
@Override
public void onOpen()
{
LOG.info("{} opened", this);
LOG.debug("onOpen {}", this);
for (Listener listener : listeners)
listener.onOpened(this);
@ -233,7 +233,7 @@ public abstract class AbstractConnection implements Connection
@Override
public void onClose()
{
LOG.info("{} closed",this);
LOG.debug("onClose {}",this);
for (Listener listener : listeners)
listener.onClosed(this);
@ -251,23 +251,37 @@ public abstract class AbstractConnection implements Connection
getEndPoint().close();
}
// @Override
// public int getMessagesIn()
// {
// return 0;
// }
//
// @Override
// public int getMessagesOut()
// {
// return 0;
// }
//
// @Override
// public long getCreatedTimeStamp()
// {
// return _created;
// }
@Override
public int getMessagesIn()
{
return 0;
}
@Override
public int getMessagesOut()
{
return 0;
}
@Override
public long getBytesIn()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public long getBytesOut()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public long getCreatedTimeStamp()
{
return _created;
}
@Override
public String toString()

View File

@ -58,20 +58,19 @@ public interface Connection extends AutoCloseable
@Override
public void close();
// public int getMessagesIn();
//
// public int getMessagesOut();
//
// public long getCreatedTimeStamp();
public int getMessagesIn();
public int getMessagesOut();
public long getBytesIn();
public long getBytesOut();
public long getCreatedTimeStamp();
public interface Listener
{
public void onOpened(Connection connection);
public void onClosed(Connection connection);
// TODO: add onMessageIn/Out + onBytesIn/Out
public static class Empty implements Listener
{
@Override

View File

@ -51,10 +51,9 @@ public abstract class AbstractConnectionFactory extends AggregateLifeCycle imple
_inputbufferSize=size;
}
protected void configureConnection(Connection connection, Connector connector, EndPoint endPoint)
protected AbstractConnection configure(AbstractConnection connection, Connector connector, EndPoint endPoint)
{
if (connection instanceof AbstractConnection)
((AbstractConnection)connection).setInputBufferSize(getInputBufferSize());
connection.setInputBufferSize(getInputBufferSize());
if (connector instanceof AggregateLifeCycle)
{
@ -62,6 +61,7 @@ public abstract class AbstractConnectionFactory extends AggregateLifeCycle imple
for (Connection.Listener listener : aggregate.getBeans(Connection.Listener.class))
connection.addListener(listener);
}
return connection;
}
@Override

View File

@ -137,7 +137,6 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
protected final Logger LOG = Log.getLogger(getClass());
// Order is important on server side, so we use a LinkedHashMap
private final Map<String, ConnectionFactory> _factories = new LinkedHashMap<>();
private final Statistics _stats = new ConnectorStatistics();
private final Server _server;
private final Executor _executor;
private final Scheduler _scheduler;
@ -175,7 +174,6 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
unmanage(_executor); // inherited from server
addBean(_scheduler);
addBean(_byteBufferPool);
addBean(_stats,true);
for (ConnectionFactory factory:factories)
addConnectionFactory(factory);
@ -187,11 +185,6 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
_acceptors = new Thread[acceptors];
}
@Override
public Statistics getStatistics()
{
return _stats;
}
@Override
public Server getServer()

View File

@ -85,132 +85,4 @@ public interface Connector extends LifeCycle, Graceful
*/
public Object getTransport();
/**
* @return the {@link Statistics} associated with this {@link Connector}
*/
public Statistics getStatistics();
/**
* <p>{@link Connector} statistics.</p>
*/
public interface Statistics extends LifeCycle
{
/**
* <p>Resets the statistics.</p>
*/
public void reset();
/**
* @return the number of messages received by this connector
* since last call to {@link #reset}.
*/
public int getMessagesIn();
/**
* @return the number of messages sent by this connector
* since last call to {@link #reset}.
*/
public int getMessagesOut();
/**
* @return the number of bytes received by this connector
* since last call to {@link #reset}.
*/
public int getBytesIn();
/**
* @return the number of bytes sent by this connector
* since last call to {@link #reset}.
*/
public int getBytesOut();
/**
* @return the total time connections have been open, in milliseconds,
* since last call to {@link #reset}.
*/
public long getConnectionsDurationTotal();
/**
* @return the number of connections accepted by the server
* since last call to {@link #reset}.
*/
public int getConnections() ;
/**
* @return the number of connections currently open that were opened
* since last call to {@link #reset}.
*/
public int getConnectionsOpen() ;
/**
* @return the max number of connections opened simultaneously
* since last call to {@link #reset}.
*/
public int getConnectionsOpenMax() ;
/**
* @return the max time a connection has been open, in milliseconds,
* since last call to {@link #reset}.
*/
public long getConnectionsDurationMax();
/**
* @return the mean time connections have been open, in milliseconds,
* since last call to {@link #reset}.
*/
public double getConnectionsDurationMean() ;
/**
* @return the standard deviation of the time connections have been open, in milliseconds,
* since last call to {@link #reset}.
*/
public double getConnectionsDurationStdDev() ;
/**
* @return the mean number of messages received per connection
* since last call to {@link #reset}.
*/
public double getConnectionsMessagesInMean() ;
/**
* @return the standard deviation of the number of messages received per connection
* since last call to {@link #reset}.
*/
public double getConnectionsMessagesInStdDev() ;
/**
* @return the max number of messages received by a connection
* since last call to {@link #reset}.
*/
public int getConnectionsMessagesInMax();
/**
* @return the number of milliseconds the statistics have been started or reset
*/
public long getStartedMillis();
/**
* <p>Callback method invoked when a new connection is opened.</p>
*/
public void connectionOpened();
/**
* <p>Callback method invoked when a connection is upgraded.</p>
*
* @param messagesIn the number of messages received by the previous connection
* @param messagesOut the number of messages send by the previous connection
*/
public void connectionUpgraded(int messagesIn, int messagesOut);
/**
* <p>Callback method invoked when a connection is closed.</p>
*
* @param duration the time the connection was opened
* @param messagesIn the number of messages received by the connection
* @param messagesOut the number of messages send by the connection
*/
public void connectionClosed(long duration, int messagesIn, int messagesOut);
}
}

View File

@ -23,7 +23,7 @@ import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.server.Connector.Statistics;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.ManagedOperation;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
@ -31,7 +31,8 @@ import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.statistic.CounterStatistic;
import org.eclipse.jetty.util.statistic.SampleStatistic;
class ConnectorStatistics extends AbstractLifeCycle implements Statistics, Dumpable, Connection.Listener
@ManagedObject("Connector Statistics")
public class ConnectorStatistics extends AbstractLifeCycle implements Dumpable, Connection.Listener
{
private final AtomicLong _startMillis = new AtomicLong(-1L);
private final CounterStatistic _connectionStats = new CounterStatistic();
@ -48,97 +49,81 @@ class ConnectorStatistics extends AbstractLifeCycle implements Statistics, Dumpa
@Override
public void onClosed(Connection connection)
{
// TODO
connectionClosed(0, 0, 0);
connectionClosed(System.currentTimeMillis()-connection.getCreatedTimeStamp(),connection.getMessagesIn(),connection.getMessagesOut());
}
@Override
public int getBytesIn()
{
// TODO
return -1;
}
@Override
public int getBytesOut()
{
// TODO
return -1;
}
@Override
public int getConnections()
{
return (int)_connectionStats.getTotal();
}
@Override
public long getConnectionsDurationMax()
{
return _connectionDurationStats.getMax();
}
@Override
public double getConnectionsDurationMean()
{
return _connectionDurationStats.getMean();
}
@Override
public double getConnectionsDurationStdDev()
{
return _connectionDurationStats.getStdDev();
}
@Override
public long getConnectionsDurationTotal()
{
return _connectionDurationStats.getTotal();
}
@Override
public int getConnectionsMessagesInMax()
{
return (int)_messagesIn.getMax();
}
@Override
public double getConnectionsMessagesInMean()
{
return _messagesIn.getMean();
}
@Override
public double getConnectionsMessagesInStdDev()
{
return _messagesIn.getStdDev();
}
@Override
public int getConnectionsOpen()
{
return (int)_connectionStats.getCurrent();
}
@Override
public int getConnectionsOpenMax()
{
return (int)_connectionStats.getMax();
}
@Override
public int getMessagesIn()
{
return (int)_messagesIn.getTotal();
}
@Override
public int getMessagesOut()
{
return (int)_messagesIn.getTotal();
}
@Override
public long getStartedMillis()
{
long start = _startMillis.get();
@ -156,7 +141,6 @@ class ConnectorStatistics extends AbstractLifeCycle implements Statistics, Dumpa
{
}
@Override
public void reset()
{
_startMillis.set(System.currentTimeMillis());
@ -166,7 +150,6 @@ class ConnectorStatistics extends AbstractLifeCycle implements Statistics, Dumpa
_connectionDurationStats.reset();
}
@Override
public void connectionOpened()
{
if (isStarted())
@ -175,7 +158,6 @@ class ConnectorStatistics extends AbstractLifeCycle implements Statistics, Dumpa
}
}
@Override
public void connectionUpgraded(int messagesIn, int messagesOut)
{
if (isStarted())
@ -185,7 +167,6 @@ class ConnectorStatistics extends AbstractLifeCycle implements Statistics, Dumpa
}
}
@Override
public void connectionClosed(long duration, int messagesIn, int messagesOut)
{
if (isStarted())

View File

@ -138,17 +138,17 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
}
// @Override
// public int getMessagesIn()
// {
// return getHttpChannel().getRequests();
// }
//
// @Override
// public int getMessagesOut()
// {
// return getHttpChannel().getRequests();
// }
@Override
public int getMessagesIn()
{
return getHttpChannel().getRequests();
}
@Override
public int getMessagesOut()
{
return getHttpChannel().getRequests();
}
@Override
public String toString()
@ -444,9 +444,9 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
if (connection != null)
{
LOG.debug("Upgrade from {} to {}", this, connection);
onClose();
getEndPoint().setConnection(connection);
// TODO
// ((AbstractConnector)getConnector()).connectionUpgraded(this,connection);
connection.onOpen();
}
}

View File

@ -51,9 +51,7 @@ public class HttpConnectionFactory extends AbstractConnectionFactory implements
@Override
public Connection newConnection(Connector connector, EndPoint endPoint)
{
HttpConnection connection = new HttpConnection(_config, connector, endPoint);
configureConnection(connection, connector, endPoint);
return connection;
return configure(new HttpConnection(_config, connector, endPoint), connector, endPoint);
}
}

View File

@ -78,7 +78,7 @@ public class SslConnectionFactory extends AbstractConnectionFactory
engine.setUseClientMode(false);
SslConnection sslConnection = new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine);
configureConnection(sslConnection, connector, endPoint);
configure(sslConnection, connector, endPoint);
ConnectionFactory next = connector.getConnectionFactory(_nextProtocol);
EndPoint decryptedEndPoint = sslConnection.getDecryptedEndPoint();

View File

@ -49,6 +49,7 @@ public class SelectChannelStatisticsTest
private static final Logger LOG = Log.getLogger(SelectChannelStatisticsTest.class);
private static Server _server;
private static ConnectorStatistics _statistics;
private static AbstractNetworkConnector _connector;
private static CyclicBarrier _connect;
private static CountDownLatch _closed;
@ -63,17 +64,9 @@ public class SelectChannelStatisticsTest
_connect = new CyclicBarrier(2);
_server = new Server();
_connector = new ServerConnector(_server)
{
// TODO
// @Override
// public void connectionClosed(Connection connection)
// {
// super.connectionClosed(connection);
// _closed.countDown();
// }
};
_connector = new ServerConnector(_server);
_statistics = new ConnectorStatistics();
_connector.addBean(_statistics);
_server.addConnector(_connector);
HandlerWrapper wrapper = new HandlerWrapper()
@ -127,13 +120,12 @@ public class SelectChannelStatisticsTest
@Before
public void init() throws Exception
{
_connector.getStatistics().start();
_statistics.reset();
}
@After
public void tini() throws Exception
{
_connector.getStatistics().stop();
}
@Test
@ -145,19 +137,19 @@ public class SelectChannelStatisticsTest
doClose(1);
assertEquals(1, _connector.getStatistics().getConnections());
assertEquals(0, _connector.getStatistics().getConnectionsOpen());
assertEquals(1, _connector.getStatistics().getConnectionsOpenMax());
assertTrue(_connector.getStatistics().getConnectionsOpen() <= _connector.getStatistics().getConnectionsOpenMax());
assertEquals(1, _statistics.getConnections());
assertEquals(0, _statistics.getConnectionsOpen());
assertEquals(1, _statistics.getConnectionsOpenMax());
assertTrue(_statistics.getConnectionsOpen() <= _statistics.getConnectionsOpenMax());
assertTrue(_connector.getStatistics().getConnectionsDurationMean() > 0);
assertTrue(_connector.getStatistics().getConnectionsDurationMax() > 0);
assertTrue(_connector.getStatistics().getConnectionsDurationMean() <= _connector.getStatistics().getConnectionsDurationMax());
assertTrue(_statistics.getConnectionsDurationMean() > 0);
assertTrue(_statistics.getConnectionsDurationMax() > 0);
assertTrue(_statistics.getConnectionsDurationMean() <= _statistics.getConnectionsDurationMax());
assertEquals(1, _connector.getStatistics().getMessagesIn());
assertEquals(1.0, _connector.getStatistics().getConnectionsMessagesInMean(), 0.01);
assertEquals(1, _connector.getStatistics().getConnectionsMessagesInMax());
assertTrue(_connector.getStatistics().getConnectionsMessagesInMean() <= _connector.getStatistics().getConnectionsMessagesInMax());
assertEquals(1, _statistics.getMessagesIn());
assertEquals(1.0, _statistics.getConnectionsMessagesInMean(), 0.01);
assertEquals(1, _statistics.getConnectionsMessagesInMax());
assertTrue(_statistics.getConnectionsMessagesInMean() <= _statistics.getConnectionsMessagesInMax());
}
@Test
@ -171,19 +163,19 @@ public class SelectChannelStatisticsTest
doClose(1);
assertEquals(1, _connector.getStatistics().getConnections());
assertEquals(0, _connector.getStatistics().getConnectionsOpen());
assertEquals(1, _connector.getStatistics().getConnectionsOpenMax());
assertTrue(_connector.getStatistics().getConnectionsOpen() <= _connector.getStatistics().getConnectionsOpenMax());
assertEquals(1, _statistics.getConnections());
assertEquals(0, _statistics.getConnectionsOpen());
assertEquals(1, _statistics.getConnectionsOpenMax());
assertTrue(_statistics.getConnectionsOpen() <= _statistics.getConnectionsOpenMax());
assertTrue(_connector.getStatistics().getConnectionsDurationMean() > 0);
assertTrue(_connector.getStatistics().getConnectionsDurationMax() > 0);
assertTrue(_connector.getStatistics().getConnectionsDurationMean() <= _connector.getStatistics().getConnectionsDurationMax());
assertTrue(_statistics.getConnectionsDurationMean() > 0);
assertTrue(_statistics.getConnectionsDurationMax() > 0);
assertTrue(_statistics.getConnectionsDurationMean() <= _statistics.getConnectionsDurationMax());
assertEquals(2, _connector.getStatistics().getMessagesIn());
assertEquals(2.0, _connector.getStatistics().getConnectionsMessagesInMean(), 0.01);
assertEquals(2, _connector.getStatistics().getConnectionsMessagesInMax());
assertTrue(_connector.getStatistics().getConnectionsMessagesInMean() <= _connector.getStatistics().getConnectionsMessagesInMax());
assertEquals(2, _statistics.getMessagesIn());
assertEquals(2.0, _statistics.getConnectionsMessagesInMean(), 0.01);
assertEquals(2, _statistics.getConnectionsMessagesInMax());
assertTrue(_statistics.getConnectionsMessagesInMean() <= _statistics.getConnectionsMessagesInMax());
}
@Test
@ -205,19 +197,19 @@ public class SelectChannelStatisticsTest
doClose(3);
assertEquals(3, _connector.getStatistics().getConnections());
assertEquals(0, _connector.getStatistics().getConnectionsOpen());
assertEquals(3, _connector.getStatistics().getConnectionsOpenMax());
assertTrue(_connector.getStatistics().getConnectionsOpen() <= _connector.getStatistics().getConnectionsOpenMax());
assertEquals(3, _statistics.getConnections());
assertEquals(0, _statistics.getConnectionsOpen());
assertEquals(3, _statistics.getConnectionsOpenMax());
assertTrue(_statistics.getConnectionsOpen() <= _statistics.getConnectionsOpenMax());
assertTrue(_connector.getStatistics().getConnectionsDurationMean() > 0);
assertTrue(_connector.getStatistics().getConnectionsDurationMax() > 0);
assertTrue(_connector.getStatistics().getConnectionsDurationMean() <= _connector.getStatistics().getConnectionsDurationMax());
assertTrue(_statistics.getConnectionsDurationMean() > 0);
assertTrue(_statistics.getConnectionsDurationMax() > 0);
assertTrue(_statistics.getConnectionsDurationMean() <= _statistics.getConnectionsDurationMax());
assertEquals(6, _connector.getStatistics().getMessagesIn());
assertEquals(2.0, _connector.getStatistics().getConnectionsMessagesInMean(), 0.01);
assertEquals(3, _connector.getStatistics().getConnectionsMessagesInMax());
assertTrue(_connector.getStatistics().getConnectionsMessagesInMean() <= _connector.getStatistics().getConnectionsMessagesInMax());
assertEquals(6, _statistics.getMessagesIn());
assertEquals(2.0, _statistics.getConnectionsMessagesInMean(), 0.01);
assertEquals(3, _statistics.getConnectionsMessagesInMax());
assertTrue(_statistics.getConnectionsMessagesInMean() <= _statistics.getConnectionsMessagesInMax());
}
protected void doInit(int count)
@ -260,7 +252,7 @@ public class SelectChannelStatisticsTest
_connect.await();
assertEquals(count, _connector.getStatistics().getConnectionsOpen());
assertEquals(count, _statistics.getConnectionsOpen());
String line=_in[idx].readLine();
while(line!=null)

View File

@ -54,7 +54,7 @@ public class SlowClientWithPipelinedRequestTest
@Override
public Connection newConnection(Connector connector, EndPoint endPoint)
{
return new HttpConnection(new HttpChannelConfig(),connector,endPoint)
return configure(new HttpConnection(new HttpChannelConfig(),connector,endPoint)
{
@Override
public void onFillable()
@ -62,7 +62,7 @@ public class SlowClientWithPipelinedRequestTest
handles.incrementAndGet();
super.onFillable();
}
};
},connector,endPoint);
}
});

View File

@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.continuation.Continuation;
import org.eclipse.jetty.continuation.ContinuationListener;
import org.eclipse.jetty.continuation.ContinuationSupport;
import org.eclipse.jetty.server.ConnectorStatistics;
import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
@ -46,6 +47,7 @@ import org.junit.Test;
public class StatisticsHandlerTest
{
private Server _server;
private ConnectorStatistics _statistics;
private LocalConnector _connector;
private LatchHandler _latchHandler;
private StatisticsHandler _statsHandler;
@ -56,6 +58,8 @@ public class StatisticsHandlerTest
_server = new Server();
_connector = new LocalConnector(_server);
_statistics=new ConnectorStatistics();
_connector.addBean(_statistics);
_server.addConnector(_connector);
_latchHandler = new LatchHandler();
@ -79,6 +83,7 @@ public class StatisticsHandlerTest
_statsHandler.setHandler(new AbstractHandler()
{
@Override
public void handle(String path, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException
{
request.setHandled(true);
@ -104,7 +109,7 @@ public class StatisticsHandlerTest
barrier[0].await();
assertEquals(1, _connector.getStatistics().getConnectionsOpen());
assertEquals(1, _statistics.getConnectionsOpen());
assertEquals(1, _statsHandler.getRequests());
assertEquals(1, _statsHandler.getRequestsActive());
@ -140,7 +145,7 @@ public class StatisticsHandlerTest
barrier[0].await();
assertEquals(2, _connector.getStatistics().getConnectionsOpen());
assertEquals(2, _statistics.getConnectionsOpen());
assertEquals(2, _statsHandler.getRequests());
assertEquals(1, _statsHandler.getRequestsActive());
@ -177,7 +182,7 @@ public class StatisticsHandlerTest
barrier[0].await();
assertEquals(4, _connector.getStatistics().getConnectionsOpen());
assertEquals(4, _statistics.getConnectionsOpen());
assertEquals(4, _statsHandler.getRequests());
assertEquals(2, _statsHandler.getRequestsActive());
@ -215,6 +220,7 @@ public class StatisticsHandlerTest
final CyclicBarrier barrier[] = { new CyclicBarrier(2), new CyclicBarrier(2), new CyclicBarrier(2)};
_statsHandler.setHandler(new AbstractHandler()
{
@Override
public void handle(String path, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException
{
request.setHandled(true);
@ -262,7 +268,7 @@ public class StatisticsHandlerTest
barrier[0].await();
assertEquals(1, _connector.getStatistics().getConnectionsOpen());
assertEquals(1, _statistics.getConnectionsOpen());
assertEquals(1, _statsHandler.getRequests());
assertEquals(1, _statsHandler.getRequestsActive());
@ -286,10 +292,12 @@ public class StatisticsHandlerTest
continuationHandle.get().addContinuationListener(new ContinuationListener()
{
@Override
public void onTimeout(Continuation continuation)
{
}
@Override
public void onComplete(Continuation continuation)
{
try { barrier[2].await(); } catch(Exception e) {}
@ -301,7 +309,7 @@ public class StatisticsHandlerTest
barrier[0].await();
assertEquals(1, _connector.getStatistics().getConnectionsOpen());
assertEquals(1, _statistics.getConnectionsOpen());
assertEquals(1, _statsHandler.getRequests());
assertEquals(1, _statsHandler.getRequestsActive());
@ -341,6 +349,7 @@ public class StatisticsHandlerTest
final CyclicBarrier barrier[] = { new CyclicBarrier(2), new CyclicBarrier(2), new CyclicBarrier(2)};
_statsHandler.setHandler(new AbstractHandler()
{
@Override
public void handle(String path, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException
{
request.setHandled(true);
@ -389,7 +398,7 @@ public class StatisticsHandlerTest
barrier[0].await();
assertEquals(1, _connector.getStatistics().getConnectionsOpen());
assertEquals(1, _statistics.getConnectionsOpen());
assertEquals(1, _statsHandler.getRequests());
assertEquals(1, _statsHandler.getRequestsActive());
@ -403,10 +412,12 @@ public class StatisticsHandlerTest
continuationHandle.get().addContinuationListener(new ContinuationListener()
{
@Override
public void onTimeout(Continuation continuation)
{
}
@Override
public void onComplete(Continuation continuation)
{
try { barrier[2].await(); } catch(Exception e) {}
@ -461,6 +472,7 @@ public class StatisticsHandlerTest
final CyclicBarrier barrier[] = { new CyclicBarrier(2), new CyclicBarrier(2), new CyclicBarrier(2)};
_statsHandler.setHandler(new AbstractHandler()
{
@Override
public void handle(String path, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException
{
request.setHandled(true);
@ -509,7 +521,7 @@ public class StatisticsHandlerTest
barrier[0].await();
assertEquals(1, _connector.getStatistics().getConnectionsOpen());
assertEquals(1, _statistics.getConnectionsOpen());
assertEquals(1, _statsHandler.getRequests());
assertEquals(1, _statsHandler.getRequestsActive());
@ -523,10 +535,12 @@ public class StatisticsHandlerTest
assertTrue(continuationHandle.get().isSuspended());
continuationHandle.get().addContinuationListener(new ContinuationListener()
{
@Override
public void onTimeout(Continuation continuation)
{
}
@Override
public void onComplete(Continuation continuation)
{
try { barrier[2].await(); } catch(Exception e) {}

View File

@ -45,7 +45,7 @@ public class ProxyHTTPConnectionFactory extends AbstractConnectionFactory implem
@Override
public Connection newConnection(Connector connector, EndPoint endPoint)
{
return new ProxyHTTPSPDYConnection(connector, httpChannelConfig, endPoint, version, proxyEngineSelector);
return configure(new ProxyHTTPSPDYConnection(connector, httpChannelConfig, endPoint, version, proxyEngineSelector),connector,endPoint);
}
@Override

View File

@ -97,7 +97,7 @@ public class NPNServerConnectionFactory extends AbstractConnectionFactory
if (dft==null)
dft=_protocols.get(0);
return new NextProtoNegoServerConnection((DecryptedEndPoint)endPoint, connector,protocols,_defaultProtocol);
return configure(new NextProtoNegoServerConnection((DecryptedEndPoint)endPoint, connector,protocols,_defaultProtocol),connector,endPoint);
}
@Override

View File

@ -78,7 +78,6 @@ public class SPDYServerConnectionFactory extends AbstractConnectionFactory
ServerSessionFrameListener listener = provideServerSessionFrameListener(connector,endPoint);
SPDYConnection connection = new ServerSPDYConnection(connector,endPoint, parser, listener, getInputBufferSize());
configureConnection(connection, connector, endPoint);
FlowControlStrategy flowControlStrategy = newFlowControlStrategy(version);
@ -90,7 +89,7 @@ public class SPDYServerConnectionFactory extends AbstractConnectionFactory
sessionOpened(session);
return connection;
return configure(connection,connector,endPoint);
}
protected FlowControlStrategy newFlowControlStrategy(short version)

View File

@ -51,23 +51,8 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
private final List<Bean> _beans = new CopyOnWriteArrayList<>();
private boolean _started = false;
enum Managed { MANAGED, UNMANAGED, AUTO };
private class Bean
public AggregateLifeCycle()
{
private final Object _bean;
private volatile Managed _managed = Managed.AUTO;
private Bean(Object b)
{
_bean = b;
}
@Override
public String toString()
{
return String.format("{%s,%b}", _bean, _managed);
}
}
/**
@ -495,4 +480,24 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
}
}
}
enum Managed { MANAGED, UNMANAGED, AUTO };
private class Bean
{
private final Object _bean;
private volatile Managed _managed = Managed.AUTO;
private Bean(Object b)
{
_bean = b;
}
@Override
public String toString()
{
return String.format("{%s,%b}", _bean, _managed);
}
}
}