annotate src/org/eclipse/jetty/server/Connector.java @ 906:eaf271fb747f

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 07 Oct 2016 03:59:44 -0600
parents e7175965e6cf
children bc4e299de953
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 // ------------------------------------------------------------------------
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 // All rights reserved. This program and the accompanying materials
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 // are made available under the terms of the Eclipse Public License v1.0
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 // and Apache License v2.0 which accompanies this distribution.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 // The Eclipse Public License is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 // http://www.eclipse.org/legal/epl-v10.html
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 // The Apache License v2.0 is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 // http://www.opensource.org/licenses/apache2.0.php
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 // You may elect to redistribute this code under either of these licenses.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 package org.eclipse.jetty.server;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 import java.io.IOException;
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
22 import java.net.InetAddress;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
23 import java.net.Socket;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
24 import java.net.UnknownHostException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
25 import java.util.concurrent.ThreadPoolExecutor;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
26 import java.util.concurrent.atomic.AtomicLong;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
28 import javax.servlet.ServletRequest;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
30 import org.eclipse.jetty.http.HttpBuffers;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
31 import org.eclipse.jetty.http.HttpBuffersImpl;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
32 import org.eclipse.jetty.http.HttpFields;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
33 import org.eclipse.jetty.http.HttpHeaders;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
34 import org.eclipse.jetty.http.HttpSchemes;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
35 import org.eclipse.jetty.io.Buffers;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
36 import org.eclipse.jetty.io.Buffers.Type;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
37 import org.eclipse.jetty.io.Connection;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
38 import org.eclipse.jetty.io.EndPoint;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
39 import org.eclipse.jetty.io.EofException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
40 import org.eclipse.jetty.util.component.AggregateLifeCycle;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
41 import org.eclipse.jetty.util.component.Dumpable;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
42 import org.slf4j.Logger;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
43 import org.slf4j.LoggerFactory;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
44
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
46 * Abstract Connector implementation. This abstract implementation of the Connector interface provides:
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
47 * <ul>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
48 * <li>AbstractLifeCycle implementation</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
49 * <li>Implementations for connector getters and setters</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
50 * <li>Buffer management</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
51 * <li>Socket configuration</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
52 * <li>Base acceptor thread</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
53 * <li>Optional reverse proxy headers checking</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
54 * </ul>
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
56 public abstract class Connector extends AggregateLifeCycle implements HttpBuffers, Dumpable
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
57 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
58 private static final Logger LOG = LoggerFactory.getLogger(Connector.class);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
59
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
60 private String _name;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
62 public final Server server;
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
63 private String _host;
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
64 public final int port;
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
65 private int _acceptors = 1;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
66
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
67 protected int _maxIdleTime = 200000;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
68 protected int _lowResourceMaxIdleTime = -1;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
69 protected int _soLingerTime = -1;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
70
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
71 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
72
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
73 public Connector(Server server,int port) {
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
74 this.server = server;
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
75 this.port = port;
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
76 server.connectors.add(this);
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
77 addBean(_buffers);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
78 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
79
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
80 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
81 /**
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
82 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
83 public void setHost(String host)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
84 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
85 _host = host;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
86 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
87
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
88 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
89 /*
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
90 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
91 public String getHost()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
92 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
93 return _host;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
94 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
95
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
96 /* ------------------------------------------------------------ */
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
97 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
98 * @return Returns the maxIdleTime.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
99 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
100 public int getMaxIdleTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
101 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
102 return _maxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
103 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
104
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
105 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
106 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
107 * Set the maximum Idle time for a connection, which roughly translates to the {@link Socket#setSoTimeout(int)} call, although with NIO implementations
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
108 * other mechanisms may be used to implement the timeout. The max idle time is applied:
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
109 * <ul>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
110 * <li>When waiting for a new request to be received on a connection</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
111 * <li>When reading the headers and content of a request</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
112 * <li>When writing the headers and content of a response</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
113 * </ul>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
114 * Jetty interprets this value as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
115 * timeout (if implemented by jetty) is reset. However, in many instances, the reading/writing is delegated to the JVM, and the semantic is more strictly
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
116 * enforced as the maximum time a single read/write operation can take. Note, that as Jetty supports writes of memory mapped file buffers, then a write may
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
117 * take many 10s of seconds for large content written to a slow device.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
118 * <p>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
119 * Previously, Jetty supported separate idle timeouts and IO operation timeouts, however the expense of changing the value of soTimeout was significant, so
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
120 * these timeouts were merged. With the advent of NIO, it may be possible to again differentiate these values (if there is demand).
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
121 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
122 * @param maxIdleTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
123 * The maxIdleTime to set.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
124 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
125 public void setMaxIdleTime(int maxIdleTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
126 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
127 _maxIdleTime = maxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
128 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
129
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
130 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
131 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
132 * @return Returns the maxIdleTime when resources are low.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
133 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
134 public int getLowResourcesMaxIdleTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
135 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
136 return _lowResourceMaxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
137 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
138
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
139 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
140 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
141 * @param maxIdleTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
142 * The maxIdleTime to set when resources are low.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
143 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
144 public void setLowResourcesMaxIdleTime(int maxIdleTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
145 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
146 _lowResourceMaxIdleTime = maxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
147 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
148
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
149 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
150 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
151 * @return Returns the maxIdleTime when resources are low.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
152 * @deprecated
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
153 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
154 @Deprecated
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
155 public final int getLowResourceMaxIdleTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
156 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
157 return getLowResourcesMaxIdleTime();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
158 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
159
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
160 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
161 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
162 * @param maxIdleTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
163 * The maxIdleTime to set when resources are low.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
164 * @deprecated
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
165 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
166 @Deprecated
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
167 public final void setLowResourceMaxIdleTime(int maxIdleTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
168 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
169 setLowResourcesMaxIdleTime(maxIdleTime);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
170 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
171
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
172 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
173 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
174 * @return Returns the soLingerTime.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
175 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
176 public int getSoLingerTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
177 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
178 return _soLingerTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
179 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
180
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
181 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
182 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
183 * @return Returns the number of acceptor threads.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
184 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
185 public int getAcceptors()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
186 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
187 return _acceptors;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
188 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
189
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
190 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
191 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
192 * @param acceptors
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
193 * The number of acceptor threads to set.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
194 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
195 public void setAcceptors(int acceptors)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
196 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
197 if (acceptors > 2 * Runtime.getRuntime().availableProcessors())
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
198 LOG.warn("Acceptors should be <=2*availableProcessors: " + this);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
199 _acceptors = acceptors;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
200 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
201
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
202 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
203 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
204 * @param soLingerTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
205 * The soLingerTime to set or -1 to disable.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
206 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
207 public void setSoLingerTime(int soLingerTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
208 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
209 _soLingerTime = soLingerTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
210 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
211
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
212 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
213 @Override
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
214 protected void doStart() throws Exception
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
215 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
216 // open listener port
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
217 open();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
218
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
219 super.doStart();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
220
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
221 // Start selector thread
905
e7175965e6cf remove Connector._acceptorThreads
Franklin Schmidt <fschmidt@gmail.com>
parents: 904
diff changeset
222 ThreadPoolExecutor _threadPool = server.threadPool;
e7175965e6cf remove Connector._acceptorThreads
Franklin Schmidt <fschmidt@gmail.com>
parents: 904
diff changeset
223 for (int i = 0; i < _acceptors; i++)
906
Franklin Schmidt <fschmidt@gmail.com>
parents: 905
diff changeset
224 _threadPool.execute(new Acceptor());
905
e7175965e6cf remove Connector._acceptorThreads
Franklin Schmidt <fschmidt@gmail.com>
parents: 904
diff changeset
225 if (server.isLowOnThreads())
e7175965e6cf remove Connector._acceptorThreads
Franklin Schmidt <fschmidt@gmail.com>
parents: 904
diff changeset
226 LOG.warn("insufficient threads configured for {}",this);
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
227
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
228 LOG.info("Started {}",this);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
229 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
230
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
231 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
232 @Override
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
233 protected void doStop() throws Exception
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
234 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
235 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
236 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
237 close();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
238 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
239 catch (IOException e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
240 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
241 LOG.warn("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
242 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
243
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
244 super.doStop();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
245 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
246
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
247
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
248 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
249 protected void configure(Socket socket) throws IOException
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
250 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
251 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
252 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
253 socket.setTcpNoDelay(true);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
254 if (_soLingerTime >= 0)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
255 socket.setSoLinger(true,_soLingerTime / 1000);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
256 else
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
257 socket.setSoLinger(false,0);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
258 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
259 catch (Exception e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
260 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
261 LOG.trace("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
262 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
263 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
264
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
265 public void customize(EndPoint endpoint, Request request) throws IOException
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
266 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
267 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
268
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
269 public void persist(EndPoint endpoint) throws IOException
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
270 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
271 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
272
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
273 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
274 /*
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
275 * @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server.Request)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
276 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
277 public boolean isConfidential(Request request)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
278 {
889
5731a7707466 remove _forwarded
Franklin Schmidt <fschmidt@gmail.com>
parents: 888
diff changeset
279 return false;
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
280 }
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
281
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
282 /* ------------------------------------------------------------ */
906
Franklin Schmidt <fschmidt@gmail.com>
parents: 905
diff changeset
283 protected abstract void accept() throws IOException, InterruptedException;
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
284
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
285 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
286 public void stopAccept(int acceptorID) throws Exception
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
287 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
288 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
289
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
290 public int getRequestBufferSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
291 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
292 return _buffers.getRequestBufferSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
293 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
294
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
295 public void setRequestBufferSize(int requestBufferSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
296 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
297 _buffers.setRequestBufferSize(requestBufferSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
298 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
299
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
300 public int getRequestHeaderSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
301 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
302 return _buffers.getRequestHeaderSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
303 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
304
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
305 public void setRequestHeaderSize(int requestHeaderSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
306 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
307 _buffers.setRequestHeaderSize(requestHeaderSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
308 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
309
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
310 public int getResponseBufferSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
311 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
312 return _buffers.getResponseBufferSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
313 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
314
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
315 public void setResponseBufferSize(int responseBufferSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
316 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
317 _buffers.setResponseBufferSize(responseBufferSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
318 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
319
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
320 public int getResponseHeaderSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
321 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
322 return _buffers.getResponseHeaderSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
323 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
324
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
325 public void setResponseHeaderSize(int responseHeaderSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
326 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
327 _buffers.setResponseHeaderSize(responseHeaderSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
328 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
329
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
330 public Type getRequestBufferType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
331 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
332 return _buffers.getRequestBufferType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
333 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
334
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
335 public Type getRequestHeaderType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
336 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
337 return _buffers.getRequestHeaderType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
338 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
339
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
340 public Type getResponseBufferType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
341 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
342 return _buffers.getResponseBufferType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
343 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
344
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
345 public Type getResponseHeaderType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
346 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
347 return _buffers.getResponseHeaderType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
348 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
349
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
350 public void setRequestBuffers(Buffers requestBuffers)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
351 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
352 _buffers.setRequestBuffers(requestBuffers);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
353 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
354
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
355 public void setResponseBuffers(Buffers responseBuffers)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
356 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
357 _buffers.setResponseBuffers(responseBuffers);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
358 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
359
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
360 public Buffers getRequestBuffers()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
361 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
362 return _buffers.getRequestBuffers();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
363 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
364
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
365 public Buffers getResponseBuffers()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
366 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
367 return _buffers.getResponseBuffers();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
368 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
369
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
370 public int getMaxBuffers()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
371 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
372 return _buffers.getMaxBuffers();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
373 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
374
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
375 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
376 @Override
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
377 public String toString()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
378 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
379 return String.format("%s@%s:%d",
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
380 getClass().getSimpleName(),
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
381 getHost()==null?"0.0.0.0":getHost(),
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
382 getLocalPort()<=0 ? port : getLocalPort());
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
383 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
384
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
385 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
386 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
387 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
388 private class Acceptor implements Runnable
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
389 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
390
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
391 public void run()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
392 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
393 Thread current = Thread.currentThread();
905
e7175965e6cf remove Connector._acceptorThreads
Franklin Schmidt <fschmidt@gmail.com>
parents: 904
diff changeset
394 String name = current.getName();
906
Franklin Schmidt <fschmidt@gmail.com>
parents: 905
diff changeset
395 current.setName(name + " Acceptor" + " " + Connector.this);
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
396
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
397 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
398 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
399 while (isRunning() && getConnection() != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
400 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
401 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
402 {
906
Franklin Schmidt <fschmidt@gmail.com>
parents: 905
diff changeset
403 accept();
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
404 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
405 catch (EofException e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
406 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
407 LOG.trace("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
408 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
409 catch (IOException e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
410 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
411 LOG.trace("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
412 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
413 catch (InterruptedException x)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
414 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
415 // Connector has been stopped
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
416 LOG.trace("",x);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
417 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
418 catch (Throwable e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
419 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
420 LOG.warn("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
421 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
422 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
423 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
424 finally
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
425 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
426 current.setName(name);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
427 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
428 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
429 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
430
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
431 public String getName()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
432 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
433 if (_name == null)
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
434 _name = (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?port:getLocalPort());
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
435 return _name;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
436 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
437
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
438 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
439 public final boolean isLowResources()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
440 {
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
441 return server.isLowOnThreads();
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
442 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
443
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
444 // from old interface
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
445 public abstract void open() throws IOException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
446 public abstract void close() throws IOException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
447 public abstract int getLocalPort();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
448 public abstract Object getConnection();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
449 }