annotate src/org/eclipse/jetty/server/nio/SelectChannelConnector.java @ 901:d9a12a7339a6

remove connectionUpgraded()
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 07 Oct 2016 00:17:26 -0600
parents 821e4634b787
children 769040d68b0a
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.nio;
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.InetSocketAddress;
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.nio.channels.SelectionKey;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 import java.nio.channels.ServerSocketChannel;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 import java.nio.channels.SocketChannel;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 import org.eclipse.jetty.continuation.Continuation;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 import org.eclipse.jetty.io.AsyncEndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 import org.eclipse.jetty.io.ConnectedEndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 import org.eclipse.jetty.io.Connection;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 import org.eclipse.jetty.io.EndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 import org.eclipse.jetty.io.nio.AsyncConnection;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 import org.eclipse.jetty.io.nio.SelectorManager;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 import org.eclipse.jetty.io.nio.SelectorManager.SelectSet;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 import org.eclipse.jetty.server.AsyncHttpConnection;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 import org.eclipse.jetty.server.Request;
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
39 import org.eclipse.jetty.server.Server;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 /* ------------------------------------------------------------------------------- */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 /**
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 * Selecting NIO connector.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 * <p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 * This connector uses efficient NIO buffers with a non blocking threading model. Direct NIO buffers
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 * are used and threads are only allocated to connections with requests. Synchronization is used to
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 * simulate blocking for the servlet API, and any unflushed content at the end of request handling
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 * is written asynchronously.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 * </p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 * <p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 * This connector is best used when there are a many connections that have idle periods.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 * </p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 * <p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 * When used with {@link org.eclipse.jetty.continuation.Continuation}, threadless waits are supported.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 * If a filter or servlet returns after calling {@link Continuation#suspend()} or when a
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 * runtime exception is thrown from a call to {@link Continuation#undispatch()}, Jetty will
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57 * will not send a response to the client. Instead the thread is released and the Continuation is
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
58 * placed on the timer queue. If the Continuation timeout expires, or it's
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
59 * resume method is called, then the request is again allocated a thread and the request is retried.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
60 * The limitation of this approach is that request content is not available on the retried request,
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61 * thus if possible it should be read after the continuation or saved as a request attribute or as the
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
62 * associated object of the Continuation instance.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
63 * </p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
64 *
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
65 * @org.apache.xbean.XBean element="nioConnector" description="Creates an NIO based socket connector"
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
66 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
67 public class SelectChannelConnector extends AbstractNIOConnector
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
68 {
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
69 protected ServerSocketChannel _acceptChannel;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
70 private int _lowResourcesConnections;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
71 private int _lowResourcesMaxIdleTime;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
72 private int _localPort=-1;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
73
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
74 private final SelectorManager _manager = new ConnectorSelectorManager();
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: 802
diff changeset
76 /* ------------------------------------------------------------------------------- */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
77 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
78 * Constructor.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
79 *
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
80 */
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
81 public SelectChannelConnector(Server server,int port)
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
82 {
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
83 super(server,port);
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
84 _manager.setMaxIdleTime(getMaxIdleTime());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
85 addBean(_manager,true);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
86 setAcceptors(Math.max(1,(Runtime.getRuntime().availableProcessors()+3)/4));
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
87 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
88
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
89 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
90 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
91 public void accept(int acceptorID) throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
92 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
93 ServerSocketChannel server;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
94 synchronized(this)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
95 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
96 server = _acceptChannel;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
97 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
98
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
99 if (server!=null && server.isOpen() && _manager.isStarted())
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
100 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
101 SocketChannel channel = server.accept();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
102 channel.configureBlocking(false);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
103 Socket socket = channel.socket();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
104 configure(socket);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
105 _manager.register(channel);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
106 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
107 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
108
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
109 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
110 public void close() throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
111 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
112 synchronized(this)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
113 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
114 if (_acceptChannel != null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
115 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
116 removeBean(_acceptChannel);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
117 if (_acceptChannel.isOpen())
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
118 _acceptChannel.close();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
119 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
120 _acceptChannel = null;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
121 _localPort=-2;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
122 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
123 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
124
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
125 /* ------------------------------------------------------------------------------- */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
126 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
127 public void customize(EndPoint endpoint, Request request) throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
128 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
129 request.setTimeStamp(System.currentTimeMillis());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
130 endpoint.setMaxIdleTime(_maxIdleTime);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
131 super.customize(endpoint, request);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
132 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
133
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
134 /* ------------------------------------------------------------------------------- */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
135 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
136 public void persist(EndPoint endpoint) throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
137 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
138 AsyncEndPoint aEndp = ((AsyncEndPoint)endpoint);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
139 aEndp.setCheckForIdle(true);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
140 super.persist(endpoint);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
141 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
142
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
143 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
144 public SelectorManager getSelectorManager()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
145 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
146 return _manager;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
147 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
148
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
149 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
150 public synchronized Object getConnection()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
151 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
152 return _acceptChannel;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
153 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
154
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
155 /* ------------------------------------------------------------------------------- */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
156 public int getLocalPort()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
157 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
158 synchronized(this)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
159 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
160 return _localPort;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
161 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
162 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
163
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
164 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
165 public void open() throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
166 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
167 synchronized(this)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
168 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
169 if (_acceptChannel == null)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
170 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
171 // Create a new server socket
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
172 _acceptChannel = ServerSocketChannel.open();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
173 // Set to blocking mode
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
174 _acceptChannel.configureBlocking(true);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
175
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
176 // Bind the server socket to the local host and port
897
821e4634b787 remove _reuseAddress
Franklin Schmidt <fschmidt@gmail.com>
parents: 888
diff changeset
177 _acceptChannel.socket().setReuseAddress(true);
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
178 InetSocketAddress addr = getHost()==null?new InetSocketAddress(port):new InetSocketAddress(getHost(),port);
888
1aa58272794f remove _acceptQueueSize
Franklin Schmidt <fschmidt@gmail.com>
parents: 887
diff changeset
179 _acceptChannel.socket().bind(addr,0);
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
180
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
181 _localPort=_acceptChannel.socket().getLocalPort();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
182 if (_localPort<=0)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
183 throw new IOException("Server channel not bound");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
184
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
185 addBean(_acceptChannel);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
186 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
187 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
188 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
189
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
190 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
191 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
192 public void setMaxIdleTime(int maxIdleTime)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
193 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
194 _manager.setMaxIdleTime(maxIdleTime);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
195 super.setMaxIdleTime(maxIdleTime);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
196 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
197
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
198 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
199 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
200 * @return the lowResourcesConnections
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
201 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
202 public int getLowResourcesConnections()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
203 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
204 return _lowResourcesConnections;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
205 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
206
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
207 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
208 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
209 * Set the number of connections, which if exceeded places this manager in low resources state.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
210 * This is not an exact measure as the connection count is averaged over the select sets.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
211 * @param lowResourcesConnections the number of connections
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
212 * @see #setLowResourcesMaxIdleTime(int)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
213 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
214 public void setLowResourcesConnections(int lowResourcesConnections)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
215 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
216 _lowResourcesConnections=lowResourcesConnections;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
217 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
218
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
219 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
220 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
221 * @return the lowResourcesMaxIdleTime
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
222 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
223 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
224 public int getLowResourcesMaxIdleTime()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
225 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
226 return _lowResourcesMaxIdleTime;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
227 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
228
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
229 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
230 /**
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
231 * Set the period in ms that a connection is allowed to be idle when this there are more
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
232 * than {@link #getLowResourcesConnections()} connections. This allows the server to rapidly close idle connections
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
233 * in order to gracefully handle high load situations.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
234 * @param lowResourcesMaxIdleTime the period in ms that a connection is allowed to be idle when resources are low.
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
235 * @see #setMaxIdleTime(int)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
236 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
237 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
238 public void setLowResourcesMaxIdleTime(int lowResourcesMaxIdleTime)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
239 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
240 _lowResourcesMaxIdleTime=lowResourcesMaxIdleTime;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
241 super.setLowResourcesMaxIdleTime(lowResourcesMaxIdleTime);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
242 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
243
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
244
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
245 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
246 /*
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
247 * @see org.eclipse.jetty.server.server.AbstractConnector#doStart()
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
248 */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
249 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
250 protected void doStart() throws Exception
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
251 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
252 _manager.setSelectSets(getAcceptors());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
253 _manager.setMaxIdleTime(getMaxIdleTime());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
254 _manager.setLowResourcesConnections(getLowResourcesConnections());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
255 _manager.setLowResourcesMaxIdleTime(getLowResourcesMaxIdleTime());
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
256
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
257 super.doStart();
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
258 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
259
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
260 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
261 protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
262 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
263 SelectChannelEndPoint endp= new SelectChannelEndPoint(channel,selectSet,key, SelectChannelConnector.this._maxIdleTime);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
264 endp.setConnection(selectSet.getManager().newConnection(channel,endp, key.attachment()));
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
265 return endp;
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
266 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
267
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
268 /* ------------------------------------------------------------------------------- */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
269 protected void endPointClosed(SelectChannelEndPoint endpoint)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
270 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
271 connectionClosed(endpoint.getConnection());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
272 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
273
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
274 /* ------------------------------------------------------------------------------- */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
275 protected AsyncConnection newConnection(SocketChannel channel,final AsyncEndPoint endpoint)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
276 {
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
277 return new AsyncHttpConnection(SelectChannelConnector.this,endpoint,server);
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
278 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
279
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
280
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
281 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
282 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
283 /* ------------------------------------------------------------ */
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
284 private final class ConnectorSelectorManager extends SelectorManager
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
285 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
286 @Override
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
287 public void execute(Runnable task)
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
288 {
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
289 server.threadPool.execute(task);
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
290 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
291
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
292 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
293 protected void endPointClosed(final SelectChannelEndPoint endpoint)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
294 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
295 SelectChannelConnector.this.endPointClosed(endpoint);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
296 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
297
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
298 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
299 protected void endPointOpened(SelectChannelEndPoint endpoint)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
300 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
301 // TODO handle max connections and low resources
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
302 connectionOpened(endpoint.getConnection());
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
303 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
304
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
305 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
306 protected void endPointUpgraded(ConnectedEndPoint endpoint, Connection oldConnection)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
307 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
308 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
309
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
310 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
311 public AsyncConnection newConnection(SocketChannel channel,AsyncEndPoint endpoint, Object attachment)
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
312 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
313 return SelectChannelConnector.this.newConnection(channel,endpoint);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
314 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
315
864
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
316 @Override
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
317 protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey sKey) throws IOException
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
318 {
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
319 return SelectChannelConnector.this.newEndPoint(channel,selectSet,sKey);
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
320 }
e21ca9878a10 simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
321 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
322 }