changeset 1007:945568ee77ac

remove HttpBuffersImpl
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 23 Oct 2016 17:40:20 -0600
parents 58a9c4a42292
children b664624a4423
files src/org/eclipse/jetty/http/HttpBuffersImpl.java src/org/eclipse/jetty/server/AbstractHttpConnection.java src/org/eclipse/jetty/server/Connector.java src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java
diffstat 4 files changed, 47 insertions(+), 141 deletions(-) [+]
line wrap: on
line diff
diff -r 58a9c4a42292 -r 945568ee77ac src/org/eclipse/jetty/http/HttpBuffersImpl.java
--- a/src/org/eclipse/jetty/http/HttpBuffersImpl.java	Sun Oct 23 17:21:20 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-package org.eclipse.jetty.http;
-
-import org.eclipse.jetty.io.Buffers;
-import org.eclipse.jetty.io.BuffersFactory;
-import org.eclipse.jetty.util.component.AbstractLifeCycle;
-
-/* ------------------------------------------------------------ */
-/** Abstract Buffer pool.
- * simple unbounded pool of buffers for header, request and response sizes.
- *
- */
-public final class HttpBuffersImpl extends AbstractLifeCycle
-{
-	private int _requestBufferSize=16*1024;
-	private int _requestHeaderSize=6*1024;
-	private int _responseBufferSize=32*1024;
-	private int _responseHeaderSize=6*1024;
-	private final int _maxBuffers=1024;
-	
-	private Buffers.Type _requestBufferType=Buffers.Type.DIRECT;
-	private Buffers.Type _responseBufferType=Buffers.Type.DIRECT;
-	
-	private Buffers _requestBuffers;
-	private Buffers _responseBuffers;
-	
-	
-	public int getRequestBufferSize()
-	{
-		return _requestBufferSize;
-	}
-	
-	public void setRequestBufferSize(int requestBufferSize)
-	{
-		_requestBufferSize = requestBufferSize;
-	}
-
-	public int getRequestHeaderSize()
-	{
-		return _requestHeaderSize;
-	}
-
-	public void setRequestHeaderSize(int requestHeaderSize)
-	{
-		_requestHeaderSize = requestHeaderSize;
-	}
-
-	public Buffers.Type getRequestBufferType()
-	{
-		return _requestBufferType;
-	}
-
-	public void setRequestBufferType(Buffers.Type requestBufferType)
-	{
-		_requestBufferType = requestBufferType;
-	}
-
-	public void setResponseBufferType(Buffers.Type responseBufferType)
-	{
-		_responseBufferType = responseBufferType;
-	}
-
-	@Override
-	protected void doStart()
-		throws Exception
-	{
-		_requestBuffers = BuffersFactory.newBuffers(Buffers.Type.INDIRECT,_requestHeaderSize,_requestBufferType,_requestBufferSize,_maxBuffers);
-		_responseBuffers = BuffersFactory.newBuffers(Buffers.Type.INDIRECT,_responseHeaderSize,_responseBufferType,_responseBufferSize,_maxBuffers);
-		super.doStart();
-	}
-	
-	@Override
-	protected void doStop()
-		throws Exception
-	{
-		_requestBuffers=null;
-		_responseBuffers=null;
-	}
-
-	public Buffers getRequestBuffers()
-	{
-		return _requestBuffers;
-	}
-	
-
-	public Buffers getResponseBuffers()
-	{
-		return _responseBuffers;
-	}
-
-	@Override
-	public String toString()
-	{
-		return _requestBuffers+"/"+_responseBuffers;
-	}
-}
diff -r 58a9c4a42292 -r 945568ee77ac src/org/eclipse/jetty/server/AbstractHttpConnection.java
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Sun Oct 23 17:21:20 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Sun Oct 23 17:40:20 2016 -0600
@@ -29,7 +29,6 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.eclipse.jetty.http.EncodedHttpURI;
-import org.eclipse.jetty.http.HttpBuffersImpl;
 import org.eclipse.jetty.http.HttpException;
 import org.eclipse.jetty.http.HttpFields;
 import org.eclipse.jetty.http.HttpGenerator;
@@ -122,11 +121,10 @@
 	{
 		super(endpoint);
 		_connector = connector;
-		HttpBuffersImpl ab = _connector._buffers;
-		_parser = new HttpParser(ab.getRequestBuffers(), endpoint, new RequestHandler());
+		_parser = new HttpParser(_connector.getRequestBuffers(), endpoint, new RequestHandler());
 		_request = new Request(this);
 		_response = new Response(this);
-		_generator = new HttpGenerator(ab.getResponseBuffers(), endpoint);
+		_generator = new HttpGenerator(_connector.getResponseBuffers(), endpoint);
 		_server = connector.server;
 	}
 
diff -r 58a9c4a42292 -r 945568ee77ac src/org/eclipse/jetty/server/Connector.java
--- a/src/org/eclipse/jetty/server/Connector.java	Sun Oct 23 17:21:20 2016 -0600
+++ b/src/org/eclipse/jetty/server/Connector.java	Sun Oct 23 17:40:20 2016 -0600
@@ -28,12 +28,8 @@
 
 import javax.servlet.ServletRequest;
 
-import org.eclipse.jetty.http.HttpBuffersImpl;
-import org.eclipse.jetty.http.HttpFields;
-import org.eclipse.jetty.http.HttpHeaders;
-import org.eclipse.jetty.http.HttpSchemes;
 import org.eclipse.jetty.io.Buffers;
-import org.eclipse.jetty.io.Buffers.Type;
+import org.eclipse.jetty.io.BuffersFactory;
 import org.eclipse.jetty.io.EndPoint;
 import org.eclipse.jetty.io.EofException;
 import org.eclipse.jetty.util.component.AggregateLifeCycle;
@@ -65,8 +61,6 @@
 	protected final int _maxIdleTime = 200000;
 	protected int _soLingerTime = -1;
 
-	protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
-
 	// from child classes
 	protected transient ServerSocketChannel _acceptChannel;
 
@@ -74,7 +68,6 @@
 		this.server = server;
 		this.port = port;
 		server.connectors.add(this);
-		addBean(_buffers);
 	}
 
 	public final void setHost(String host)
@@ -139,6 +132,8 @@
 		if (server.isLowOnThreads())
 			LOG.warn("insufficient threads configured for {}",this);
 
+		startBuffers();
+
 		LOG.info("Started {}",this);
 	}
 
@@ -156,6 +151,8 @@
 			LOG.warn("",e);
 		}
 
+		stopBuffers();
+
 		super.doStop();
 	}
 
@@ -236,22 +233,44 @@
 	}
 
 
-	// from AbstractNIOConnector
+
+	// from HttpBuffersImpl
 
-	public final boolean getUseDirectBuffers()
+	protected int _requestBufferSize = 16*1024;
+	protected int _requestHeaderSize = 6*1024;
+	private final int _responseBufferSize = 32*1024;
+	private final int _responseHeaderSize = 6*1024;
+	private final int _maxBuffers = 1024;
+	
+	protected Buffers.Type _requestBufferType = Buffers.Type.DIRECT;
+	protected Buffers.Type _responseBufferType = Buffers.Type.DIRECT;
+	
+	private Buffers _requestBuffers;
+	private Buffers _responseBuffers;
+
+	private void startBuffers()
+		throws Exception
 	{
-		return _buffers.getRequestBufferType()==Type.DIRECT;
+		_requestBuffers = BuffersFactory.newBuffers(Buffers.Type.INDIRECT,_requestHeaderSize,_requestBufferType,_requestBufferSize,_maxBuffers);
+		_responseBuffers = BuffersFactory.newBuffers(Buffers.Type.INDIRECT,_responseHeaderSize,_responseBufferType,_responseBufferSize,_maxBuffers);
+		super.doStart();
+	}
+	
+	private void stopBuffers()
+		throws Exception
+	{
+		_requestBuffers = null;
+		_responseBuffers = null;
 	}
 
-	/* ------------------------------------------------------------------------------- */
-	/**
-	 * @param direct If True (the default), the connector can use NIO direct buffers.
-	 * Some JVMs have memory management issues (bugs) with direct buffers.
-	 */
-	public final void setUseDirectBuffers(boolean direct)
+	public final Buffers getRequestBuffers()
 	{
-		_buffers.setRequestBufferType(direct?Type.DIRECT:Type.INDIRECT);
-		_buffers.setResponseBufferType(direct?Type.DIRECT:Type.INDIRECT);
+		return _requestBuffers;
+	}
+	
+	public final Buffers getResponseBuffers()
+	{
+		return _responseBuffers;
 	}
 
 }
diff -r 58a9c4a42292 -r 945568ee77ac src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java
--- a/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java	Sun Oct 23 17:21:20 2016 -0600
+++ b/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java	Sun Oct 23 17:40:20 2016 -0600
@@ -71,7 +71,9 @@
 		super(server,port);
 		_sslContextFactory = sslContextFactory;
 		addBean(_sslContextFactory);
-		setUseDirectBuffers(false);
+//		setUseDirectBuffers(false);
+		_requestBufferType = Buffers.Type.INDIRECT;
+		_responseBufferType = Buffers.Type.INDIRECT;
 		setSoLingerTime(30000);
 	}
 
@@ -187,10 +189,10 @@
 
 		SSLSession sslSession = sslEngine.getSession();
 
-		if (_buffers.getRequestHeaderSize()<sslSession.getApplicationBufferSize())
-			_buffers.setRequestHeaderSize(sslSession.getApplicationBufferSize());
-		if (_buffers.getRequestBufferSize()<sslSession.getApplicationBufferSize())
-			_buffers.setRequestBufferSize(sslSession.getApplicationBufferSize());
+		if (_requestHeaderSize < sslSession.getApplicationBufferSize())
+			_requestHeaderSize = sslSession.getApplicationBufferSize();
+		if (_requestBufferSize < sslSession.getApplicationBufferSize())
+			_requestBufferSize = sslSession.getApplicationBufferSize();
 
 		super.doStart();
 	}