图说springboot整合jetty-Request

一张巨无霸图

  1. 将Selector与一个Channel注册绑定得到一个SelectedKey
  2. 异步将EndPoint附加到SelectedKey。
  3. channel数据准备就绪时唤醒select阻塞,根据SelectedKey的attachment判断channel的是Selectable,或者根据SelectedKey判断isConnectable。
  4. 如果是Selectable则回调相应的callback(例如:ReadCallback)
    注:一个Selector可以监听多个channel。
    图说springboot整合jetty-Request_第1张图片

Server容器中的bean

0 = {ContainerLifeCycle$Bean@7974} "{QueuedThreadPool[qtp509636452]@1e606f64{STARTED,8<=8<=200,i=4,q=0}[ReservedThreadExecutor@6cee903a{s=0/4,p=0}],MANAGED}"
1 = {ContainerLifeCycle$Bean@7975} "{ServerConnector@137a4b54{HTTP/1.1,[http/1.1]}{0.0.0.0:16090},MANAGED}"
2 = {ContainerLifeCycle$Bean@7976} "{o.s.b.c.e.j.JettyEmbeddedWebAppContext@340c57e0{application,/dispatch/grafana,[file:///C:/Users/Gallant/AppData/Local/Temp/jetty-docbase.875282093164272833.16090/],UNAVAILABLE},MANAGED}"
3 = {ContainerLifeCycle$Bean@7977} "{AbstractLifeCycle@1acc873b{STOPPED},AUTO}"
4 = {ContainerLifeCycle$Bean@7978} "{ErrorHandler@6d617b07{STOPPED},AUTO}"
5 = {DefaultSessionIdManager@49bb808f{STARTED}[worker=node0],MANAGED}

ServerConnector容器中的bean

0 = {ContainerLifeCycle$Bean@8091} "{Server@797f97e3{STARTING}[9.4.12.v20180830],UNMANAGED}"
1 = {ContainerLifeCycle$Bean@8092} "{QueuedThreadPool[qtp509636452]@1e606f64{STARTED,8<=8<=200,i=4,q=0}[ReservedThreadExecutor@6cee903a{s=0/4,p=0}],UNMANAGED}"
2 = {ContainerLifeCycle$Bean@8093} "{ScheduledExecutorScheduler@15cee630{STOPPED},AUTO}"
3 = {ContainerLifeCycle$Bean@8094} "{org.eclipse.jetty.io.ArrayByteBufferPool@1884e671,POJO}"
4 = {ContainerLifeCycle$Bean@8095} "{HttpConnectionFactory@376498da[HTTP/1.1],AUTO}"
5 = {ContainerLifeCycle$Bean@8096} "{SelectorManager@ServerConnector@137a4b54{HTTP/1.1,[http/1.1]}{0.0.0.0:16090},MANAGED}"
6 = {sun.nio.ch.ServerSocketChannelImpl[/0:0:0:0:0:0:0:0:16090],POJO}

EatWhatYouKill容器中的bean

0 = {ContainerLifeCycle$Bean@13759} "{SelectorProducer@2a742ee4,POJO}"
1 = {ContainerLifeCycle$Bean@13760} "{QueuedThreadPool[qtp2042086224]@79b7c350{STARTED,8<=8<=200,i=8,q=0}[ReservedThreadExecutor@12670e55{s=0/4,p=0}],UNMANAGED}"

SelectorManager容器中的bean(当前案例中默认数量为2)

0 = {ContainerLifeCycle$Bean@10700} "{ManagedSelector@796d0b43{STOPPED} id=0 keys=-1 selected=-1 updates=0,AUTO}"
1 = {ContainerLifeCycle$Bean@10701} "{ManagedSelector@424ebf5b{STOPPED} id=1 keys=-1 selected=-1 updates=0,AUTO}"

ManagedSelector容器中的bean

0 = {EatWhatYouKill@4e41b993/SelectorProducer@2a742ee4/IDLE/p=false/QueuedThreadPool[qtp2042086224]@79b7c350{STARTED,8<=8<=200,i=8,q=0}[ReservedThreadExecutor@12670e55{s=0/4,p=0}][pc=0,pic=0,pec=0,epc=0]@2020-05-24T16:24:06.017+08:00,MANAGED}

Server对connectors的特殊处理

Server中对connectors做了特殊处理,最后启动

@Override
protected void start(LifeCycle l) throws Exception
{
   // start connectors last
   if (!(l instanceof Connector))
       super.start(l);
}

你可能感兴趣的:(java)