use of org.eclipse.jetty.util.thread.TimerScheduler in project jetty.project by eclipse.
the class IdleTimeoutTest method setUp.
@Before
public void setUp() throws Exception {
_open = true;
_expired = null;
_timer = new TimerScheduler();
_timer.start();
_timeout = new IdleTimeout(_timer) {
@Override
protected void onIdleExpired(TimeoutException timeout) {
_expired = timeout;
}
@Override
public boolean isOpen() {
return _open;
}
};
_timeout.setIdleTimeout(1000);
}
use of org.eclipse.jetty.util.thread.TimerScheduler in project jetty.project by eclipse.
the class LowResourcesMonitorTest method before.
@Before
public void before() throws Exception {
_threadPool = new QueuedThreadPool();
_threadPool.setMaxThreads(50);
_server = new Server(_threadPool);
_server.manage(_threadPool);
_server.addBean(new TimerScheduler());
_connector = new ServerConnector(_server);
_connector.setPort(0);
_connector.setIdleTimeout(35000);
_server.addConnector(_connector);
_server.setHandler(new DumpHandler());
_lowResourcesMonitor = new LowResourceMonitor(_server);
_lowResourcesMonitor.setLowResourcesIdleTimeout(200);
_lowResourcesMonitor.setMaxConnections(20);
_lowResourcesMonitor.setPeriod(900);
_server.addBean(_lowResourcesMonitor);
_server.start();
}
use of org.eclipse.jetty.util.thread.TimerScheduler in project jetty.project by eclipse.
the class ResponseTest method init.
@Before
public void init() throws Exception {
_server = new Server();
Scheduler _scheduler = new TimerScheduler();
HttpConfiguration config = new HttpConfiguration();
LocalConnector connector = new LocalConnector(_server, null, _scheduler, null, 1, new HttpConnectionFactory(config));
_server.addConnector(connector);
_server.setHandler(new DumpHandler());
_server.start();
AbstractEndPoint endp = new ByteArrayEndPoint(_scheduler, 5000) {
@Override
public InetSocketAddress getLocalAddress() {
return LOCALADDRESS;
}
};
_channel = new HttpChannel(connector, new HttpConfiguration(), endp, new HttpTransport() {
private Throwable _channelError;
@Override
public void send(MetaData.Response info, boolean head, ByteBuffer content, boolean lastContent, Callback callback) {
if (_channelError == null)
callback.succeeded();
else
callback.failed(_channelError);
}
@Override
public boolean isPushSupported() {
return false;
}
@Override
public void push(org.eclipse.jetty.http.MetaData.Request request) {
}
@Override
public void onCompleted() {
}
@Override
public void abort(Throwable failure) {
_channelError = failure;
}
@Override
public boolean isOptimizedForDirectBuffers() {
return false;
}
});
}
use of org.eclipse.jetty.util.thread.TimerScheduler in project jetty.project by eclipse.
the class SelectChannelEndPointInterestsTest method init.
public void init(final Interested interested) throws Exception {
threadPool = new QueuedThreadPool();
threadPool.start();
scheduler = new TimerScheduler();
scheduler.start();
connector = ServerSocketChannel.open();
connector.bind(new InetSocketAddress("localhost", 0));
selectorManager = new SelectorManager(threadPool, scheduler) {
@Override
protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key) throws IOException {
SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, key, getScheduler()) {
@Override
protected void onIncompleteFlush() {
super.onIncompleteFlush();
interested.onIncompleteFlush();
}
};
endp.setIdleTimeout(60000);
return endp;
}
@Override
public Connection newConnection(SelectableChannel channel, final EndPoint endPoint, Object attachment) {
return new AbstractConnection(endPoint, getExecutor()) {
@Override
public void onOpen() {
super.onOpen();
fillInterested();
}
@Override
public void onFillable() {
interested.onFillable(endPoint, this);
}
};
}
};
selectorManager.start();
}
use of org.eclipse.jetty.util.thread.TimerScheduler in project jetty.project by eclipse.
the class ByteArrayEndPointTest method before.
@Before
public void before() throws Exception {
_scheduler = new TimerScheduler();
_scheduler.start();
}
Aggregations