19-Oct-2022 11:32:58.320 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"] 19-Oct-2022 11:32:58.407 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 19-Oct-2022 11:33:07.092 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 9593 ms
19-Oct-2022 11:33:07.123 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina] 19-Oct-2022 11:33:07.124 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/8.5.66] 19-Oct-2022 11:33:07.165 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"] 19-Oct-2022 11:33:50.942 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 43847 ms
"main@1" prio=5 tid=0x1 nid=NA runnable java.lang.Thread.State: RUNNABLE #AbstractEndpoint.init at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1153) #AbstractJsseEndpoint.init at org.apache.tomcat.util.net.AbstractJsseEndpoint.init(AbstractJsseEndpoint.java:222) #AbstractProtocol.init at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:599) at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:80) #Connector.initInternal at org.apache.catalina.connector.Connector.initInternal(Connector.java:1074) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) - locked <0x99f> (a org.apache.catalina.connector.Connector) #StandardService.initInternal at org.apache.catalina.core.StandardService.initInternal(StandardService.java:552) - locked <0x9c6> (a java.lang.Object) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) - locked <0x9a0> (a org.apache.catalina.core.StandardService) #StandardServer.initInternal at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:846) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) - locked <0x9a1> (a org.apache.catalina.core.StandardServer) #catalina.load at org.apache.catalina.startup.Catalina.load(Catalina.java:639) at org.apache.catalina.startup.Catalina.load(Catalina.java:662) at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:302) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:472)
if (!getUseInheritedChannel()) { serverSock = ServerSocketChannel.open(); socketProperties.setProperties(serverSock.socket()); InetSocketAddress addr = (getAddress()!=null?new InetSocketAddress(getAddress(),getPort()):new InetSocketAddress(getPort())); // 这里进行了bind和listen serverSock.socket().bind(addr,getAcceptCount()); } else { // Retrieve the channel provided by the OS Channel ic = System.inheritedChannel(); if (ic instanceof ServerSocketChannel) { serverSock = (ServerSocketChannel) ic; } if (serverSock == null) { thrownew IllegalArgumentException(sm.getString("endpoint.init.bind.inherited")); } } serverSock.configureBlocking(true); //mimic APR behavior
// Initialize thread count defaults for acceptor, poller if (acceptorThreadCount == 0) { // FIXME: Doesn't seem to work that well with multiple accept threads acceptorThreadCount = 1; } if (pollerThreadCount <= 0) { //minimum one poller thread pollerThreadCount = 1; } setStopLatch(new CountDownLatch(pollerThreadCount));
// Initialize SSL if needed initialiseSsl();
selectorPool.open(); }
// java.net.ServerSocket#bind(java.net.SocketAddress, int) publicvoidbind(SocketAddress endpoint, int backlog)throws IOException { if (isClosed()) thrownew SocketException("Socket is closed"); if (!oldImpl && isBound()) thrownew SocketException("Already bound"); if (endpoint == null) endpoint = new InetSocketAddress(0); if (!(endpoint instanceof InetSocketAddress)) thrownew IllegalArgumentException("Unsupported address type"); InetSocketAddress epoint = (InetSocketAddress) endpoint; if (epoint.isUnresolved()) thrownew SocketException("Unresolved address"); if (backlog < 1) backlog = 50; try { SecurityManager security = System.getSecurityManager(); if (security != null) security.checkListen(epoint.getPort()); // 先bind端口 getImpl().bind(epoint.getAddress(), epoint.getPort()); // 再listen,listen时内核会创建SYN Queue和Accept Queue getImpl().listen(backlog); bound = true; } catch(SecurityException e) { bound = false; throw e; } catch(IOException e) { bound = false; throw e; } }
"main@1" prio=5 tid=0x1 nid=NA runnable java.lang.Thread.State: RUNNABLE #NioEndpoint.startInternal at org.apache.tomcat.util.net.NioEndpoint.startInternal(NioEndpoint.java:261) #AbstractEndpoint.start at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1219) #AbstractProtocol.start at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:609) #Connector.startInternal at org.apache.catalina.connector.Connector.startInternal(Connector.java:1099) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) - locked <0x99d> (a org.apache.catalina.connector.Connector) #StandardService.startInternal at org.apache.catalina.core.StandardService.startInternal(StandardService.java:440) - locked <0xa6a> (a java.lang.Object) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) - locked <0x99e> (a org.apache.catalina.core.StandardService) #StandardServer.startInternal at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:766) - locked <0xa6b> (a java.lang.Object) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) - locked <0x99f> (a org.apache.catalina.core.StandardServer) #Catalina.start at org.apache.catalina.startup.Catalina.start(Catalina.java:688) at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:342) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)
processorCache = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, socketProperties.getProcessorCache()); eventCache = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, socketProperties.getEventCache()); nioChannels = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, socketProperties.getBufferPool());
// org.apache.tomcat.util.net.NioEndpoint.Acceptor /** * The background thread that listens for incoming TCP/IP connections and * hands them off to an appropriate processor. */ protectedclassAcceptorextendsAbstractEndpoint.Acceptor{
@Override publicvoidrun(){
int errorDelay = 0;
// Loop until we receive a shutdown command while (running) {
// Loop if endpoint is paused while (paused && running) { state = AcceptorState.PAUSED; try { Thread.sleep(50); } catch (InterruptedException e) { // Ignore } }
if (!running) { break; } state = AcceptorState.RUNNING;
try { //if we have reached max connections, wait countUpOrAwaitConnection();
SocketChannel socket = null; try { // Accept the next incoming connection from the server // socket // 注意这里accept了 socket = serverSock.accept(); } catch (IOException ioe) { // We didn't get a socket countDownConnection(); if (running) { // Introduce delay if necessary errorDelay = handleExceptionWithDelay(errorDelay); // re-throw throw ioe; } else { break; } } // Successful accept, reset the error delay errorDelay = 0;
// Configure the socket if (running && !paused) { // setSocketOptions() will hand the socket off to // an appropriate processor if successful if (!setSocketOptions(socket)) { closeSocket(socket); } } else { closeSocket(socket); } } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.error(sm.getString("endpoint.accept.fail"), t); } } state = AcceptorState.ENDED; }
19-Oct-2022 14:51:28.147 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"] 19-Oct-2022 14:51:28.164 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 19-Oct-2022 14:51:28.176 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 501 ms 19-Oct-2022 14:51:28.237 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina] 19-Oct-2022 14:51:28.237 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/8.5.66] 19-Oct-2022 14:51:28.251 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"] 19-Oct-2022 14:51:28.257 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 80 ms Connected to server [2022-10-19 02:51:28,339] Artifact web:war exploded: Artifact is being deployed, please wait... 19-Oct-2022 14:51:28.747 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 14:51:28.803 [RMI TCP Connection(2)-127.0.0.1] INFO c.a.context.SimpleLogContextListener - contextInitialized... begin sleep 19-Oct-2022 14:51:38.253 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/Users/qishengli/Downloads/apache-tomcat-8.5.66/webapps/manager] 19-Oct-2022 14:51:38.278 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 19-Oct-2022 14:51:38.296 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/Users/qishengli/Downloads/apache-tomcat-8.5.66/webapps/manager] has finished in [42] ms 14:51:38.812 [RMI TCP Connection(2)-127.0.0.1] INFO com.air.filter.TestFilter - initing Filter... 14:51:48.818 [RMI TCP Connection(2)-127.0.0.1] INFO com.air.TestServlet2 - init TestServlet2... 14:51:58.819 [RMI TCP Connection(2)-127.0.0.1] INFO com.air.SampleServlet - initing sample servlet 14:51:58.820 [RMI TCP Connection(2)-127.0.0.1] INFO com.air.TestServlet3 - init TestServlet3... [2022-10-19 02:52:08,833] Artifact web:war exploded: Artifact is deployed successfully [2022-10-19 02:52:08,833] Artifact web:war exploded: Deploy took 40,494 milliseconds
19-Oct-2022 14:29:36.778 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-21002"] 19-Oct-2022 14:29:36.790 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 19-Oct-2022 14:29:36.796 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 448 ms 19-Oct-2022 14:29:36.801 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina] 19-Oct-2022 14:29:36.801 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.38 19-Oct-2022 14:29:38.641 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. # 中间有业务日志 19-Oct-2022 14:34:25.888 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-21002"] 19-Oct-2022 14:34:25.894 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 289097 ms
19-Oct-2022 14:51:38.296 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/Users/qishengli/Downloads/apache-tomcat-8.5.66/webapps/manager] has finished in [42] ms