@Override public void accept(int acceptorID) throws IOException { ServerSocketChannel server; synchronized(this) { server = _acceptChannel; } if (server!=null && server.isOpen() && _manager.isStarted()) { SocketChannel channel = server.accept(); channel.configureBlocking(false); Socket socket = channel.socket(); configure(socket); _manager.register(channel); } }
@Override protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment) { Timeout.Task connectTimeout = _connectingChannels.remove(channel); if (connectTimeout != null) connectTimeout.cancel(); if (attachment instanceof HttpDestination) ((HttpDestination)attachment).onConnectionFailed(ex); else super.connectionFailed(channel,ex,attachment); } }
@Override protected void doStart() throws Exception { _manager.setSelectSets(getAcceptors()); _manager.setMaxIdleTime(getMaxIdleTime()); _manager.setLowResourcesConnections(getLowResourcesConnections()); _manager.setLowResourcesMaxIdleTime(getLowResourcesMaxIdleTime()); super.doStart(); }
@Override protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException { SelectChannelEndPoint endp = new SelectChannelEndPoint(channel, selectSet, key, channel.socket().getSoTimeout()); endp.setConnection(selectSet.getManager().newConnection(channel,endp, key.attachment())); endp.setMaxIdleTime(_writeTimeout); return endp; }
private void register(SocketChannel channel, ProxyToServerConnection proxyToServer) throws IOException { _selectorManager.register(channel, proxyToServer); proxyToServer.waitReady(_connectTimeout); }
@Override public void setMaxIdleTime(int maxIdleTime) { _manager.setMaxIdleTime(maxIdleTime); super.setMaxIdleTime(maxIdleTime); }
@Override protected void doStop() throws Exception { _selectorManager.stop(); ThreadPool threadPool = _threadPool; if (_privateThreadPool && _threadPool != null && threadPool instanceof LifeCycle) ((LifeCycle)threadPool).stop(); super.doStop(); }
@Override protected void doStart() throws Exception { super.doStart(); if (_threadPool == null) { _threadPool = getServer().getThreadPool(); _privateThreadPool = false; } if (_threadPool instanceof LifeCycle && !((LifeCycle)_threadPool).isRunning()) ((LifeCycle)_threadPool).start(); _selectorManager.start(); }
@Override protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException { SelectChannelEndPoint endp = new SelectChannelEndPoint(channel, selectSet, key, channel.socket().getSoTimeout()); endp.setConnection(selectSet.getManager().newConnection(channel,endp, key.attachment())); endp.setMaxIdleTime(_writeTimeout); return endp; }
private void register(SocketChannel channel, ProxyToServerConnection proxyToServer) throws IOException { _selectorManager.register(channel, proxyToServer); proxyToServer.waitReady(_connectTimeout); }
@Override public void setMaxIdleTime(int maxIdleTime) { _manager.setMaxIdleTime(maxIdleTime); super.setMaxIdleTime(maxIdleTime); }
@Override protected void doStop() throws Exception { _selectorManager.stop(); ThreadPool threadPool = _threadPool; if (_privateThreadPool && _threadPool != null && threadPool instanceof LifeCycle) ((LifeCycle)threadPool).stop(); super.doStop(); }
@Override protected void doStart() throws Exception { super.doStart(); if (_threadPool == null) { _threadPool = getServer().getThreadPool(); _privateThreadPool = false; } if (_threadPool instanceof LifeCycle && !((LifeCycle)_threadPool).isRunning()) ((LifeCycle)_threadPool).start(); _selectorManager.start(); }
@Override protected void doStart() throws Exception { _manager.setSelectSets(getAcceptors()); _manager.setMaxIdleTime(getMaxIdleTime()); _manager.setLowResourcesConnections(getLowResourcesConnections()); _manager.setLowResourcesMaxIdleTime(getLowResourcesMaxIdleTime()); super.doStart(); }
@Override protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException { SelectChannelEndPoint endp = new SelectChannelEndPoint(channel, selectSet, key, channel.socket().getSoTimeout()); endp.setConnection(selectSet.getManager().newConnection(channel,endp, key.attachment())); endp.setMaxIdleTime(_writeTimeout); return endp; }
@Override public void accept(int acceptorID) throws IOException { ServerSocketChannel server; synchronized(this) { server = _acceptChannel; } if (server!=null && server.isOpen() && _manager.isStarted()) { SocketChannel channel = server.accept(); channel.configureBlocking(false); Socket socket = channel.socket(); configure(socket); _manager.register(channel); } }
private void register(SocketChannel channel, ProxyToServerConnection proxyToServer) throws IOException { _selectorManager.register(channel, proxyToServer); proxyToServer.waitReady(_connectTimeout); }