comparison src/org/eclipse/jetty/http/HttpBuffersImpl.java @ 868:688b875e18ba

remove ThreadLocalBuffers
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 03 Oct 2016 19:29:34 -0600
parents 3428c60d7cfc
children 0e96ce3db20a
comparison
equal deleted inserted replaced
867:4f5547d29192 868:688b875e18ba
25 /* ------------------------------------------------------------ */ 25 /* ------------------------------------------------------------ */
26 /** Abstract Buffer pool. 26 /** Abstract Buffer pool.
27 * simple unbounded pool of buffers for header, request and response sizes. 27 * simple unbounded pool of buffers for header, request and response sizes.
28 * 28 *
29 */ 29 */
30 public class HttpBuffersImpl extends AbstractLifeCycle implements HttpBuffers 30 public final class HttpBuffersImpl extends AbstractLifeCycle implements HttpBuffers
31 { 31 {
32 private int _requestBufferSize=16*1024; 32 private int _requestBufferSize=16*1024;
33 private int _requestHeaderSize=6*1024; 33 private int _requestHeaderSize=6*1024;
34 private int _responseBufferSize=32*1024; 34 private int _responseBufferSize=32*1024;
35 private int _responseHeaderSize=6*1024; 35 private int _responseHeaderSize=6*1024;
36 private int _maxBuffers=1024; 36 private final int _maxBuffers=1024;
37 37
38 private Buffers.Type _requestBufferType=Buffers.Type.BYTE_ARRAY; 38 private Buffers.Type _requestBufferType=Buffers.Type.BYTE_ARRAY;
39 private Buffers.Type _requestHeaderType=Buffers.Type.BYTE_ARRAY; 39 private Buffers.Type _requestHeaderType=Buffers.Type.BYTE_ARRAY;
40 private Buffers.Type _responseBufferType=Buffers.Type.BYTE_ARRAY; 40 private Buffers.Type _responseBufferType=Buffers.Type.BYTE_ARRAY;
41 private Buffers.Type _responseHeaderType=Buffers.Type.BYTE_ARRAY; 41 private Buffers.Type _responseHeaderType=Buffers.Type.BYTE_ARRAY;
42 42
43 private Buffers _requestBuffers; 43 private Buffers _requestBuffers;
44 private Buffers _responseBuffers; 44 private Buffers _responseBuffers;
45 45
46 46
47 public HttpBuffersImpl() 47 public HttpBuffersImpl()
48 { 48 {
49 super(); 49 super();
50 } 50 }
51 51
52 /** 52 /**
53 * @return the requestBufferSize 53 * @return the requestBufferSize
54 */ 54 */
55 public int getRequestBufferSize() 55 public int getRequestBufferSize()
56 { 56 {
57 return _requestBufferSize; 57 return _requestBufferSize;
58 } 58 }
59 59
60 /** 60 /**
61 * @param requestBufferSize the requestBufferSize to set 61 * @param requestBufferSize the requestBufferSize to set
62 */ 62 */
63 public void setRequestBufferSize(int requestBufferSize) 63 public void setRequestBufferSize(int requestBufferSize)
64 { 64 {
65 _requestBufferSize = requestBufferSize; 65 _requestBufferSize = requestBufferSize;
66 } 66 }
67 67
68 /** 68 /**
69 * @return the requestHeaderSize 69 * @return the requestHeaderSize
70 */ 70 */
71 public int getRequestHeaderSize() 71 public int getRequestHeaderSize()
72 { 72 {
73 return _requestHeaderSize; 73 return _requestHeaderSize;
74 } 74 }
75 75
76 /** 76 /**
77 * @param requestHeaderSize the requestHeaderSize to set 77 * @param requestHeaderSize the requestHeaderSize to set
78 */ 78 */
79 public void setRequestHeaderSize(int requestHeaderSize) 79 public void setRequestHeaderSize(int requestHeaderSize)
80 { 80 {
81 _requestHeaderSize = requestHeaderSize; 81 _requestHeaderSize = requestHeaderSize;
82 } 82 }
83 83
84 /** 84 /**
85 * @return the responseBufferSize 85 * @return the responseBufferSize
86 */ 86 */
87 public int getResponseBufferSize() 87 public int getResponseBufferSize()
88 { 88 {
89 return _responseBufferSize; 89 return _responseBufferSize;
90 } 90 }
91 91
92 /** 92 /**
93 * @param responseBufferSize the responseBufferSize to set 93 * @param responseBufferSize the responseBufferSize to set
94 */ 94 */
95 public void setResponseBufferSize(int responseBufferSize) 95 public void setResponseBufferSize(int responseBufferSize)
96 { 96 {
97 _responseBufferSize = responseBufferSize; 97 _responseBufferSize = responseBufferSize;
98 } 98 }
99 99
100 /** 100 /**
101 * @return the responseHeaderSize 101 * @return the responseHeaderSize
102 */ 102 */
103 public int getResponseHeaderSize() 103 public int getResponseHeaderSize()
104 { 104 {
105 return _responseHeaderSize; 105 return _responseHeaderSize;
106 } 106 }
107 107
108 /** 108 /**
109 * @param responseHeaderSize the responseHeaderSize to set 109 * @param responseHeaderSize the responseHeaderSize to set
110 */ 110 */
111 public void setResponseHeaderSize(int responseHeaderSize) 111 public void setResponseHeaderSize(int responseHeaderSize)
112 { 112 {
113 _responseHeaderSize = responseHeaderSize; 113 _responseHeaderSize = responseHeaderSize;
114 } 114 }
115 115
116 /** 116 /**
117 * @return the requestBufferType 117 * @return the requestBufferType
118 */ 118 */
119 public Buffers.Type getRequestBufferType() 119 public Buffers.Type getRequestBufferType()
120 { 120 {
121 return _requestBufferType; 121 return _requestBufferType;
122 } 122 }
123 123
124 /** 124 /**
125 * @param requestBufferType the requestBufferType to set 125 * @param requestBufferType the requestBufferType to set
126 */ 126 */
127 public void setRequestBufferType(Buffers.Type requestBufferType) 127 public void setRequestBufferType(Buffers.Type requestBufferType)
128 { 128 {
129 _requestBufferType = requestBufferType; 129 _requestBufferType = requestBufferType;
130 } 130 }
131 131
132 /** 132 /**
133 * @return the requestHeaderType 133 * @return the requestHeaderType
134 */ 134 */
135 public Buffers.Type getRequestHeaderType() 135 public Buffers.Type getRequestHeaderType()
136 { 136 {
137 return _requestHeaderType; 137 return _requestHeaderType;
138 } 138 }
139 139
140 /** 140 /**
141 * @param requestHeaderType the requestHeaderType to set 141 * @param requestHeaderType the requestHeaderType to set
142 */ 142 */
143 public void setRequestHeaderType(Buffers.Type requestHeaderType) 143 public void setRequestHeaderType(Buffers.Type requestHeaderType)
144 { 144 {
145 _requestHeaderType = requestHeaderType; 145 _requestHeaderType = requestHeaderType;
146 } 146 }
147 147
148 /** 148 /**
149 * @return the responseBufferType 149 * @return the responseBufferType
150 */ 150 */
151 public Buffers.Type getResponseBufferType() 151 public Buffers.Type getResponseBufferType()
152 { 152 {
153 return _responseBufferType; 153 return _responseBufferType;
154 } 154 }
155 155
156 /** 156 /**
157 * @param responseBufferType the responseBufferType to set 157 * @param responseBufferType the responseBufferType to set
158 */ 158 */
159 public void setResponseBufferType(Buffers.Type responseBufferType) 159 public void setResponseBufferType(Buffers.Type responseBufferType)
160 { 160 {
161 _responseBufferType = responseBufferType; 161 _responseBufferType = responseBufferType;
162 } 162 }
163 163
164 /** 164 /**
165 * @return the responseHeaderType 165 * @return the responseHeaderType
166 */ 166 */
167 public Buffers.Type getResponseHeaderType() 167 public Buffers.Type getResponseHeaderType()
168 { 168 {
169 return _responseHeaderType; 169 return _responseHeaderType;
170 } 170 }
171 171
172 /** 172 /**
173 * @param responseHeaderType the responseHeaderType to set 173 * @param responseHeaderType the responseHeaderType to set
174 */ 174 */
175 public void setResponseHeaderType(Buffers.Type responseHeaderType) 175 public void setResponseHeaderType(Buffers.Type responseHeaderType)
176 { 176 {
177 _responseHeaderType = responseHeaderType; 177 _responseHeaderType = responseHeaderType;
178 } 178 }
179 179
180 /** 180 /**
181 * @param requestBuffers the requestBuffers to set 181 * @param requestBuffers the requestBuffers to set
182 */ 182 */
183 public void setRequestBuffers(Buffers requestBuffers) 183 public void setRequestBuffers(Buffers requestBuffers)
184 { 184 {
185 _requestBuffers = requestBuffers; 185 _requestBuffers = requestBuffers;
186 } 186 }
187 187
188 /** 188 /**
189 * @param responseBuffers the responseBuffers to set 189 * @param responseBuffers the responseBuffers to set
190 */ 190 */
191 public void setResponseBuffers(Buffers responseBuffers) 191 public void setResponseBuffers(Buffers responseBuffers)
192 { 192 {
193 _responseBuffers = responseBuffers; 193 _responseBuffers = responseBuffers;
194 } 194 }
195 195
196 @Override 196 @Override
197 protected void doStart() 197 protected void doStart()
198 throws Exception 198 throws Exception
199 { 199 {
200 _requestBuffers=BuffersFactory.newBuffers(_requestHeaderType,_requestHeaderSize,_requestBufferType,_requestBufferSize,_requestBufferType,getMaxBuffers()); 200 _requestBuffers=BuffersFactory.newBuffers(_requestHeaderType,_requestHeaderSize,_requestBufferType,_requestBufferSize,_requestBufferType,getMaxBuffers());
201 _responseBuffers=BuffersFactory.newBuffers(_responseHeaderType,_responseHeaderSize,_responseBufferType,_responseBufferSize,_responseBufferType,getMaxBuffers()); 201 _responseBuffers=BuffersFactory.newBuffers(_responseHeaderType,_responseHeaderSize,_responseBufferType,_responseBufferSize,_responseBufferType,getMaxBuffers());
202 super.doStart(); 202 super.doStart();
203 } 203 }
204 204
205 @Override 205 @Override
206 protected void doStop() 206 protected void doStop()
207 throws Exception 207 throws Exception
208 { 208 {
209 _requestBuffers=null; 209 _requestBuffers=null;
210 _responseBuffers=null; 210 _responseBuffers=null;
211 } 211 }
212 212
213 public Buffers getRequestBuffers() 213 public Buffers getRequestBuffers()
214 { 214 {
215 return _requestBuffers; 215 return _requestBuffers;
216 } 216 }
217 217
218 218
219 public Buffers getResponseBuffers() 219 public Buffers getResponseBuffers()
220 { 220 {
221 return _responseBuffers; 221 return _responseBuffers;
222 } 222 }
223 223
224 public void setMaxBuffers(int maxBuffers) 224 public int getMaxBuffers()
225 { 225 {
226 _maxBuffers = maxBuffers; 226 return _maxBuffers;
227 } 227 }
228 228
229 public int getMaxBuffers() 229 public String toString()
230 { 230 {
231 return _maxBuffers; 231 return _requestBuffers+"/"+_responseBuffers;
232 } 232 }
233
234 public String toString()
235 {
236 return _requestBuffers+"/"+_responseBuffers;
237 }
238 } 233 }