Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java @ 887:df84a1741687
make Connector reference to server explicit
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 04 Oct 2016 23:59:56 -0600 |
parents | 6b210bb66c63 |
children | 1aa58272794f |
comparison
equal
deleted
inserted
replaced
886:0d876a03ab0b | 887:df84a1741687 |
---|---|
36 import org.eclipse.jetty.io.EndPoint; | 36 import org.eclipse.jetty.io.EndPoint; |
37 import org.eclipse.jetty.io.EofException; | 37 import org.eclipse.jetty.io.EofException; |
38 import org.eclipse.jetty.io.nio.ChannelEndPoint; | 38 import org.eclipse.jetty.io.nio.ChannelEndPoint; |
39 import org.eclipse.jetty.server.BlockingHttpConnection; | 39 import org.eclipse.jetty.server.BlockingHttpConnection; |
40 import org.eclipse.jetty.server.Request; | 40 import org.eclipse.jetty.server.Request; |
41 import org.eclipse.jetty.server.Server; | |
41 import org.slf4j.Logger; | 42 import org.slf4j.Logger; |
42 import org.slf4j.LoggerFactory; | 43 import org.slf4j.LoggerFactory; |
43 | 44 |
44 | 45 |
45 /* ------------------------------------------------------------------------------- */ | 46 /* ------------------------------------------------------------------------------- */ |
64 | 65 |
65 /* ------------------------------------------------------------ */ | 66 /* ------------------------------------------------------------ */ |
66 /** Constructor. | 67 /** Constructor. |
67 * | 68 * |
68 */ | 69 */ |
69 public BlockingChannelConnector() | 70 public BlockingChannelConnector(Server server,int port) |
70 { | 71 { |
72 super(server,port); | |
71 } | 73 } |
72 | 74 |
73 /* ------------------------------------------------------------ */ | 75 /* ------------------------------------------------------------ */ |
74 public Object getConnection() | 76 public Object getConnection() |
75 { | 77 { |
82 */ | 84 */ |
83 @Override | 85 @Override |
84 protected void doStart() throws Exception | 86 protected void doStart() throws Exception |
85 { | 87 { |
86 super.doStart(); | 88 super.doStart(); |
87 getThreadPool().execute(new Runnable() | 89 server.threadPool.execute(new Runnable() |
88 { | 90 { |
89 | 91 |
90 public void run() | 92 public void run() |
91 { | 93 { |
92 while (isRunning()) | 94 while (isRunning()) |
122 // Create a new server socket and set to non blocking mode | 124 // Create a new server socket and set to non blocking mode |
123 _acceptChannel= ServerSocketChannel.open(); | 125 _acceptChannel= ServerSocketChannel.open(); |
124 _acceptChannel.configureBlocking(true); | 126 _acceptChannel.configureBlocking(true); |
125 | 127 |
126 // Bind the server socket to the local host and port | 128 // Bind the server socket to the local host and port |
127 InetSocketAddress addr = getHost()==null?new InetSocketAddress(getPort()):new InetSocketAddress(getHost(),getPort()); | 129 InetSocketAddress addr = getHost()==null?new InetSocketAddress(port):new InetSocketAddress(getHost(),port); |
128 _acceptChannel.socket().bind(addr,getAcceptQueueSize()); | 130 _acceptChannel.socket().bind(addr,getAcceptQueueSize()); |
129 } | 131 } |
130 | 132 |
131 /* ------------------------------------------------------------ */ | 133 /* ------------------------------------------------------------ */ |
132 public void close() throws IOException | 134 public void close() throws IOException |
180 | 182 |
181 BlockingChannelEndPoint(ByteChannel channel) | 183 BlockingChannelEndPoint(ByteChannel channel) |
182 throws IOException | 184 throws IOException |
183 { | 185 { |
184 super(channel,BlockingChannelConnector.this._maxIdleTime); | 186 super(channel,BlockingChannelConnector.this._maxIdleTime); |
185 _connection = new BlockingHttpConnection(BlockingChannelConnector.this,this,getServer()); | 187 _connection = new BlockingHttpConnection(BlockingChannelConnector.this,this,server); |
186 } | 188 } |
187 | 189 |
188 /* ------------------------------------------------------------ */ | 190 /* ------------------------------------------------------------ */ |
189 /** Get the connection. | 191 /** Get the connection. |
190 * @return the connection | 192 * @return the connection |
224 | 226 |
225 /* ------------------------------------------------------------ */ | 227 /* ------------------------------------------------------------ */ |
226 void dispatch() throws IOException | 228 void dispatch() throws IOException |
227 { | 229 { |
228 try { | 230 try { |
229 getThreadPool().execute(this); | 231 server.threadPool.execute(this); |
230 } catch(RejectedExecutionException e) { | 232 } catch(RejectedExecutionException e) { |
231 LOG.warn("dispatch failed for {}",_connection); | 233 LOG.warn("dispatch failed for {}",_connection); |
232 super.close(); | 234 super.close(); |
233 } | 235 } |
234 } | 236 } |
278 while (isOpen()) | 280 while (isOpen()) |
279 { | 281 { |
280 _idleTimestamp=System.currentTimeMillis(); | 282 _idleTimestamp=System.currentTimeMillis(); |
281 if (_connection.isIdle()) | 283 if (_connection.isIdle()) |
282 { | 284 { |
283 if (getServer().isLowOnThreads()) | 285 if (server.isLowOnThreads()) |
284 { | 286 { |
285 int lrmit = getLowResourcesMaxIdleTime(); | 287 int lrmit = getLowResourcesMaxIdleTime(); |
286 if (lrmit>=0 && _timeout!= lrmit) | 288 if (lrmit>=0 && _timeout!= lrmit) |
287 { | 289 { |
288 _timeout=lrmit; | 290 _timeout=lrmit; |