comparison src/org/eclipse/jetty/server/Connector.java @ 1007:945568ee77ac

remove HttpBuffersImpl
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 23 Oct 2016 17:40:20 -0600
parents 58a9c4a42292
children b664624a4423
comparison
equal deleted inserted replaced
1006:58a9c4a42292 1007:945568ee77ac
26 import java.util.concurrent.ThreadPoolExecutor; 26 import java.util.concurrent.ThreadPoolExecutor;
27 import java.util.concurrent.atomic.AtomicLong; 27 import java.util.concurrent.atomic.AtomicLong;
28 28
29 import javax.servlet.ServletRequest; 29 import javax.servlet.ServletRequest;
30 30
31 import org.eclipse.jetty.http.HttpBuffersImpl;
32 import org.eclipse.jetty.http.HttpFields;
33 import org.eclipse.jetty.http.HttpHeaders;
34 import org.eclipse.jetty.http.HttpSchemes;
35 import org.eclipse.jetty.io.Buffers; 31 import org.eclipse.jetty.io.Buffers;
36 import org.eclipse.jetty.io.Buffers.Type; 32 import org.eclipse.jetty.io.BuffersFactory;
37 import org.eclipse.jetty.io.EndPoint; 33 import org.eclipse.jetty.io.EndPoint;
38 import org.eclipse.jetty.io.EofException; 34 import org.eclipse.jetty.io.EofException;
39 import org.eclipse.jetty.util.component.AggregateLifeCycle; 35 import org.eclipse.jetty.util.component.AggregateLifeCycle;
40 import org.eclipse.jetty.util.component.Dumpable; 36 import org.eclipse.jetty.util.component.Dumpable;
41 import org.slf4j.Logger; 37 import org.slf4j.Logger;
63 public final int port; 59 public final int port;
64 60
65 protected final int _maxIdleTime = 200000; 61 protected final int _maxIdleTime = 200000;
66 protected int _soLingerTime = -1; 62 protected int _soLingerTime = -1;
67 63
68 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
69
70 // from child classes 64 // from child classes
71 protected transient ServerSocketChannel _acceptChannel; 65 protected transient ServerSocketChannel _acceptChannel;
72 66
73 protected Connector(Server server,int port) { 67 protected Connector(Server server,int port) {
74 this.server = server; 68 this.server = server;
75 this.port = port; 69 this.port = port;
76 server.connectors.add(this); 70 server.connectors.add(this);
77 addBean(_buffers);
78 } 71 }
79 72
80 public final void setHost(String host) 73 public final void setHost(String host)
81 { 74 {
82 _host = host; 75 _host = host;
137 ThreadPoolExecutor _threadPool = server.threadPool; 130 ThreadPoolExecutor _threadPool = server.threadPool;
138 _threadPool.execute(this); 131 _threadPool.execute(this);
139 if (server.isLowOnThreads()) 132 if (server.isLowOnThreads())
140 LOG.warn("insufficient threads configured for {}",this); 133 LOG.warn("insufficient threads configured for {}",this);
141 134
135 startBuffers();
136
142 LOG.info("Started {}",this); 137 LOG.info("Started {}",this);
143 } 138 }
144 139
145 @Override 140 @Override
146 protected synchronized void doStop() throws Exception 141 protected synchronized void doStop() throws Exception
153 } 148 }
154 catch (IOException e) 149 catch (IOException e)
155 { 150 {
156 LOG.warn("",e); 151 LOG.warn("",e);
157 } 152 }
153
154 stopBuffers();
158 155
159 super.doStop(); 156 super.doStop();
160 } 157 }
161 158
162 159
234 _name = (getHost() == null?"0.0.0.0":getHost()) + ":" + port; 231 _name = (getHost() == null?"0.0.0.0":getHost()) + ":" + port;
235 return _name; 232 return _name;
236 } 233 }
237 234
238 235
239 // from AbstractNIOConnector 236
240 237 // from HttpBuffersImpl
241 public final boolean getUseDirectBuffers() 238
242 { 239 protected int _requestBufferSize = 16*1024;
243 return _buffers.getRequestBufferType()==Type.DIRECT; 240 protected int _requestHeaderSize = 6*1024;
244 } 241 private final int _responseBufferSize = 32*1024;
245 242 private final int _responseHeaderSize = 6*1024;
246 /* ------------------------------------------------------------------------------- */ 243 private final int _maxBuffers = 1024;
247 /** 244
248 * @param direct If True (the default), the connector can use NIO direct buffers. 245 protected Buffers.Type _requestBufferType = Buffers.Type.DIRECT;
249 * Some JVMs have memory management issues (bugs) with direct buffers. 246 protected Buffers.Type _responseBufferType = Buffers.Type.DIRECT;
250 */ 247
251 public final void setUseDirectBuffers(boolean direct) 248 private Buffers _requestBuffers;
252 { 249 private Buffers _responseBuffers;
253 _buffers.setRequestBufferType(direct?Type.DIRECT:Type.INDIRECT); 250
254 _buffers.setResponseBufferType(direct?Type.DIRECT:Type.INDIRECT); 251 private void startBuffers()
252 throws Exception
253 {
254 _requestBuffers = BuffersFactory.newBuffers(Buffers.Type.INDIRECT,_requestHeaderSize,_requestBufferType,_requestBufferSize,_maxBuffers);
255 _responseBuffers = BuffersFactory.newBuffers(Buffers.Type.INDIRECT,_responseHeaderSize,_responseBufferType,_responseBufferSize,_maxBuffers);
256 super.doStart();
257 }
258
259 private void stopBuffers()
260 throws Exception
261 {
262 _requestBuffers = null;
263 _responseBuffers = null;
264 }
265
266 public final Buffers getRequestBuffers()
267 {
268 return _requestBuffers;
269 }
270
271 public final Buffers getResponseBuffers()
272 {
273 return _responseBuffers;
255 } 274 }
256 275
257 } 276 }