Mercurial Hosting > luan
diff src/org/eclipse/jetty/io/nio/SelectorManager.java @ 948:f5aefdc4a81a
simplify SelectChannelConnector
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 11 Oct 2016 22:16:29 -0600 |
parents | 1d24b6e422fa |
children | e9088af3787f |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/nio/SelectorManager.java Tue Oct 11 21:33:40 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/SelectorManager.java Tue Oct 11 22:16:29 2016 -0600 @@ -92,34 +92,6 @@ } /* ------------------------------------------------------------ */ - /** - * @return the max idle time - */ - public long getMaxIdleTime() - { - return _maxIdleTime; - } - - /* ------------------------------------------------------------ */ - /** - * @return the number of select sets in use - */ - public int getSelectSets() - { - return _selectSets; - } - - /* ------------------------------------------------------------ */ - /** - * @param i - * @return The select set - */ - public SelectSet getSelectSet(int i) - { - return _selectSet[i]; - } - - /* ------------------------------------------------------------ */ /** Register a channel * @param channel */ @@ -129,11 +101,11 @@ // so long as the value changes sometimes, then connections will // be distributed over the available sets. - int s=_set++; + int s = _set++; if (s<0) s=-s; s=s%_selectSets; - SelectSet[] sets=_selectSet; + SelectSet[] sets = _selectSet; if (sets!=null) { SelectSet set=sets[s]; @@ -196,7 +168,7 @@ super.doStart(); // start a thread to Select - for (int i=0;i<getSelectSets();i++) + for (int i=0;i<_selectSets;i++) { final int id=i; execute(new Runnable() @@ -258,40 +230,14 @@ super.doStop(); } - /* ------------------------------------------------------------ */ - /** - * @param endpoint - */ - protected abstract void endPointClosed(SelectChannelEndPoint endpoint); - /* ------------------------------------------------------------------------------- */ public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment); - /* ------------------------------------------------------------ */ - /** - * Create a new end point - * @param channel - * @param selectSet - * @param sKey the selection key - * @return the new endpoint {@link SelectChannelEndPoint} - * @throws IOException - */ - protected abstract SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey sKey) throws IOException; - - /* ------------------------------------------------------------------------------- */ - protected void connectionFailed(SocketChannel channel,Throwable ex,Object attachment) - { - LOG.warn(ex+","+channel+","+attachment); - LOG.debug("",ex); - } - - /* ------------------------------------------------------------ */ public String dump() { return AggregateLifeCycle.dump(this); } - /* ------------------------------------------------------------ */ public void dump(Appendable out, String indent) throws IOException { AggregateLifeCycle.dumpObject(out,this); @@ -299,9 +245,6 @@ } - /* ------------------------------------------------------------------------------- */ - /* ------------------------------------------------------------------------------- */ - /* ------------------------------------------------------------------------------- */ public class SelectSet implements Dumpable { private final int _setID; @@ -500,7 +443,8 @@ } catch(Exception e) { - connectionFailed(channel,e,att); + LOG.warn(e+","+channel+","+att); + LOG.debug("",e); } finally { @@ -628,7 +572,8 @@ private SelectChannelEndPoint createEndPoint(SocketChannel channel, SelectionKey sKey) throws IOException { - SelectChannelEndPoint endp = newEndPoint(channel,this,sKey); + SelectChannelEndPoint endp = new SelectChannelEndPoint(channel,this,sKey, _maxIdleTime); + endp.setConnection(getManager().newConnection(channel,endp, sKey.attachment())); LOG.debug("created {}",endp); _endPoints.put(endp,this); return endp; @@ -638,7 +583,7 @@ { LOG.debug("destroyEndPoint {}",endp); _endPoints.remove(endp); - endPointClosed(endp); + endp.getConnection().onClose(); } Selector getSelector()