annotate src/org/eclipse/jetty/server/Connector.java @ 893:d1c302afeeb6

remove _confidentialPort
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 06 Oct 2016 23:36:34 -0600
parents 093460816905
children c33a99fca826
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 String _confidentialScheme = HttpSchemes.HTTPS;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
66 private int _acceptors = 1;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
67 private int _acceptorPriorityOffset = 0;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
68 private boolean _useDNS;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
69 private String _hostHeader;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
70
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
71 private String _forwardedHostHeader = HttpHeaders.X_FORWARDED_HOST;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
72 private String _forwardedServerHeader = HttpHeaders.X_FORWARDED_SERVER;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
73 private String _forwardedForHeader = HttpHeaders.X_FORWARDED_FOR;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
74 private String _forwardedProtoHeader = HttpHeaders.X_FORWARDED_PROTO;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
75 private String _forwardedCipherSuiteHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
76 private String _forwardedSslSessionIdHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
77 private boolean _reuseAddress = true;
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 protected int _maxIdleTime = 200000;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
80 protected int _lowResourceMaxIdleTime = -1;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
81 protected int _soLingerTime = -1;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
82
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
83 private transient Thread[] _acceptorThreads;
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 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
86
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
87 public Connector(Server server,int port) {
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
88 this.server = server;
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
89 this.port = port;
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
90 server.connectors.add(this);
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
91 addBean(_buffers);
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
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
94 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
95 /**
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
96 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
97 public void setHost(String host)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
98 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
99 _host = host;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
100 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
101
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
102 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
103 /*
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
104 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
105 public String getHost()
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 return _host;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
108 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
109
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
110 /* ------------------------------------------------------------ */
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
111 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
112 * @return Returns the maxIdleTime.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
113 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
114 public int getMaxIdleTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
115 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
116 return _maxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
117 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
118
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
119 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
120 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
121 * 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
122 * 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
123 * <ul>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
124 * <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
125 * <li>When reading the headers and content of a request</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
126 * <li>When writing the headers and content of a response</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
127 * </ul>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
128 * 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
129 * 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
130 * 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
131 * 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
132 * <p>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
133 * 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
134 * 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
135 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
136 * @param maxIdleTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
137 * The maxIdleTime to set.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
138 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
139 public void setMaxIdleTime(int maxIdleTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
140 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
141 _maxIdleTime = maxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
142 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
143
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
144 /* ------------------------------------------------------------ */
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 * @return Returns the maxIdleTime when resources are low.
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 public int getLowResourcesMaxIdleTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
149 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
150 return _lowResourceMaxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
151 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
152
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
153 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
154 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
155 * @param maxIdleTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
156 * The maxIdleTime to set when resources are low.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
157 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
158 public void setLowResourcesMaxIdleTime(int maxIdleTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
159 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
160 _lowResourceMaxIdleTime = maxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
161 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
162
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
163 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
164 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
165 * @return Returns the maxIdleTime when resources are low.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
166 * @deprecated
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
167 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
168 @Deprecated
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
169 public final int getLowResourceMaxIdleTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
170 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
171 return getLowResourcesMaxIdleTime();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
172 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
173
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
174 /* ------------------------------------------------------------ */
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 * @param maxIdleTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
177 * The maxIdleTime to set when resources are low.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
178 * @deprecated
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
179 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
180 @Deprecated
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
181 public final void setLowResourceMaxIdleTime(int maxIdleTime)
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 setLowResourcesMaxIdleTime(maxIdleTime);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
184 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
185
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
186 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
187 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
188 * @return Returns the soLingerTime.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
189 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
190 public int getSoLingerTime()
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 return _soLingerTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
193 }
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 /* ------------------------------------------------------------ */
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 * @return Returns the number of acceptor threads.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
198 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
199 public int getAcceptors()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
200 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
201 return _acceptors;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
202 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
203
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
204 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
205 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
206 * @param acceptors
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
207 * The number of acceptor threads to set.
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 public void setAcceptors(int acceptors)
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 if (acceptors > 2 * Runtime.getRuntime().availableProcessors())
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
212 LOG.warn("Acceptors should be <=2*availableProcessors: " + this);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
213 _acceptors = acceptors;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
214 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
215
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
216 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
217 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
218 * @param soLingerTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
219 * The soLingerTime to set or -1 to disable.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
220 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
221 public void setSoLingerTime(int soLingerTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
222 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
223 _soLingerTime = soLingerTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
224 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
225
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
226 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
227 @Override
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
228 protected void doStart() throws Exception
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 // open listener port
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
231 open();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
232
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
233 super.doStart();
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 // Start selector thread
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
236 synchronized (this)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
237 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
238 _acceptorThreads = new Thread[getAcceptors()];
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
239
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
240 ThreadPoolExecutor _threadPool = server.threadPool;
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
241 for (int i = 0; i < _acceptorThreads.length; i++)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
242 _threadPool.execute(new Acceptor(i));
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
243 if (server.isLowOnThreads())
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
244 LOG.warn("insufficient threads configured for {}",this);
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 LOG.info("Started {}",this);
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
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 @Override
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
252 protected void doStop() throws Exception
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
253 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
254 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
255 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
256 close();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
257 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
258 catch (IOException e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
259 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
260 LOG.warn("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
261 }
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 super.doStop();
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 Thread[] acceptors;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
266 synchronized (this)
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 acceptors = _acceptorThreads;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
269 _acceptorThreads = null;
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 if (acceptors != null)
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 for (Thread thread : acceptors)
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 if (thread != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
276 thread.interrupt();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
277 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
278 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
279 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
280
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
281 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
282 public void join() throws InterruptedException
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
283 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
284 Thread[] threads;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
285 synchronized(this)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
286 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
287 threads=_acceptorThreads;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
288 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
289 if (threads != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
290 for (Thread thread : threads)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
291 if (thread != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
292 thread.join();
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 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
296 protected void configure(Socket socket) throws IOException
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
297 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
298 try
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 socket.setTcpNoDelay(true);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
301 if (_soLingerTime >= 0)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
302 socket.setSoLinger(true,_soLingerTime / 1000);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
303 else
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
304 socket.setSoLinger(false,0);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
305 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
306 catch (Exception e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
307 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
308 LOG.trace("",e);
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 }
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 public void customize(EndPoint endpoint, Request request) throws IOException
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
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 protected String getLeftMostFieldValue(HttpFields fields, String header)
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 if (header == null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
320 return null;
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 String headerValue = fields.getStringField(header);
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 if (headerValue == null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
325 return null;
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 int commaIndex = headerValue.indexOf(',');
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 if (commaIndex == -1)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
330 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
331 // Single value
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
332 return headerValue;
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 // The left-most value is the farthest downstream client
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
336 return headerValue.substring(0,commaIndex);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
337 }
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 void persist(EndPoint endpoint) throws IOException
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 }
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 /* ------------------------------------------------------------ */
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 * @see org.eclipse.jetty.server.Connector#getConfidentialScheme()
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 public String getConfidentialScheme()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
350 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
351 return _confidentialScheme;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
352 }
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 /*
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
356 * @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server.Request)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
357 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
358 public boolean isConfidential(Request request)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
359 {
889
5731a7707466 remove _forwarded
Franklin Schmidt <fschmidt@gmail.com>
parents: 888
diff changeset
360 return false;
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
361 }
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
362
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
363 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
364 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
365 * @param confidentialScheme
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
366 * The confidentialScheme to set.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
367 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
368 public void setConfidentialScheme(String confidentialScheme)
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 _confidentialScheme = confidentialScheme;
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
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
373 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
374 protected abstract void accept(int acceptorID) throws IOException, InterruptedException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
375
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
376 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
377 public void stopAccept(int acceptorID) throws Exception
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 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
380
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
381 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
382 public boolean getResolveNames()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
383 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
384 return _useDNS;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
385 }
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 public void setResolveNames(boolean resolve)
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 _useDNS = resolve;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
391 }
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 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
394 public String getHostHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
395 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
396 return _hostHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
397 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
398
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
399 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
400 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
401 * Set a forced valued for the host header to control what is returned by {@link ServletRequest#getServerName()} and {@link ServletRequest#getServerPort()}.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
402 * This value is only used if {@link #isForwarded()} is true.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
403 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
404 * @param hostHeader
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
405 * The value of the host header to force.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
406 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
407 public void setHostHeader(String hostHeader)
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 _hostHeader = hostHeader;
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
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 /*
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 * @see #setForwarded(boolean)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
416 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
417 public String getForwardedHostHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
418 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
419 return _forwardedHostHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
420 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
421
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
422 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
423 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
424 * @param forwardedHostHeader
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
425 * The header name for forwarded hosts (default x-forwarded-host)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
426 * @see #setForwarded(boolean)
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 public void setForwardedHostHeader(String forwardedHostHeader)
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 _forwardedHostHeader = forwardedHostHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
431 }
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 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
434 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
435 * @return the header name for forwarded server.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
436 * @see #setForwarded(boolean)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
437 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
438 public String getForwardedServerHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
439 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
440 return _forwardedServerHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
441 }
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 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
445 * @param forwardedServerHeader
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
446 * The header name for forwarded server (default x-forwarded-server)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
447 * @see #setForwarded(boolean)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
448 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
449 public void setForwardedServerHeader(String forwardedServerHeader)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
450 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
451 _forwardedServerHeader = forwardedServerHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
452 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
453
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
454 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
455 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
456 * @see #setForwarded(boolean)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
457 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
458 public String getForwardedForHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
459 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
460 return _forwardedForHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
461 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
462
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
463 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
464 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
465 * @param forwardedRemoteAddressHeader
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
466 * The header name for forwarded for (default x-forwarded-for)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
467 * @see #setForwarded(boolean)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
468 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
469 public void setForwardedForHeader(String forwardedRemoteAddressHeader)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
470 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
471 _forwardedForHeader = forwardedRemoteAddressHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
472 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
473
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
474 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
475 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
476 * Get the forwardedProtoHeader.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
477 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
478 * @return the forwardedProtoHeader (default X-Forwarded-For)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
479 * @see #setForwarded(boolean)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
480 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
481 public String getForwardedProtoHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
482 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
483 return _forwardedProtoHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
484 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
485
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
486 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
487 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
488 * Set the forwardedProtoHeader.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
489 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
490 * @param forwardedProtoHeader
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
491 * the forwardedProtoHeader to set (default X-Forwarded-For)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
492 * @see #setForwarded(boolean)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
493 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
494 public void setForwardedProtoHeader(String forwardedProtoHeader)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
495 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
496 _forwardedProtoHeader = forwardedProtoHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
497 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
498
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
499 /* ------------------------------------------------------------ */
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
500 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
501 * @return The header name holding a forwarded cipher suite (default null)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
502 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
503 public String getForwardedCipherSuiteHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
504 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
505 return _forwardedCipherSuiteHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
506 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
507
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
508 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
509 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
510 * @param forwardedCipherSuite
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
511 * The header name holding a forwarded cipher suite (default null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
512 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
513 public void setForwardedCipherSuiteHeader(String forwardedCipherSuite)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
514 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
515 _forwardedCipherSuiteHeader = forwardedCipherSuite;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
516 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
517
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
518 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
519 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
520 * @return The header name holding a forwarded SSL Session ID (default null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
521 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
522 public String getForwardedSslSessionIdHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
523 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
524 return _forwardedSslSessionIdHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
525 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
526
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
527 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
528 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
529 * @param forwardedSslSessionId
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
530 * The header name holding a forwarded SSL Session ID (default null)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
531 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
532 public void setForwardedSslSessionIdHeader(String forwardedSslSessionId)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
533 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
534 _forwardedSslSessionIdHeader = forwardedSslSessionId;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
535 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
536
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
537 public int getRequestBufferSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
538 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
539 return _buffers.getRequestBufferSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
540 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
541
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
542 public void setRequestBufferSize(int requestBufferSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
543 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
544 _buffers.setRequestBufferSize(requestBufferSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
545 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
546
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
547 public int getRequestHeaderSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
548 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
549 return _buffers.getRequestHeaderSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
550 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
551
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
552 public void setRequestHeaderSize(int requestHeaderSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
553 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
554 _buffers.setRequestHeaderSize(requestHeaderSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
555 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
556
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
557 public int getResponseBufferSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
558 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
559 return _buffers.getResponseBufferSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
560 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
561
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
562 public void setResponseBufferSize(int responseBufferSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
563 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
564 _buffers.setResponseBufferSize(responseBufferSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
565 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
566
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
567 public int getResponseHeaderSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
568 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
569 return _buffers.getResponseHeaderSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
570 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
571
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
572 public void setResponseHeaderSize(int responseHeaderSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
573 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
574 _buffers.setResponseHeaderSize(responseHeaderSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
575 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
576
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
577 public Type getRequestBufferType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
578 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
579 return _buffers.getRequestBufferType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
580 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
581
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
582 public Type getRequestHeaderType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
583 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
584 return _buffers.getRequestHeaderType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
585 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
586
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
587 public Type getResponseBufferType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
588 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
589 return _buffers.getResponseBufferType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
590 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
591
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
592 public Type getResponseHeaderType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
593 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
594 return _buffers.getResponseHeaderType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
595 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
596
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
597 public void setRequestBuffers(Buffers requestBuffers)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
598 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
599 _buffers.setRequestBuffers(requestBuffers);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
600 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
601
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
602 public void setResponseBuffers(Buffers responseBuffers)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
603 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
604 _buffers.setResponseBuffers(responseBuffers);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
605 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
606
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
607 public Buffers getRequestBuffers()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
608 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
609 return _buffers.getRequestBuffers();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
610 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
611
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
612 public Buffers getResponseBuffers()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
613 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
614 return _buffers.getResponseBuffers();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
615 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
616
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
617 public int getMaxBuffers()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
618 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
619 return _buffers.getMaxBuffers();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
620 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
621
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
622 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
623 @Override
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
624 public String toString()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
625 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
626 return String.format("%s@%s:%d",
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
627 getClass().getSimpleName(),
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
628 getHost()==null?"0.0.0.0":getHost(),
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
629 getLocalPort()<=0 ? port : getLocalPort());
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
630 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
631
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
632 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
633 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
634 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
635 private class Acceptor implements Runnable
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
636 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
637 int _acceptor = 0;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
638
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
639 Acceptor(int id)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
640 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
641 _acceptor = id;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
642 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
643
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
644 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
645 public void run()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
646 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
647 Thread current = Thread.currentThread();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
648 String name;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
649 synchronized (Connector.this)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
650 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
651 if (_acceptorThreads == null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
652 return;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
653
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
654 _acceptorThreads[_acceptor] = current;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
655 name = _acceptorThreads[_acceptor].getName();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
656 current.setName(name + " Acceptor" + _acceptor + " " + Connector.this);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
657 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
658 int old_priority = current.getPriority();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
659
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
660 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
661 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
662 current.setPriority(old_priority - _acceptorPriorityOffset);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
663 while (isRunning() && getConnection() != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
664 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
665 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
666 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
667 accept(_acceptor);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
668 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
669 catch (EofException e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
670 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
671 LOG.trace("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
672 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
673 catch (IOException e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
674 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
675 LOG.trace("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
676 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
677 catch (InterruptedException x)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
678 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
679 // Connector has been stopped
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
680 LOG.trace("",x);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
681 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
682 catch (Throwable e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
683 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
684 LOG.warn("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
685 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
686 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
687 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
688 finally
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
689 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
690 current.setPriority(old_priority);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
691 current.setName(name);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
692
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
693 synchronized (Connector.this)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
694 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
695 if (_acceptorThreads != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
696 _acceptorThreads[_acceptor] = null;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
697 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
698 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
699 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
700 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
701
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
702 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
703 public String getName()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
704 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
705 if (_name == null)
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
706 _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
707 return _name;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
708 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
709
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
710 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
711 public void setName(String name)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
712 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
713 _name = name;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
714 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
715
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
716 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
717 protected void connectionOpened(Connection connection)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
718 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
719 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
720
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
721 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
722 protected void connectionUpgraded(Connection oldConnection, Connection newConnection)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
723 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
724 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
725
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
726 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
727 protected void connectionClosed(Connection connection)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
728 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
729 connection.onClose();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
730 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
731
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
732 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
733 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
734 * @return the acceptorPriority
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
735 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
736 public int getAcceptorPriorityOffset()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
737 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
738 return _acceptorPriorityOffset;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
739 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
740
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
741 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
742 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
743 * Set the priority offset of the acceptor threads. The priority is adjusted by this amount (default 0) to either favour the acceptance of new threads and
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
744 * newly active connections or to favour the handling of already dispatched connections.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
745 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
746 * @param offset
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
747 * the amount to alter the priority of the acceptor threads.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
748 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
749 public void setAcceptorPriorityOffset(int offset)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
750 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
751 _acceptorPriorityOffset = offset;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
752 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
753
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
754 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
755 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
756 * @return True if the the server socket will be opened in SO_REUSEADDR mode.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
757 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
758 public boolean getReuseAddress()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
759 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
760 return _reuseAddress;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
761 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
762
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
763 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
764 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
765 * @param reuseAddress
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
766 * True if the the server socket will be opened in SO_REUSEADDR mode.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
767 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
768 public void setReuseAddress(boolean reuseAddress)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
769 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
770 _reuseAddress = reuseAddress;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
771 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
772
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
773 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
774 public final boolean isLowResources()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
775 {
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
776 return server.isLowOnThreads();
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
777 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
778
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
779 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
780 private void updateNotEqual(AtomicLong valueHolder, long compare, long value)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
781 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
782 long oldValue = valueHolder.get();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
783 while (compare != oldValue)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
784 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
785 if (valueHolder.compareAndSet(oldValue,value))
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
786 break;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
787 oldValue = valueHolder.get();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
788 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
789 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
790
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
791 // from old interface
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
792 public abstract void open() throws IOException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
793 public abstract void close() throws IOException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
794 public abstract int getLocalPort();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
795 public abstract Object getConnection();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
796 }