annotate src/org/eclipse/jetty/server/AbstractConnector.java @ 864:e21ca9878a10

simplify ThreadPool use
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 02 Oct 2016 16:17:38 -0600
parents 8e9db0bbf4f9
children 6b210bb66c63
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;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 import java.net.InetAddress;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 import java.net.Socket;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 import java.net.UnknownHostException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 import java.util.concurrent.atomic.AtomicLong;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 import javax.servlet.ServletRequest;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 import org.eclipse.jetty.http.HttpBuffers;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 import org.eclipse.jetty.http.HttpBuffersImpl;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 import org.eclipse.jetty.http.HttpFields;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 import org.eclipse.jetty.http.HttpHeaders;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 import org.eclipse.jetty.http.HttpSchemes;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 import org.eclipse.jetty.io.Buffers;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 import org.eclipse.jetty.io.Buffers.Type;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 import org.eclipse.jetty.io.Connection;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 import org.eclipse.jetty.io.EndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 import org.eclipse.jetty.io.EofException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 import org.eclipse.jetty.util.component.AggregateLifeCycle;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 import org.eclipse.jetty.util.component.Dumpable;
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 818
diff changeset
41 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 818
diff changeset
42 import org.slf4j.LoggerFactory;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 import org.eclipse.jetty.util.thread.ThreadPool;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 /**
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 * Abstract Connector implementation. This abstract implementation of the Connector interface provides:
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 * <ul>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 * <li>AbstractLifeCycle implementation</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 * <li>Implementations for connector getters and setters</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 * <li>Buffer management</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 * <li>Socket configuration</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 * <li>Base acceptor thread</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 * <li>Optional reverse proxy headers checking</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 * </ul>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 public abstract class AbstractConnector extends AggregateLifeCycle implements HttpBuffers, Connector, Dumpable
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57 {
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
58 private static final Logger LOG = LoggerFactory.getLogger(AbstractConnector.class);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
59
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
60 private String _name;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
62 private Server _server;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
63 private String _host;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
64 private int _port = 0;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
65 private String _integralScheme = HttpSchemes.HTTPS;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
66 private int _integralPort = 0;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
67 private String _confidentialScheme = HttpSchemes.HTTPS;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
68 private int _confidentialPort = 0;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
69 private int _acceptQueueSize = 0;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
70 private int _acceptors = 1;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
71 private int _acceptorPriorityOffset = 0;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
72 private boolean _useDNS;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
73 private boolean _forwarded;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
74 private String _hostHeader;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
75
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
76 private String _forwardedHostHeader = HttpHeaders.X_FORWARDED_HOST;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
77 private String _forwardedServerHeader = HttpHeaders.X_FORWARDED_SERVER;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
78 private String _forwardedForHeader = HttpHeaders.X_FORWARDED_FOR;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
79 private String _forwardedProtoHeader = HttpHeaders.X_FORWARDED_PROTO;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
80 private String _forwardedCipherSuiteHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
81 private String _forwardedSslSessionIdHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
82 private boolean _reuseAddress = true;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
83
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
84 protected int _maxIdleTime = 200000;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
85 protected int _lowResourceMaxIdleTime = -1;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
86 protected int _soLingerTime = -1;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
87
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
88 private transient Thread[] _acceptorThreads;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
89
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
90 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
91
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
92 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
93 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
94 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
95 public AbstractConnector()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
96 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
97 addBean(_buffers);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
98 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
99
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
100 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
101 /*
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
102 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
103 public Server getServer()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
104 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
105 return _server;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
106 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
107
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
108 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
109 public void setServer(Server server)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
110 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
111 _server = server;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
112 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
113
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
114 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
115 public ThreadPool getThreadPool()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
116 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
117 return _server.getThreadPool();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
118 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
119
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
120 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
121 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
122 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
123 public void setHost(String host)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
124 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
125 _host = host;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
126 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
127
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
128 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
129 /*
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
130 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
131 public String getHost()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
132 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
133 return _host;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
134 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
135
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
136 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
137 public void setPort(int port)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
138 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
139 _port = port;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
140 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
141
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
142 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
143 public int getPort()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
144 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
145 return _port;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
146 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
147
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
148 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
149 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
150 * @return Returns the maxIdleTime.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
151 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
152 public int getMaxIdleTime()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
153 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
154 return _maxIdleTime;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
155 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
156
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
157 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
158 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
159 * Set the maximum Idle time for a connection, which roughly translates to the {@link Socket#setSoTimeout(int)} call, although with NIO implementations
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
160 * other mechanisms may be used to implement the timeout. The max idle time is applied:
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
161 * <ul>
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
162 * <li>When waiting for a new request to be received on a connection</li>
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
163 * <li>When reading the headers and content of a request</li>
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
164 * <li>When writing the headers and content of a response</li>
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
165 * </ul>
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
166 * 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
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
167 * 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
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
168 * 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
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
169 * take many 10s of seconds for large content written to a slow device.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
170 * <p>
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
171 * Previously, Jetty supported separate idle timeouts and IO operation timeouts, however the expense of changing the value of soTimeout was significant, so
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
172 * these timeouts were merged. With the advent of NIO, it may be possible to again differentiate these values (if there is demand).
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
173 *
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
174 * @param maxIdleTime
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
175 * The maxIdleTime to set.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
176 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
177 public void setMaxIdleTime(int maxIdleTime)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
178 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
179 _maxIdleTime = maxIdleTime;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
180 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
181
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
182 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
183 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
184 * @return Returns the maxIdleTime when resources are low.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
185 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
186 public int getLowResourcesMaxIdleTime()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
187 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
188 return _lowResourceMaxIdleTime;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
189 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
190
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
191 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
192 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
193 * @param maxIdleTime
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
194 * The maxIdleTime to set when resources are low.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
195 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
196 public void setLowResourcesMaxIdleTime(int maxIdleTime)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
197 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
198 _lowResourceMaxIdleTime = maxIdleTime;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
199 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
200
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
201 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
202 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
203 * @return Returns the maxIdleTime when resources are low.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
204 * @deprecated
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
205 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
206 @Deprecated
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
207 public final int getLowResourceMaxIdleTime()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
208 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
209 return getLowResourcesMaxIdleTime();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
210 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
211
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
212 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
213 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
214 * @param maxIdleTime
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
215 * The maxIdleTime to set when resources are low.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
216 * @deprecated
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
217 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
218 @Deprecated
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
219 public final void setLowResourceMaxIdleTime(int maxIdleTime)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
220 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
221 setLowResourcesMaxIdleTime(maxIdleTime);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
222 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
223
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
224 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
225 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
226 * @return Returns the soLingerTime.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
227 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
228 public int getSoLingerTime()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
229 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
230 return _soLingerTime;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
231 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
232
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
233 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
234 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
235 * @return Returns the acceptQueueSize.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
236 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
237 public int getAcceptQueueSize()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
238 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
239 return _acceptQueueSize;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
240 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
241
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
242 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
243 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
244 * @param acceptQueueSize
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
245 * The acceptQueueSize to set.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
246 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
247 public void setAcceptQueueSize(int acceptQueueSize)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
248 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
249 _acceptQueueSize = acceptQueueSize;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
250 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
251
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
252 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
253 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
254 * @return Returns the number of acceptor threads.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
255 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
256 public int getAcceptors()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
257 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
258 return _acceptors;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
259 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
260
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
261 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
262 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
263 * @param acceptors
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
264 * The number of acceptor threads to set.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
265 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
266 public void setAcceptors(int acceptors)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
267 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
268 if (acceptors > 2 * Runtime.getRuntime().availableProcessors())
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
269 LOG.warn("Acceptors should be <=2*availableProcessors: " + this);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
270 _acceptors = acceptors;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
271 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
272
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
273 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
274 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
275 * @param soLingerTime
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
276 * The soLingerTime to set or -1 to disable.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
277 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
278 public void setSoLingerTime(int soLingerTime)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
279 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
280 _soLingerTime = soLingerTime;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
281 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
282
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
283 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
284 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
285 protected void doStart() throws Exception
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
286 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
287 if (_server == null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
288 throw new IllegalStateException("No server");
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
289
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
290 // open listener port
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
291 open();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
292
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
293 super.doStart();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
294
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
295 // Start selector thread
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
296 synchronized (this)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
297 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
298 _acceptorThreads = new Thread[getAcceptors()];
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
299
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
300 ThreadPool _threadPool = getThreadPool();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
301 for (int i = 0; i < _acceptorThreads.length; i++)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
302 if (!_threadPool.dispatch(new Acceptor(i)))
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
303 throw new IllegalStateException("!accepting");
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
304 if (_threadPool.isLowOnThreads())
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
305 LOG.warn("insufficient threads configured for {}",this);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
306 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
307
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
308 LOG.info("Started {}",this);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
309 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
310
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
311 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
312 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
313 protected void doStop() throws Exception
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
314 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
315 try
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
316 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
317 close();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
318 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
319 catch (IOException e)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
320 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
321 LOG.warn("",e);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
322 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
323
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
324 super.doStop();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
325
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
326 Thread[] acceptors;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
327 synchronized (this)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
328 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
329 acceptors = _acceptorThreads;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
330 _acceptorThreads = null;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
331 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
332 if (acceptors != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
333 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
334 for (Thread thread : acceptors)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
335 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
336 if (thread != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
337 thread.interrupt();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
338 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
339 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
340 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
341
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
342 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
343 public void join() throws InterruptedException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
344 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
345 Thread[] threads;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
346 synchronized(this)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
347 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
348 threads=_acceptorThreads;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
349 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
350 if (threads != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
351 for (Thread thread : threads)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
352 if (thread != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
353 thread.join();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
354 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
355
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
356 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
357 protected void configure(Socket socket) throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
358 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
359 try
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
360 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
361 socket.setTcpNoDelay(true);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
362 if (_soLingerTime >= 0)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
363 socket.setSoLinger(true,_soLingerTime / 1000);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
364 else
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
365 socket.setSoLinger(false,0);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
366 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
367 catch (Exception e)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
368 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
369 LOG.trace("",e);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
370 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
371 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
372
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
373 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
374 public void customize(EndPoint endpoint, Request request) throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
375 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
376 if (isForwarded())
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
377 checkForwardedHeaders(endpoint,request);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
378 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
379
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
380 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
381 protected void checkForwardedHeaders(EndPoint endpoint, Request request) throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
382 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
383 HttpFields httpFields = request.getConnection().getRequestFields();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
384
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
385 // Do SSL first
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
386 if (getForwardedCipherSuiteHeader()!=null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
387 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
388 String cipher_suite=httpFields.getStringField(getForwardedCipherSuiteHeader());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
389 if (cipher_suite!=null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
390 request.setAttribute("javax.servlet.request.cipher_suite",cipher_suite);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
391 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
392 if (getForwardedSslSessionIdHeader()!=null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
393 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
394 String ssl_session_id=httpFields.getStringField(getForwardedSslSessionIdHeader());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
395 if(ssl_session_id!=null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
396 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
397 request.setAttribute("javax.servlet.request.ssl_session_id", ssl_session_id);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
398 request.setScheme(HttpSchemes.HTTPS);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
399 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
400 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
401
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
402 // Retrieving headers from the request
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
403 String forwardedHost = getLeftMostFieldValue(httpFields,getForwardedHostHeader());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
404 String forwardedServer = getLeftMostFieldValue(httpFields,getForwardedServerHeader());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
405 String forwardedFor = getLeftMostFieldValue(httpFields,getForwardedForHeader());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
406 String forwardedProto = getLeftMostFieldValue(httpFields,getForwardedProtoHeader());
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
407
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
408 if (_hostHeader != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
409 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
410 // Update host header
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
411 httpFields.put(HttpHeaders.HOST_BUFFER,_hostHeader);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
412 request.setServerName(null);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
413 request.setServerPort(-1);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
414 request.getServerName();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
415 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
416 else if (forwardedHost != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
417 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
418 // Update host header
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
419 httpFields.put(HttpHeaders.HOST_BUFFER,forwardedHost);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
420 request.setServerName(null);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
421 request.setServerPort(-1);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
422 request.getServerName();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
423 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
424 else if (forwardedServer != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
425 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
426 // Use provided server name
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
427 request.setServerName(forwardedServer);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
428 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
429
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
430 if (forwardedFor != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
431 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
432 request.setRemoteAddr(forwardedFor);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
433 InetAddress inetAddress = null;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
434
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
435 if (_useDNS)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
436 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
437 try
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
438 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
439 inetAddress = InetAddress.getByName(forwardedFor);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
440 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
441 catch (UnknownHostException e)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
442 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
443 LOG.trace("",e);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
444 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
445 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
446
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
447 request.setRemoteHost(inetAddress == null?forwardedFor:inetAddress.getHostName());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
448 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
449
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
450 if (forwardedProto != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
451 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
452 request.setScheme(forwardedProto);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
453 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
454 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
455
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
456 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
457 protected String getLeftMostFieldValue(HttpFields fields, String header)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
458 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
459 if (header == null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
460 return null;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
461
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
462 String headerValue = fields.getStringField(header);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
463
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
464 if (headerValue == null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
465 return null;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
466
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
467 int commaIndex = headerValue.indexOf(',');
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
468
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
469 if (commaIndex == -1)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
470 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
471 // Single value
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
472 return headerValue;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
473 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
474
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
475 // The left-most value is the farthest downstream client
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
476 return headerValue.substring(0,commaIndex);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
477 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
478
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
479 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
480 public void persist(EndPoint endpoint) throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
481 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
482 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
483
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
484 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
485 /*
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
486 * @see org.eclipse.jetty.server.Connector#getConfidentialPort()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
487 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
488 public int getConfidentialPort()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
489 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
490 return _confidentialPort;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
491 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
492
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
493 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
494 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
495 /*
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
496 * @see org.eclipse.jetty.server.Connector#getConfidentialScheme()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
497 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
498 public String getConfidentialScheme()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
499 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
500 return _confidentialScheme;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
501 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
502
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
503 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
504 /*
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
505 * @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server .Request)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
506 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
507 public boolean isIntegral(Request request)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
508 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
509 return false;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
510 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
511
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
512 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
513 /*
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
514 * @see org.eclipse.jetty.server.Connector#getConfidentialPort()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
515 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
516 public int getIntegralPort()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
517 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
518 return _integralPort;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
519 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
520
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
521 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
522 /*
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
523 * @see org.eclipse.jetty.server.Connector#getIntegralScheme()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
524 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
525 public String getIntegralScheme()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
526 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
527 return _integralScheme;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
528 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
529
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
530 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
531 /*
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
532 * @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server.Request)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
533 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
534 public boolean isConfidential(Request request)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
535 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
536 return _forwarded && request.getScheme().equalsIgnoreCase(HttpSchemes.HTTPS);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
537 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
538
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
539 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
540 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
541 * @param confidentialPort
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
542 * The confidentialPort to set.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
543 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
544 public void setConfidentialPort(int confidentialPort)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
545 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
546 _confidentialPort = confidentialPort;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
547 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
548
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
549 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
550 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
551 * @param confidentialScheme
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
552 * The confidentialScheme to set.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
553 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
554 public void setConfidentialScheme(String confidentialScheme)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
555 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
556 _confidentialScheme = confidentialScheme;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
557 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
558
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
559 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
560 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
561 * @param integralPort
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
562 * The integralPort to set.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
563 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
564 public void setIntegralPort(int integralPort)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
565 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
566 _integralPort = integralPort;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
567 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
568
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
569 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
570 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
571 * @param integralScheme
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
572 * The integralScheme to set.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
573 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
574 public void setIntegralScheme(String integralScheme)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
575 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
576 _integralScheme = integralScheme;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
577 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
578
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
579 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
580 protected abstract void accept(int acceptorID) throws IOException, InterruptedException;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
581
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
582 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
583 public void stopAccept(int acceptorID) throws Exception
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
584 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
585 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
586
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
587 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
588 public boolean getResolveNames()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
589 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
590 return _useDNS;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
591 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
592
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
593 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
594 public void setResolveNames(boolean resolve)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
595 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
596 _useDNS = resolve;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
597 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
598
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
599 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
600 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
601 * Is reverse proxy handling on?
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
602 *
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
603 * @return true if this connector is checking the x-forwarded-for/host/server headers
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
604 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
605 public boolean isForwarded()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
606 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
607 return _forwarded;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
608 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
609
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
610 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
611 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
612 * Set reverse proxy handling. If set to true, then the X-Forwarded headers (or the headers set in their place) are looked for to set the request protocol,
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
613 * host, server and client ip.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
614 *
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
615 * @param check
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
616 * true if this connector is checking the x-forwarded-for/host/server headers
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
617 * @see #setForwardedForHeader(String)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
618 * @see #setForwardedHostHeader(String)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
619 * @see #setForwardedProtoHeader(String)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
620 * @see #setForwardedServerHeader(String)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
621 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
622 public void setForwarded(boolean check)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
623 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
624 if (check)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
625 LOG.debug("{} is forwarded",this);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
626 _forwarded = check;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
627 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
628
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
629 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
630 public String getHostHeader()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
631 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
632 return _hostHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
633 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
634
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
635 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
636 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
637 * Set a forced valued for the host header to control what is returned by {@link ServletRequest#getServerName()} and {@link ServletRequest#getServerPort()}.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
638 * This value is only used if {@link #isForwarded()} is true.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
639 *
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
640 * @param hostHeader
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
641 * The value of the host header to force.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
642 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
643 public void setHostHeader(String hostHeader)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
644 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
645 _hostHeader = hostHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
646 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
647
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
648 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
649 /*
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
650 *
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
651 * @see #setForwarded(boolean)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
652 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
653 public String getForwardedHostHeader()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
654 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
655 return _forwardedHostHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
656 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
657
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
658 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
659 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
660 * @param forwardedHostHeader
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
661 * The header name for forwarded hosts (default x-forwarded-host)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
662 * @see #setForwarded(boolean)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
663 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
664 public void setForwardedHostHeader(String forwardedHostHeader)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
665 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
666 _forwardedHostHeader = forwardedHostHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
667 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
668
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
669 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
670 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
671 * @return the header name for forwarded server.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
672 * @see #setForwarded(boolean)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
673 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
674 public String getForwardedServerHeader()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
675 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
676 return _forwardedServerHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
677 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
678
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
679 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
680 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
681 * @param forwardedServerHeader
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
682 * The header name for forwarded server (default x-forwarded-server)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
683 * @see #setForwarded(boolean)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
684 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
685 public void setForwardedServerHeader(String forwardedServerHeader)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
686 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
687 _forwardedServerHeader = forwardedServerHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
688 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
689
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
690 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
691 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
692 * @see #setForwarded(boolean)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
693 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
694 public String getForwardedForHeader()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
695 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
696 return _forwardedForHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
697 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
698
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
699 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
700 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
701 * @param forwardedRemoteAddressHeader
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
702 * The header name for forwarded for (default x-forwarded-for)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
703 * @see #setForwarded(boolean)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
704 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
705 public void setForwardedForHeader(String forwardedRemoteAddressHeader)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
706 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
707 _forwardedForHeader = forwardedRemoteAddressHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
708 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
709
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
710 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
711 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
712 * Get the forwardedProtoHeader.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
713 *
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
714 * @return the forwardedProtoHeader (default X-Forwarded-For)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
715 * @see #setForwarded(boolean)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
716 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
717 public String getForwardedProtoHeader()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
718 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
719 return _forwardedProtoHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
720 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
721
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
722 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
723 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
724 * Set the forwardedProtoHeader.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
725 *
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
726 * @param forwardedProtoHeader
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
727 * the forwardedProtoHeader to set (default X-Forwarded-For)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
728 * @see #setForwarded(boolean)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
729 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
730 public void setForwardedProtoHeader(String forwardedProtoHeader)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
731 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
732 _forwardedProtoHeader = forwardedProtoHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
733 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
734
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
735 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
736 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
737 * @return The header name holding a forwarded cipher suite (default null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
738 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
739 public String getForwardedCipherSuiteHeader()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
740 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
741 return _forwardedCipherSuiteHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
742 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
743
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
744 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
745 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
746 * @param forwardedCipherSuite
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
747 * The header name holding a forwarded cipher suite (default null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
748 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
749 public void setForwardedCipherSuiteHeader(String forwardedCipherSuite)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
750 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
751 _forwardedCipherSuiteHeader = forwardedCipherSuite;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
752 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
753
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
754 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
755 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
756 * @return The header name holding a forwarded SSL Session ID (default null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
757 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
758 public String getForwardedSslSessionIdHeader()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
759 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
760 return _forwardedSslSessionIdHeader;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
761 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
762
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
763 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
764 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
765 * @param forwardedSslSessionId
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
766 * The header name holding a forwarded SSL Session ID (default null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
767 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
768 public void setForwardedSslSessionIdHeader(String forwardedSslSessionId)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
769 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
770 _forwardedSslSessionIdHeader = forwardedSslSessionId;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
771 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
772
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
773 public int getRequestBufferSize()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
774 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
775 return _buffers.getRequestBufferSize();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
776 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
777
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
778 public void setRequestBufferSize(int requestBufferSize)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
779 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
780 _buffers.setRequestBufferSize(requestBufferSize);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
781 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
782
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
783 public int getRequestHeaderSize()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
784 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
785 return _buffers.getRequestHeaderSize();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
786 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
787
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
788 public void setRequestHeaderSize(int requestHeaderSize)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
789 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
790 _buffers.setRequestHeaderSize(requestHeaderSize);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
791 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
792
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
793 public int getResponseBufferSize()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
794 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
795 return _buffers.getResponseBufferSize();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
796 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
797
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
798 public void setResponseBufferSize(int responseBufferSize)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
799 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
800 _buffers.setResponseBufferSize(responseBufferSize);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
801 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
802
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
803 public int getResponseHeaderSize()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
804 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
805 return _buffers.getResponseHeaderSize();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
806 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
807
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
808 public void setResponseHeaderSize(int responseHeaderSize)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
809 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
810 _buffers.setResponseHeaderSize(responseHeaderSize);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
811 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
812
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
813 public Type getRequestBufferType()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
814 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
815 return _buffers.getRequestBufferType();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
816 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
817
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
818 public Type getRequestHeaderType()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
819 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
820 return _buffers.getRequestHeaderType();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
821 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
822
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
823 public Type getResponseBufferType()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
824 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
825 return _buffers.getResponseBufferType();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
826 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
827
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
828 public Type getResponseHeaderType()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
829 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
830 return _buffers.getResponseHeaderType();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
831 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
832
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
833 public void setRequestBuffers(Buffers requestBuffers)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
834 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
835 _buffers.setRequestBuffers(requestBuffers);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
836 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
837
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
838 public void setResponseBuffers(Buffers responseBuffers)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
839 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
840 _buffers.setResponseBuffers(responseBuffers);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
841 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
842
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
843 public Buffers getRequestBuffers()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
844 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
845 return _buffers.getRequestBuffers();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
846 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
847
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
848 public Buffers getResponseBuffers()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
849 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
850 return _buffers.getResponseBuffers();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
851 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
852
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
853 public void setMaxBuffers(int maxBuffers)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
854 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
855 _buffers.setMaxBuffers(maxBuffers);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
856 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
857
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
858 public int getMaxBuffers()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
859 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
860 return _buffers.getMaxBuffers();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
861 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
862
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
863 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
864 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
865 public String toString()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
866 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
867 return String.format("%s@%s:%d",
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
868 getClass().getSimpleName(),
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
869 getHost()==null?"0.0.0.0":getHost(),
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
870 getLocalPort()<=0?getPort():getLocalPort());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
871 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
872
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
873 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
874 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
875 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
876 private class Acceptor implements Runnable
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
877 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
878 int _acceptor = 0;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
879
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
880 Acceptor(int id)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
881 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
882 _acceptor = id;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
883 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
884
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
885 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
886 public void run()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
887 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
888 Thread current = Thread.currentThread();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
889 String name;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
890 synchronized (AbstractConnector.this)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
891 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
892 if (_acceptorThreads == null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
893 return;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
894
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
895 _acceptorThreads[_acceptor] = current;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
896 name = _acceptorThreads[_acceptor].getName();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
897 current.setName(name + " Acceptor" + _acceptor + " " + AbstractConnector.this);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
898 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
899 int old_priority = current.getPriority();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
900
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
901 try
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
902 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
903 current.setPriority(old_priority - _acceptorPriorityOffset);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
904 while (isRunning() && getConnection() != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
905 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
906 try
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
907 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
908 accept(_acceptor);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
909 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
910 catch (EofException e)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
911 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
912 LOG.trace("",e);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
913 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
914 catch (IOException e)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
915 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
916 LOG.trace("",e);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
917 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
918 catch (InterruptedException x)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
919 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
920 // Connector has been stopped
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
921 LOG.trace("",x);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
922 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
923 catch (Throwable e)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
924 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
925 LOG.warn("",e);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
926 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
927 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
928 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
929 finally
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
930 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
931 current.setPriority(old_priority);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
932 current.setName(name);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
933
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
934 synchronized (AbstractConnector.this)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
935 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
936 if (_acceptorThreads != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
937 _acceptorThreads[_acceptor] = null;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
938 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
939 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
940 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
941 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
942
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
943 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
944 public String getName()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
945 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
946 if (_name == null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
947 _name = (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?getPort():getLocalPort());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
948 return _name;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
949 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
950
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
951 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
952 public void setName(String name)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
953 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
954 _name = name;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
955 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
956
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
957 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
958 protected void connectionOpened(Connection connection)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
959 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
960 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
961
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
962 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
963 protected void connectionUpgraded(Connection oldConnection, Connection newConnection)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
964 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
965 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
966
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
967 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
968 protected void connectionClosed(Connection connection)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
969 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
970 connection.onClose();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
971 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
972
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
973 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
974 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
975 * @return the acceptorPriority
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
976 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
977 public int getAcceptorPriorityOffset()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
978 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
979 return _acceptorPriorityOffset;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
980 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
981
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
982 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
983 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
984 * 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
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
985 * newly active connections or to favour the handling of already dispatched connections.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
986 *
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
987 * @param offset
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
988 * the amount to alter the priority of the acceptor threads.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
989 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
990 public void setAcceptorPriorityOffset(int offset)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
991 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
992 _acceptorPriorityOffset = offset;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
993 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
994
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
995 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
996 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
997 * @return True if the the server socket will be opened in SO_REUSEADDR mode.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
998 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
999 public boolean getReuseAddress()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1000 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1001 return _reuseAddress;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1002 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1003
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1004 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1005 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1006 * @param reuseAddress
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1007 * True if the the server socket will be opened in SO_REUSEADDR mode.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1008 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1009 public void setReuseAddress(boolean reuseAddress)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1010 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1011 _reuseAddress = reuseAddress;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1012 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1013
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1014 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1015 public boolean isLowResources()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1016 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1017 return getThreadPool().isLowOnThreads();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1018 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1019
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1020 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1021 private void updateNotEqual(AtomicLong valueHolder, long compare, long value)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1022 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1023 long oldValue = valueHolder.get();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1024 while (compare != oldValue)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1025 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1026 if (valueHolder.compareAndSet(oldValue,value))
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1027 break;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1028 oldValue = valueHolder.get();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1029 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
1030 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1031 }