Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/Connector.java @ 1011:4e7208df7741
remove PooledBuffers
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 23 Oct 2016 23:59:08 -0600 |
parents | b664624a4423 |
children | 8c13b9224cff |
comparison
equal
deleted
inserted
replaced
1010:2712133d5bce | 1011:4e7208df7741 |
---|---|
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.io.Buffer; | |
31 import org.eclipse.jetty.io.Buffers; | 32 import org.eclipse.jetty.io.Buffers; |
32 import org.eclipse.jetty.io.PooledBuffers; | |
33 import org.eclipse.jetty.io.EndPoint; | 33 import org.eclipse.jetty.io.EndPoint; |
34 import org.eclipse.jetty.io.EofException; | 34 import org.eclipse.jetty.io.EofException; |
35 import org.eclipse.jetty.io.nio.DirectNIOBuffer; | |
36 import org.eclipse.jetty.io.nio.IndirectNIOBuffer; | |
35 import org.eclipse.jetty.util.component.AggregateLifeCycle; | 37 import org.eclipse.jetty.util.component.AggregateLifeCycle; |
36 import org.eclipse.jetty.util.component.Dumpable; | 38 import org.eclipse.jetty.util.component.Dumpable; |
37 import org.slf4j.Logger; | 39 import org.slf4j.Logger; |
38 import org.slf4j.LoggerFactory; | 40 import org.slf4j.LoggerFactory; |
39 | 41 |
130 ThreadPoolExecutor _threadPool = server.threadPool; | 132 ThreadPoolExecutor _threadPool = server.threadPool; |
131 _threadPool.execute(this); | 133 _threadPool.execute(this); |
132 if (server.isLowOnThreads()) | 134 if (server.isLowOnThreads()) |
133 LOG.warn("insufficient threads configured for {}",this); | 135 LOG.warn("insufficient threads configured for {}",this); |
134 | 136 |
135 startBuffers(); | |
136 | |
137 LOG.info("Started {}",this); | 137 LOG.info("Started {}",this); |
138 } | 138 } |
139 | 139 |
140 @Override | 140 @Override |
141 protected synchronized void doStop() throws Exception | 141 protected synchronized void doStop() throws Exception |
148 } | 148 } |
149 catch (IOException e) | 149 catch (IOException e) |
150 { | 150 { |
151 LOG.warn("",e); | 151 LOG.warn("",e); |
152 } | 152 } |
153 | |
154 stopBuffers(); | |
155 | 153 |
156 super.doStop(); | 154 super.doStop(); |
157 } | 155 } |
158 | 156 |
159 | 157 |
234 | 232 |
235 | 233 |
236 | 234 |
237 // from HttpBuffersImpl | 235 // from HttpBuffersImpl |
238 | 236 |
237 protected int _requestHeaderSize = 6*1024; | |
239 protected int _requestBufferSize = 16*1024; | 238 protected int _requestBufferSize = 16*1024; |
240 protected int _requestHeaderSize = 6*1024; | 239 private final int _responseHeaderSize = 6*1024; |
241 private final int _responseBufferSize = 32*1024; | 240 private final int _responseBufferSize = 32*1024; |
242 private final int _responseHeaderSize = 6*1024; | |
243 private final int _maxBuffers = 1024; | |
244 | 241 |
245 protected Buffers.Type _requestBufferType = Buffers.Type.DIRECT; | |
246 protected Buffers.Type _responseBufferType = Buffers.Type.DIRECT; | |
247 | |
248 private Buffers _requestBuffers; | |
249 private Buffers _responseBuffers; | |
250 | |
251 private void startBuffers() | |
252 throws Exception | |
253 { | |
254 _requestBuffers = new PooledBuffers(Buffers.Type.INDIRECT,_requestHeaderSize,_requestBufferType,_requestBufferSize,_maxBuffers); | |
255 _responseBuffers = new PooledBuffers(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() | 242 public final Buffers getRequestBuffers() |
267 { | 243 { |
268 return _requestBuffers; | 244 return new MyBuffers(_requestHeaderSize,_requestBufferSize); |
269 } | 245 } |
270 | 246 |
271 public final Buffers getResponseBuffers() | 247 public final Buffers getResponseBuffers() |
272 { | 248 { |
273 return _responseBuffers; | 249 return new MyBuffers(_responseHeaderSize,_responseBufferSize); |
274 } | 250 } |
275 | 251 |
252 | |
253 // my own buffers | |
254 | |
255 protected Buffer newBuffer(int size) { | |
256 return new DirectNIOBuffer(size); | |
257 } | |
258 | |
259 private class MyBuffers implements Buffers { | |
260 private final int headerSize; | |
261 private final int bufferSize; | |
262 | |
263 MyBuffers(int headerSize,int bufferSize) { | |
264 this.headerSize = headerSize; | |
265 this.bufferSize = bufferSize; | |
266 } | |
267 | |
268 public Buffer getHeader() { | |
269 return new IndirectNIOBuffer(headerSize); | |
270 } | |
271 | |
272 public Buffer getBuffer() { | |
273 return newBuffer(bufferSize); | |
274 } | |
275 | |
276 public Buffer getBuffer(int size) { | |
277 return newBuffer(size); | |
278 } | |
279 | |
280 public void returnBuffer(Buffer buffer) { | |
281 // like I care | |
282 } | |
283 } | |
276 } | 284 } |