Mercurial Hosting > luan
annotate src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java @ 963:4b6216fa9cec
replace SelectChannelEndPoint._state with isDispatched
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 14 Oct 2016 00:15:28 -0600 |
parents | 7b94f5b33c64 |
children | 866f2e801618 |
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.ByteChannel; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
25 import java.nio.channels.SelectionKey; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 import java.nio.channels.ServerSocketChannel; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 import java.nio.channels.SocketChannel; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 import java.util.Set; |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
29 import java.util.concurrent.ConcurrentHashMap; |
865 | 30 import java.util.concurrent.RejectedExecutionException; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 import org.eclipse.jetty.http.HttpException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 import org.eclipse.jetty.io.Buffer; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
34 import org.eclipse.jetty.io.ConnectedEndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
35 import org.eclipse.jetty.io.Connection; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
36 import org.eclipse.jetty.io.EndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
37 import org.eclipse.jetty.io.EofException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
38 import org.eclipse.jetty.io.nio.ChannelEndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
39 import org.eclipse.jetty.server.BlockingHttpConnection; |
907
bc4e299de953
remove AbstractNIOConnector
Franklin Schmidt <fschmidt@gmail.com>
parents:
906
diff
changeset
|
40 import org.eclipse.jetty.server.Connector; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
41 import org.eclipse.jetty.server.Request; |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
42 import org.eclipse.jetty.server.Server; |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
43 import org.slf4j.Logger; |
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
44 import org.slf4j.LoggerFactory; |
802
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 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
47 /* ------------------------------------------------------------------------------- */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
48 /** Blocking NIO connector. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
49 * This connector uses efficient NIO buffers with a traditional blocking thread model. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
50 * Direct NIO buffers are used and a thread is allocated per connections. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
51 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
52 * This connector is best used when there are a few very active connections. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
53 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
54 * @org.apache.xbean.XBean element="blockingNioConnector" description="Creates a blocking NIO based socket connector" |
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 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
57 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
58 */ |
907
bc4e299de953
remove AbstractNIOConnector
Franklin Schmidt <fschmidt@gmail.com>
parents:
906
diff
changeset
|
59 public final class BlockingChannelConnector extends Connector |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
60 { |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
61 private static final Logger LOG = LoggerFactory.getLogger(BlockingChannelConnector.class); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
62 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
63 private final Set<BlockingChannelEndPoint> _endpoints = new ConcurrentHashMap<BlockingChannelEndPoint,Boolean>().newKeySet(); |
802
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 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
66 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
67 /** Constructor. |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
68 * |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
69 */ |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
70 public BlockingChannelConnector(Server server,int port) |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
71 { |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
72 super(server,port); |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
73 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
74 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
75 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
76 @Override |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
77 protected void doStart() throws Exception |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
78 { |
909 | 79 // Create a new server socket and set to non blocking mode |
80 _acceptChannel= ServerSocketChannel.open(); | |
81 _acceptChannel.configureBlocking(true); | |
82 | |
83 // Bind the server socket to the local host and port | |
84 InetSocketAddress addr = getHost()==null?new InetSocketAddress(port):new InetSocketAddress(getHost(),port); | |
85 _acceptChannel.bind(addr); | |
86 | |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
87 super.doStart(); |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
88 server.threadPool.execute(new Runnable() |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
89 { |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
90 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
91 public void run() |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
92 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
93 while (isRunning()) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
94 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
95 try |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
96 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
97 Thread.sleep(400); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
98 long now=System.currentTimeMillis(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
99 for (BlockingChannelEndPoint endp : _endpoints) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
100 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
101 endp.checkIdleTimestamp(now); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
102 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
103 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
104 catch(InterruptedException e) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
105 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
106 LOG.trace("",e); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
107 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
108 catch(Exception e) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
109 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
110 LOG.warn("",e); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
111 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
112 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
113 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
114 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
115 }); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
116 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
117 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
118 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
119 @Override |
906 | 120 public void accept() |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
121 throws IOException, InterruptedException |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
122 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
123 SocketChannel channel = _acceptChannel.accept(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
124 channel.configureBlocking(true); |
909 | 125 Socket socket = channel.socket(); |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
126 configure(socket); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
127 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
128 BlockingChannelEndPoint connection=new BlockingChannelEndPoint(channel); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
129 connection.dispatch(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
130 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
131 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
132 @Override |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
133 public void customize(EndPoint endpoint, Request request) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
134 throws IOException |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
135 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
136 super.customize(endpoint, request); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
137 endpoint.setMaxIdleTime(_maxIdleTime); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
138 configure(((SocketChannel)endpoint.getTransport()).socket()); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
139 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
140 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
141 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
142 private class BlockingChannelEndPoint extends ChannelEndPoint implements Runnable, ConnectedEndPoint |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
143 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
144 private Connection _connection; |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
145 private int _timeout; |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
146 private volatile long _idleTimestamp; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
147 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
148 BlockingChannelEndPoint(ByteChannel channel) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
149 throws IOException |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
150 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
151 super(channel,BlockingChannelConnector.this._maxIdleTime); |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
152 _connection = new BlockingHttpConnection(BlockingChannelConnector.this,this,server); |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
153 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
154 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
155 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
156 /** Get the connection. |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
157 * @return the connection |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
158 */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
159 public Connection getConnection() |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
160 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
161 return _connection; |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
162 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
163 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
164 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
165 public void setConnection(Connection connection) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
166 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
167 _connection=connection; |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
168 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
169 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
170 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
171 public void checkIdleTimestamp(long now) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
172 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
173 if (_idleTimestamp!=0 && _timeout>0 && now>(_idleTimestamp+_timeout)) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
174 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
175 idleExpired(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
176 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
177 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
178 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
179 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
180 protected void idleExpired() |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
181 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
182 try |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
183 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
184 super.close(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
185 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
186 catch (IOException e) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
187 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
188 LOG.trace("",e); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
189 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
190 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
191 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
192 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
193 void dispatch() throws IOException |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
194 { |
865 | 195 try { |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
196 server.threadPool.execute(this); |
865 | 197 } catch(RejectedExecutionException e) { |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
198 LOG.warn("dispatch failed for {}",_connection); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
199 super.close(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
200 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
201 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
202 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
203 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
204 /** |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
205 * @see org.eclipse.jetty.io.nio.ChannelEndPoint#fill(org.eclipse.jetty.io.Buffer) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
206 */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
207 @Override |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
208 public int fill(Buffer buffer) throws IOException |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
209 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
210 _idleTimestamp=System.currentTimeMillis(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
211 return super.fill(buffer); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
212 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
213 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
214 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
215 /** |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
216 * @see org.eclipse.jetty.io.nio.ChannelEndPoint#flush(org.eclipse.jetty.io.Buffer) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
217 */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
218 @Override |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
219 public int flush(Buffer buffer) throws IOException |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
220 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
221 _idleTimestamp=System.currentTimeMillis(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
222 return super.flush(buffer); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
223 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
224 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
225 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
226 /** |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
227 * @see org.eclipse.jetty.io.nio.ChannelEndPoint#flush(org.eclipse.jetty.io.Buffer, org.eclipse.jetty.io.Buffer, org.eclipse.jetty.io.Buffer) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
228 */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
229 @Override |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
230 public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
231 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
232 _idleTimestamp=System.currentTimeMillis(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
233 return super.flush(header,buffer,trailer); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
234 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
235 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
236 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
237 public void run() |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
238 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
239 try |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
240 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
241 _timeout=getMaxIdleTime(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
242 _endpoints.add(this); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
243 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
244 while (isOpen()) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
245 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
246 _idleTimestamp=System.currentTimeMillis(); |
913 | 247 if (!_connection.isIdle()) |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
248 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
249 if (_timeout!=getMaxIdleTime()) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
250 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
251 _timeout=getMaxIdleTime(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
252 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
253 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
254 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
255 _connection = _connection.handle(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
256 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
257 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
258 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
259 catch (EofException e) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
260 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
261 LOG.debug("EOF", e); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
262 try{BlockingChannelEndPoint.this.close();} |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
263 catch(IOException e2){LOG.trace("",e2);} |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
264 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
265 catch (HttpException e) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
266 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
267 LOG.debug("BAD", e); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
268 try{super.close();} |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
269 catch(IOException e2){LOG.trace("",e2);} |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
270 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
271 catch(Throwable e) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
272 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
273 LOG.warn("handle failed",e); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
274 try{super.close();} |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
275 catch(IOException e2){LOG.trace("",e2);} |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
276 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
277 finally |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
278 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
279 _endpoints.remove(this); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
280 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
281 // wait for client to close, but if not, close ourselves. |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
282 try |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
283 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
284 if (!_socket.isClosed()) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
285 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
286 long timestamp=System.currentTimeMillis(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
287 int max_idle=getMaxIdleTime(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
288 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
289 _socket.setSoTimeout(getMaxIdleTime()); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
290 int c=0; |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
291 do |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
292 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
293 c = _socket.getInputStream().read(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
294 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
295 while (c>=0 && (System.currentTimeMillis()-timestamp)<max_idle); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
296 if (!_socket.isClosed()) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
297 _socket.close(); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
298 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
299 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
300 catch(IOException e) |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
301 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
302 LOG.trace("",e); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
303 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
304 } |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
305 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
306 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
307 /* ------------------------------------------------------------ */ |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
308 @Override |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
309 public String toString() |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
310 { |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
311 return String.format("BCEP@%x{l(%s)<->r(%s),open=%b,ishut=%b,oshut=%b}-{%s}", |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
312 hashCode(), |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
313 _socket.getRemoteSocketAddress(), |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
314 _socket.getLocalSocketAddress(), |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
315 isOpen(), |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
316 isInputShutdown(), |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
317 isOutputShutdown(), |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
318 _connection); |
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
319 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
320 |
840
0f53601ea489
remove ConcurrentHashSet
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
321 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
322 } |