Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/Connector.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 | 150092cebf3e | 
| children | 1aa58272794f | 
   comparison
  equal
  deleted
  inserted
  replaced
| 886:0d876a03ab0b | 887:df84a1741687 | 
|---|---|
| 57 { | 57 { | 
| 58 private static final Logger LOG = LoggerFactory.getLogger(Connector.class); | 58 private static final Logger LOG = LoggerFactory.getLogger(Connector.class); | 
| 59 | 59 | 
| 60 private String _name; | 60 private String _name; | 
| 61 | 61 | 
| 62 private Server _server; | 62 public final Server server; | 
| 63 private String _host; | 63 private String _host; | 
| 64 private int _port = 0; | 64 public final int port; | 
| 65 private String _integralScheme = HttpSchemes.HTTPS; | 65 private String _integralScheme = HttpSchemes.HTTPS; | 
| 66 private int _integralPort = 0; | 66 private int _integralPort = 0; | 
| 67 private String _confidentialScheme = HttpSchemes.HTTPS; | 67 private String _confidentialScheme = HttpSchemes.HTTPS; | 
| 68 private int _confidentialPort = 0; | 68 private int _confidentialPort = 0; | 
| 69 private int _acceptQueueSize = 0; | 69 private int _acceptQueueSize = 0; | 
| 87 | 87 | 
| 88 private transient Thread[] _acceptorThreads; | 88 private transient Thread[] _acceptorThreads; | 
| 89 | 89 | 
| 90 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl(); | 90 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl(); | 
| 91 | 91 | 
| 92 /* ------------------------------------------------------------ */ | 92 public Connector(Server server,int port) { | 
| 93 /** | 93 this.server = server; | 
| 94 */ | 94 this.port = port; | 
| 95 public Connector() | 95 server.connectors.add(this); | 
| 96 { | |
| 97 addBean(_buffers); | 96 addBean(_buffers); | 
| 98 } | 97 } | 
| 99 | 98 | 
| 100 /* ------------------------------------------------------------ */ | 99 /* ------------------------------------------------------------ */ | 
| 100 /** | |
| 101 */ | |
| 102 public void setHost(String host) | |
| 103 { | |
| 104 _host = host; | |
| 105 } | |
| 106 | |
| 107 /* ------------------------------------------------------------ */ | |
| 101 /* | 108 /* | 
| 102 */ | 109 */ | 
| 103 public Server getServer() | |
| 104 { | |
| 105 return _server; | |
| 106 } | |
| 107 | |
| 108 /* ------------------------------------------------------------ */ | |
| 109 public void setServer(Server server) | |
| 110 { | |
| 111 _server = server; | |
| 112 } | |
| 113 | |
| 114 /* ------------------------------------------------------------ */ | |
| 115 public ThreadPoolExecutor getThreadPool() | |
| 116 { | |
| 117 return _server.threadPool; | |
| 118 } | |
| 119 | |
| 120 /* ------------------------------------------------------------ */ | |
| 121 /** | |
| 122 */ | |
| 123 public void setHost(String host) | |
| 124 { | |
| 125 _host = host; | |
| 126 } | |
| 127 | |
| 128 /* ------------------------------------------------------------ */ | |
| 129 /* | |
| 130 */ | |
| 131 public String getHost() | 110 public String getHost() | 
| 132 { | 111 { | 
| 133 return _host; | 112 return _host; | 
| 134 } | |
| 135 | |
| 136 /* ------------------------------------------------------------ */ | |
| 137 public void setPort(int port) | |
| 138 { | |
| 139 _port = port; | |
| 140 } | |
| 141 | |
| 142 /* ------------------------------------------------------------ */ | |
| 143 public int getPort() | |
| 144 { | |
| 145 return _port; | |
| 146 } | 113 } | 
| 147 | 114 | 
| 148 /* ------------------------------------------------------------ */ | 115 /* ------------------------------------------------------------ */ | 
| 149 /** | 116 /** | 
| 150 * @return Returns the maxIdleTime. | 117 * @return Returns the maxIdleTime. | 
| 282 | 249 | 
| 283 /* ------------------------------------------------------------ */ | 250 /* ------------------------------------------------------------ */ | 
| 284 @Override | 251 @Override | 
| 285 protected void doStart() throws Exception | 252 protected void doStart() throws Exception | 
| 286 { | 253 { | 
| 287 if (_server == null) | |
| 288 throw new IllegalStateException("No server"); | |
| 289 | |
| 290 // open listener port | 254 // open listener port | 
| 291 open(); | 255 open(); | 
| 292 | 256 | 
| 293 super.doStart(); | 257 super.doStart(); | 
| 294 | 258 | 
| 295 // Start selector thread | 259 // Start selector thread | 
| 296 synchronized (this) | 260 synchronized (this) | 
| 297 { | 261 { | 
| 298 _acceptorThreads = new Thread[getAcceptors()]; | 262 _acceptorThreads = new Thread[getAcceptors()]; | 
| 299 | 263 | 
| 300 ThreadPoolExecutor _threadPool = getThreadPool(); | 264 ThreadPoolExecutor _threadPool = server.threadPool; | 
| 301 for (int i = 0; i < _acceptorThreads.length; i++) | 265 for (int i = 0; i < _acceptorThreads.length; i++) | 
| 302 _threadPool.execute(new Acceptor(i)); | 266 _threadPool.execute(new Acceptor(i)); | 
| 303 if (_server.isLowOnThreads()) | 267 if (server.isLowOnThreads()) | 
| 304 LOG.warn("insufficient threads configured for {}",this); | 268 LOG.warn("insufficient threads configured for {}",this); | 
| 305 } | 269 } | 
| 306 | 270 | 
| 307 LOG.info("Started {}",this); | 271 LOG.info("Started {}",this); | 
| 308 } | 272 } | 
| 859 public String toString() | 823 public String toString() | 
| 860 { | 824 { | 
| 861 return String.format("%s@%s:%d", | 825 return String.format("%s@%s:%d", | 
| 862 getClass().getSimpleName(), | 826 getClass().getSimpleName(), | 
| 863 getHost()==null?"0.0.0.0":getHost(), | 827 getHost()==null?"0.0.0.0":getHost(), | 
| 864 getLocalPort()<=0?getPort():getLocalPort()); | 828 getLocalPort()<=0 ? port : getLocalPort()); | 
| 865 } | 829 } | 
| 866 | 830 | 
| 867 /* ------------------------------------------------------------ */ | 831 /* ------------------------------------------------------------ */ | 
| 868 /* ------------------------------------------------------------ */ | 832 /* ------------------------------------------------------------ */ | 
| 869 /* ------------------------------------------------------------ */ | 833 /* ------------------------------------------------------------ */ | 
| 936 | 900 | 
| 937 /* ------------------------------------------------------------ */ | 901 /* ------------------------------------------------------------ */ | 
| 938 public String getName() | 902 public String getName() | 
| 939 { | 903 { | 
| 940 if (_name == null) | 904 if (_name == null) | 
| 941 _name = (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?getPort():getLocalPort()); | 905 _name = (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?port:getLocalPort()); | 
| 942 return _name; | 906 return _name; | 
| 943 } | 907 } | 
| 944 | 908 | 
| 945 /* ------------------------------------------------------------ */ | 909 /* ------------------------------------------------------------ */ | 
| 946 public void setName(String name) | 910 public void setName(String name) | 
| 1006 } | 970 } | 
| 1007 | 971 | 
| 1008 /* ------------------------------------------------------------ */ | 972 /* ------------------------------------------------------------ */ | 
| 1009 public final boolean isLowResources() | 973 public final boolean isLowResources() | 
| 1010 { | 974 { | 
| 1011 return _server.isLowOnThreads(); | 975 return server.isLowOnThreads(); | 
| 1012 } | 976 } | 
| 1013 | 977 | 
| 1014 /* ------------------------------------------------------------ */ | 978 /* ------------------------------------------------------------ */ | 
| 1015 private void updateNotEqual(AtomicLong valueHolder, long compare, long value) | 979 private void updateNotEqual(AtomicLong valueHolder, long compare, long value) | 
| 1016 { | 980 { | 
