Mercurial Hosting > luan
comparison src/org/eclipse/jetty/io/nio/SelectorManager.java @ 970:d82eb99e8df6
remove ConnectorSelectorManager
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 14 Oct 2016 05:24:18 -0600 |
parents | 0650077fcd6c |
children | f997df37cec1 |
comparison
equal
deleted
inserted
replaced
969:0650077fcd6c | 970:d82eb99e8df6 |
---|---|
41 import org.eclipse.jetty.io.EndPoint; | 41 import org.eclipse.jetty.io.EndPoint; |
42 import org.eclipse.jetty.util.TypeUtil; | 42 import org.eclipse.jetty.util.TypeUtil; |
43 import org.eclipse.jetty.util.component.AbstractLifeCycle; | 43 import org.eclipse.jetty.util.component.AbstractLifeCycle; |
44 import org.eclipse.jetty.util.component.AggregateLifeCycle; | 44 import org.eclipse.jetty.util.component.AggregateLifeCycle; |
45 import org.eclipse.jetty.util.component.Dumpable; | 45 import org.eclipse.jetty.util.component.Dumpable; |
46 import org.eclipse.jetty.server.nio.SelectChannelConnector; | |
46 import org.slf4j.Logger; | 47 import org.slf4j.Logger; |
47 import org.slf4j.LoggerFactory; | 48 import org.slf4j.LoggerFactory; |
48 | 49 |
49 | 50 |
50 /* ------------------------------------------------------------ */ | 51 /* ------------------------------------------------------------ */ |
51 /** | 52 /** |
52 * The Selector Manager manages and number of SelectSets to allow | 53 * The Selector Manager manages and number of SelectSets to allow |
53 * NIO scheduling to scale to large numbers of connections. | 54 * NIO scheduling to scale to large numbers of connections. |
54 * <p> | 55 * <p> |
55 */ | 56 */ |
56 public abstract class SelectorManager extends AbstractLifeCycle implements Dumpable | 57 public final class SelectorManager extends AbstractLifeCycle implements Dumpable |
57 { | 58 { |
58 public static final Logger LOG = LoggerFactory.getLogger("org.eclipse.jetty.io.nio"); | 59 public static final Logger LOG = LoggerFactory.getLogger("org.eclipse.jetty.io.nio"); |
59 | 60 |
60 private final int _maxIdleTime; | 61 private final SelectChannelConnector scc; |
61 private volatile long _now = System.currentTimeMillis(); | 62 private volatile long _now = System.currentTimeMillis(); |
62 private SaneSelector _selector; | 63 private SaneSelector _selector; |
63 | 64 |
64 /* ------------------------------------------------------------ */ | 65 /* ------------------------------------------------------------ */ |
65 /** | 66 /** |
66 * @param maxIdleTime The maximum period in milli seconds that a connection may be idle before it is closed. | 67 * @param maxIdleTime The maximum period in milli seconds that a connection may be idle before it is closed. |
67 * @see #setLowResourcesMaxIdleTime(long) | 68 * @see #setLowResourcesMaxIdleTime(long) |
68 */ | 69 */ |
69 public SelectorManager(int maxIdleTime) | 70 public SelectorManager(SelectChannelConnector scc) |
70 { | 71 { |
71 _maxIdleTime = maxIdleTime; | 72 this.scc = scc; |
72 } | 73 } |
73 | 74 |
74 /* ------------------------------------------------------------ */ | 75 /* ------------------------------------------------------------ */ |
75 /** Register a channel | 76 /** Register a channel |
76 * @param channel | 77 * @param channel |
84 set.addChange(channel); | 85 set.addChange(channel); |
85 } | 86 } |
86 */ | 87 */ |
87 try { | 88 try { |
88 SelectionKey key = _selector.register(channel,0,null); | 89 SelectionKey key = _selector.register(channel,0,null); |
89 SelectChannelEndPoint endpoint = new SelectChannelEndPoint(channel,this,key, _maxIdleTime); | 90 SelectChannelEndPoint endpoint = new SelectChannelEndPoint(channel,this,key, scc.getMaxIdleTime()); |
90 key.attach(endpoint); | 91 key.attach(endpoint); |
91 _selector.update(); | 92 _selector.update(); |
92 //System.out.println("qqqqqqqqqqqqqqqqqqqqqqqqqqqqq b"); | 93 //System.out.println("qqqqqqqqqqqqqqqqqqqqqqqqqqqqq b"); |
93 endpoint.schedule(); | 94 endpoint.schedule(); |
94 } catch(IOException e) { | 95 } catch(IOException e) { |
100 } | 101 } |
101 } | 102 } |
102 } | 103 } |
103 | 104 |
104 | 105 |
105 public abstract void execute(Runnable task); | 106 public void execute(Runnable task) { |
107 scc.server.threadPool.execute(task); | |
108 } | |
106 | 109 |
107 | 110 |
108 @Override | 111 @Override |
109 protected void doStart() throws Exception | 112 protected void doStart() throws Exception |
110 { | 113 { |
182 } | 185 } |
183 } | 186 } |
184 super.doStop(); | 187 super.doStop(); |
185 } | 188 } |
186 | 189 |
187 public abstract AsyncConnection newConnection(SocketChannel channel, SelectChannelEndPoint endpoint); | 190 public AsyncConnection newConnection(SocketChannel channel, SelectChannelEndPoint endpoint) { |
191 return scc.newConnection(channel,endpoint); | |
192 } | |
188 | 193 |
189 @Override | 194 @Override |
190 public String dump() | 195 public String dump() |
191 { | 196 { |
192 return AggregateLifeCycle.dump(this); | 197 return AggregateLifeCycle.dump(this); |