changeset 970:d82eb99e8df6

remove ConnectorSelectorManager
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 14 Oct 2016 05:24:18 -0600
parents 0650077fcd6c
children f997df37cec1
files src/org/eclipse/jetty/io/nio/SelectorManager.java src/org/eclipse/jetty/server/nio/SelectChannelConnector.java src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java
diffstat 3 files changed, 15 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/nio/SelectorManager.java	Fri Oct 14 02:44:02 2016 -0600
+++ b/src/org/eclipse/jetty/io/nio/SelectorManager.java	Fri Oct 14 05:24:18 2016 -0600
@@ -43,6 +43,7 @@
 import org.eclipse.jetty.util.component.AbstractLifeCycle;
 import org.eclipse.jetty.util.component.AggregateLifeCycle;
 import org.eclipse.jetty.util.component.Dumpable;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,11 +54,11 @@
  * NIO scheduling to scale to large numbers of connections.
  * <p>
  */
-public abstract class SelectorManager extends AbstractLifeCycle implements Dumpable
+public final class SelectorManager extends AbstractLifeCycle implements Dumpable
 {
 	public static final Logger LOG = LoggerFactory.getLogger("org.eclipse.jetty.io.nio");
 
-	private final int _maxIdleTime;
+	private final SelectChannelConnector scc;
 	private volatile long _now = System.currentTimeMillis();
 	private SaneSelector _selector;
 
@@ -66,9 +67,9 @@
 	 * @param maxIdleTime The maximum period in milli seconds that a connection may be idle before it is closed.
 	 * @see #setLowResourcesMaxIdleTime(long)
 	 */
-	public SelectorManager(int maxIdleTime)
+	public SelectorManager(SelectChannelConnector scc)
 	{
-		_maxIdleTime = maxIdleTime;
+		this.scc = scc;
 	}
 
 	/* ------------------------------------------------------------ */
@@ -86,7 +87,7 @@
 */
 		try {
 			SelectionKey key = _selector.register(channel,0,null);
-			SelectChannelEndPoint endpoint = new SelectChannelEndPoint(channel,this,key, _maxIdleTime);
+			SelectChannelEndPoint endpoint = new SelectChannelEndPoint(channel,this,key, scc.getMaxIdleTime());
 			key.attach(endpoint);
 			_selector.update();
 //System.out.println("qqqqqqqqqqqqqqqqqqqqqqqqqqqqq b");
@@ -102,7 +103,9 @@
 	}
 
 
-	public abstract void execute(Runnable task);
+	public void execute(Runnable task) {
+		scc.server.threadPool.execute(task);
+	}
 
 
 	@Override
@@ -184,7 +187,9 @@
 		super.doStop();
 	}
 
-	public abstract AsyncConnection newConnection(SocketChannel channel, SelectChannelEndPoint endpoint);
+	public AsyncConnection newConnection(SocketChannel channel, SelectChannelEndPoint endpoint) {
+		return scc.newConnection(channel,endpoint);
+	}
 
 	@Override
 	public String dump()
--- a/src/org/eclipse/jetty/server/nio/SelectChannelConnector.java	Fri Oct 14 02:44:02 2016 -0600
+++ b/src/org/eclipse/jetty/server/nio/SelectChannelConnector.java	Fri Oct 14 05:24:18 2016 -0600
@@ -53,7 +53,7 @@
  */
 public class SelectChannelConnector extends Connector
 {
-	private final SelectorManager _manager = new ConnectorSelectorManager();
+	private final SelectorManager _manager = new SelectorManager(this);
 
 	public SelectChannelConnector(Server server,int port)
 	{
@@ -107,28 +107,8 @@
 		super.doStart();
 	}
 
-	protected AsyncConnection newConnection(SocketChannel channel,AsyncEndPoint endpoint)
+	public AsyncConnection newConnection(SocketChannel channel,AsyncEndPoint endpoint)
 	{
 		return new AsyncHttpConnection(SelectChannelConnector.this,endpoint,server);
 	}
-
-
-	private final class ConnectorSelectorManager extends SelectorManager
-	{
-		ConnectorSelectorManager() {
-			super(_maxIdleTime);
-		}
-
-		@Override
-		public void execute(Runnable task)
-		{
-			server.threadPool.execute(task);
-		}
-
-		@Override
-		public AsyncConnection newConnection(SocketChannel channel,SelectChannelEndPoint endpoint)
-		{
-			return SelectChannelConnector.this.newConnection(channel,endpoint);
-		}
-	}
 }
--- a/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java	Fri Oct 14 02:44:02 2016 -0600
+++ b/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java	Fri Oct 14 05:24:18 2016 -0600
@@ -532,7 +532,7 @@
 	}
 
 	@Override
-	protected AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint)
+	public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint)
 	{
 		try
 		{