changeset 913:17f4fe8271de

simplify connectors
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 08 Oct 2016 23:57:11 -0600
parents 1d0c304e12b5
children 54308d65265a
files src/org/eclipse/jetty/server/AbstractHttpConnection.java src/org/eclipse/jetty/server/Connector.java src/org/eclipse/jetty/server/Server.java src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java src/org/eclipse/jetty/server/nio/SelectChannelConnector.java
diffstat 5 files changed, 10 insertions(+), 143 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Sat Oct 08 22:05:14 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Sat Oct 08 23:57:11 2016 -0600
@@ -711,7 +711,7 @@
 	public int getMaxIdleTime()
 	{
 		if (_connector.isLowResources() && _endp.getMaxIdleTime()==_connector.getMaxIdleTime())
-			return _connector.getLowResourceMaxIdleTime();
+			return 0;
 		if (_endp.getMaxIdleTime()>0)
 			return _endp.getMaxIdleTime();
 		return _connector.getMaxIdleTime();
--- a/src/org/eclipse/jetty/server/Connector.java	Sat Oct 08 22:05:14 2016 -0600
+++ b/src/org/eclipse/jetty/server/Connector.java	Sat Oct 08 23:57:11 2016 -0600
@@ -66,7 +66,6 @@
 	private int _acceptors = 1;
 
 	protected int _maxIdleTime = 200000;
-	protected int _lowResourceMaxIdleTime = -1;
 	protected int _soLingerTime = -1;
 
 	protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
@@ -120,52 +119,12 @@
 	 * @param maxIdleTime
 	 *            The maxIdleTime to set.
 	 */
+/*
 	public void setMaxIdleTime(int maxIdleTime)
 	{
 		_maxIdleTime = maxIdleTime;
 	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @return Returns the maxIdleTime when resources are low.
-	 */
-	public int getLowResourcesMaxIdleTime()
-	{
-		return _lowResourceMaxIdleTime;
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @param maxIdleTime
-	 *            The maxIdleTime to set when resources are low.
-	 */
-	public void setLowResourcesMaxIdleTime(int maxIdleTime)
-	{
-		_lowResourceMaxIdleTime = maxIdleTime;
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @return Returns the maxIdleTime when resources are low.
-	 * @deprecated
-	 */
-	@Deprecated
-	public final int getLowResourceMaxIdleTime()
-	{
-		return getLowResourcesMaxIdleTime();
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @param maxIdleTime
-	 *            The maxIdleTime to set when resources are low.
-	 * @deprecated
-	 */
-	@Deprecated
-	public final void setLowResourceMaxIdleTime(int maxIdleTime)
-	{
-		setLowResourcesMaxIdleTime(maxIdleTime);
-	}
+*/
 
 	/* ------------------------------------------------------------ */
 	/**
@@ -224,11 +183,13 @@
 
 	/* ------------------------------------------------------------ */
 	@Override
-	protected void doStop() throws Exception
+	protected synchronized void doStop() throws Exception
 	{
 		try
 		{
-			close();
+			if (_acceptChannel != null)
+				_acceptChannel.close();
+			_acceptChannel=null;
 		}
 		catch (IOException e)
 		{
@@ -425,9 +386,6 @@
 		return server.isLowOnThreads();
 	}
 
-	// from old interface
-	public abstract void close() throws IOException;
-
 
 	// from AbstractNIOConnector
 
--- a/src/org/eclipse/jetty/server/Server.java	Sat Oct 08 22:05:14 2016 -0600
+++ b/src/org/eclipse/jetty/server/Server.java	Sat Oct 08 23:57:11 2016 -0600
@@ -76,7 +76,6 @@
 		new SelectChannelConnector(this,port);
 	}
 
-	/* ------------------------------------------------------------ */
 	@Override
 	protected void doStart() throws Exception
 	{
@@ -105,7 +104,6 @@
 		mex.ifExceptionThrow();
 	}
 
-	/* ------------------------------------------------------------ */
 	@Override
 	protected void doStop() throws Exception
 	{
@@ -201,7 +199,6 @@
 	}
 
 
-	/* ------------------------------------------------------------ */
 	public void join() throws InterruptedException
 	{
 		threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
@@ -259,7 +256,6 @@
 		return this.getClass().getName()+"@"+Integer.toHexString(hashCode());
 	}
 
-	/* ------------------------------------------------------------ */
 	@Override
 	public void dump(Appendable out,String indent) throws IOException
 	{
@@ -287,7 +283,6 @@
 	}
 
 
-	/* ------------------------------------------------------------ */
 	public static void main(String...args) throws Exception
 	{
 		System.err.println(version);
--- a/src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java	Sat Oct 08 22:05:14 2016 -0600
+++ b/src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java	Sat Oct 08 23:57:11 2016 -0600
@@ -116,13 +116,6 @@
 
 	}
 
-	public void close() throws IOException
-	{
-		if (_acceptChannel != null)
-			_acceptChannel.close();
-		_acceptChannel=null;
-	}
-
 	@Override
 	public void accept()
 		throws IOException, InterruptedException
@@ -251,18 +244,7 @@
 				while (isOpen())
 				{
 					_idleTimestamp=System.currentTimeMillis();
-					if (_connection.isIdle())
-					{
-						if (server.isLowOnThreads())
-						{
-							int lrmit = getLowResourcesMaxIdleTime();
-							if (lrmit>=0 && _timeout!= lrmit)
-							{
-								_timeout=lrmit;
-							}
-						}
-					}
-					else
+					if (!_connection.isIdle())
 					{
 						if (_timeout!=getMaxIdleTime())
 						{
--- a/src/org/eclipse/jetty/server/nio/SelectChannelConnector.java	Sat Oct 08 22:05:14 2016 -0600
+++ b/src/org/eclipse/jetty/server/nio/SelectChannelConnector.java	Sat Oct 08 23:57:11 2016 -0600
@@ -67,9 +67,6 @@
  */
 public class SelectChannelConnector extends Connector
 {
-	private int _lowResourcesConnections;
-	private int _lowResourcesMaxIdleTime;
-
 	private final SelectorManager _manager = new ConnectorSelectorManager();
 
 	public SelectChannelConnector(Server server,int port)
@@ -95,16 +92,6 @@
 		}
 	}
 
-	public synchronized void close() throws IOException
-	{
-		if (_acceptChannel != null)
-		{
-			if (_acceptChannel.isOpen())
-				_acceptChannel.close();
-		}
-		_acceptChannel = null;
-	}
-
 	@Override
 	public void customize(EndPoint endpoint, Request request) throws IOException
 	{
@@ -121,68 +108,13 @@
 		super.persist(endpoint);
 	}
 
-	public SelectorManager getSelectorManager()
-	{
-		return _manager;
-	}
-
-	@Override
-	public void setMaxIdleTime(int maxIdleTime)
-	{
-		_manager.setMaxIdleTime(maxIdleTime);
-		super.setMaxIdleTime(maxIdleTime);
-	}
-
-	public int getLowResourcesConnections()
-	{
-		return _lowResourcesConnections;
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * Set the number of connections, which if exceeded places this manager in low resources state.
-	 * This is not an exact measure as the connection count is averaged over the select sets.
-	 * @param lowResourcesConnections the number of connections
-	 * @see #setLowResourcesMaxIdleTime(int)
-	 */
-	public void setLowResourcesConnections(int lowResourcesConnections)
-	{
-		_lowResourcesConnections=lowResourcesConnections;
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @return the lowResourcesMaxIdleTime
-	 */
-	@Override
-	public int getLowResourcesMaxIdleTime()
-	{
-		return _lowResourcesMaxIdleTime;
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * Set the period in ms that a connection is allowed to be idle when this there are more
-	 * than {@link #getLowResourcesConnections()} connections.  This allows the server to rapidly close idle connections
-	 * in order to gracefully handle high load situations.
-	 * @param lowResourcesMaxIdleTime the period in ms that a connection is allowed to be idle when resources are low.
-	 * @see #setMaxIdleTime(int)
-	 */
-	@Override
-	public void setLowResourcesMaxIdleTime(int lowResourcesMaxIdleTime)
-	{
-		_lowResourcesMaxIdleTime=lowResourcesMaxIdleTime;
-		super.setLowResourcesMaxIdleTime(lowResourcesMaxIdleTime);
-	}
-
-
 	@Override
 	protected synchronized void doStart() throws Exception
 	{
 		_manager.setSelectSets(getAcceptors());
 		_manager.setMaxIdleTime(getMaxIdleTime());
-		_manager.setLowResourcesConnections(getLowResourcesConnections());
-		_manager.setLowResourcesMaxIdleTime(getLowResourcesMaxIdleTime());
+		_manager.setLowResourcesConnections(0);
+		_manager.setLowResourcesMaxIdleTime(0);
 
 		if (_acceptChannel == null)
 		{