Jetty.xml learning

In order to learn the startup process of jetty, I have read a lot of articles and gave the following startup flowchart. Now combine jetty.xml to understand the startup process of jetty

  • Server

Find jetty.xml in the project, you will see the configuration of Server in the first line, and a Server will be created at this time The object, org.eclipse.jetty.server.Server is the location of the Server class, _threadPool, _connectors, _stopAtShutdown are all fields in the Server.

"Server" class = "org.eclipse.jetty.server.Server" >

  • ThreadPool
"ThreadPool" >
class = "org.eclipse.jetty.util.thread.QueuedThreadPool" >
< Set name= "minThreads" > 20
"maxThreads" > 1024

Set used, so it will use the setThreadPool method in Server to set a QueuedThreadPool In the thread pool, the minimum number of threads is set to 20, and the maximum number of threads is 1024.

public void setThreadPool(ThreadPool threadPool)
{
if (_threadPool!= null )
removeBean(_threadPool);
_container.update( this , _threadPool, threadPool,  "threadpool" , false );
     _threadPool = threadPool;
     if  (_threadPool!= null )
         addBean(_threadPool);
}

  • Connector
"addConnector" >
    
         class = "org.eclipse.jetty.server.nio.SelectChannelConnector" >
             "host" > "jetty.host" />
             "port" > "jetty.port"  default = "8080" />
             "maxIdleTime" > 3000
             "Acceptors" > 5
             "statsOn" > false
            
             "lowResourcesConnections" > 5000
             "lowResourcesMaxIdleTime" > 5000
        
     < code class="java plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace; background:0px center; border:0px; bottom:auto; float:none; height:auto; left:auto; line-height:20px; margin:0px; outline:0px; overflow:visible; padding:0px; position:static; right:auto; top:auto; vertical-align:baseline; width:auto; min-height:inherit">

这是jetty.xml中connector的配置,标签使用的是Call,就会直接调用Server中的addConnector方法添加connector,其中connector使用的是Connector的子类SelectChannelConnector。

maxIdleTime是一个连接的最大空闲时间,如果空闲时间超过这个值就会关闭连接。 
Acceptors:用于表示用于调用ServerSocket或ServerSocketChannel中accept方法的线程数,建议这个数字小于或等于可用处理器的2倍。 

//AcceptQueueSize:用于表示ServerSocket 或ServerSocketChannel中最大可等待的请求数.

"Server"  class = "org.eclipse.jetty.server.Server" >

"Server"  class = "org.eclipse.jetty.server.Server" >

"Server"  class = "org.eclipse.jetty.server.Server" >

"Server"  class = "org.eclipse.jetty.server.Server" >

"Server"  class = "org.eclipse.jetty.server.Server" >

"Server"  class = "org.eclipse.jetty.server.Server" >

"ThreadPool" >
     class = "org.eclipse.jetty.util.thread.QueuedThreadPool" >
         "minThreads" > 20
         "maxThreads" > 1024
    

"ThreadPool" >
     class = "org.eclipse.jetty.util.thread.QueuedThreadPool" >
         "minThreads" > 20
         "maxThreads" > 1024
    

"ThreadPool" >
     class = "org.eclipse.jetty.util.thread.QueuedThreadPool" >
         "minThreads" > 20
         "maxThreads" > 1024
    

"ThreadPool" >
     class = "org.eclipse.jetty.util.thread.QueuedThreadPool" >
         "minThreads" > 20
         "maxThreads" > 1024
    

"ThreadPool" >
     class = "org.eclipse.jetty.util.thread.QueuedThreadPool" >
         "minThreads" > 20
         "maxThreads" > 1024
    

"ThreadPool" >

     class = "org.eclipse.jetty.util.thread.QueuedThreadPool" >

         "minThreads" > 20

         "maxThreads" > 1024

    

public  void  setThreadPool(ThreadPool threadPool)
{
     if  (_threadPool!= null )
         removeBean(_threadPool);
     _container.update( this , _threadPool, threadPool,  "threadpool" , false );
     _threadPool = threadPool;
     if  (_threadPool!= null )
         addBean(_threadPool);
}

public  void  setThreadPool(ThreadPool threadPool)
{
     if  (_threadPool!= null )
         removeBean(_threadPool);
     _container.update( this , _threadPool, threadPool,  "threadpool" , false );
     _threadPool = threadPool;
     if  (_threadPool!= null )
         addBean(_threadPool);
}

public  void  setThreadPool(ThreadPool threadPool)
{
     if  (_threadPool!= null )
         removeBean(_threadPool);
     _container.update( this , _threadPool, threadPool,  "threadpool" , false );
     _threadPool = threadPool;
     if  (_threadPool!= null )
         addBean(_threadPool);
}

public  void  setThreadPool(ThreadPool threadPool)
{
     if  (_threadPool!= null )
         removeBean(_threadPool);
     _container.update( this , _threadPool, threadPool,  "threadpool" , false );
     _threadPool = threadPool;
     if  (_threadPool!= < code class="java keyword" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace; background:0px center; border:0px; bottom:auto; float:none; height:auto; left:auto; line-height:20px; margin:0px; outline:0px; overflow:visible; padding:0px; position:static; right:auto; top:auto; vertical-align:baseline; width:auto; min-height:inherit; font-weight:bold!important; color:rgb(51,102,153)!important">null )
         addBean(_threadPool);
}

public  void  setThreadPool(ThreadPool threadPool)
{
     if  (_threadPool!= null )
         removeBean(_threadPool);
     _container.update( this , _threadPool, threadPool,  "threadpool" , false );
     _threadPool = threadPool;
     if  (_threadPool!= null )
         addBean(_threadPool);
}

public  void  setThreadPool(ThreadPool threadPool)

{

     if  (_threadPool!= null )

         rem oveBean(_threadPool);

     _container.update( this , _threadPool, threadPool,  "threadpool" , false );

     _threadPool = threadPool;

     if  (_threadPool!= null )

         addBean(_threadPool);

}

"addConnector" >
    
         class = "org.eclipse.jetty.server.nio.SelectChannelConnector" >
             "host" > "jetty.host" />
             "port" > "jetty.port"  default = "8080" />
             "maxIdleTime" > 3000
             "Acceptors" > 5
             "statsOn" > false
            
             "lowResourcesConnections" > 5000
             "lowResourcesMaxIdleTime" > 5000
        
    

"addConnector" >
    
         class = "org.eclipse.jetty.server.nio.SelectChannelConnector" >
             "host" > "jetty.host" />
             "port" > "jetty.port"  default = "8080" />
             "maxIdleTime" > 3000
             "Acceptors" > 5
             "statsOn" > false
            
             "lowResourcesConnections" > 5000
             "lowResourcesMaxIdleTime" > 5000
        
    

"addConnector" >
    
         class = "org.eclipse.jetty.server.nio.SelectChannelConnector" >
             "host" > "jetty.host" />
             "port" > " jetty.port"  default = "8080" />
             "maxIdleTime" > 3000
             "Acceptors" > 5
             "statsOn" > false
            
             "lowResourcesConnections" > 5000
             "lowResourcesMaxIdleTime" > 5000
        
    

"addConnector" >
    
         class = "org.eclipse.jetty.server.nio.SelectChannelConnector" >
             "host" > "jetty.host" />
             "port" > "jetty.port"  default = "8080" />
             "maxIdleTime" > 3000
             "Acceptors" > 5
             "statsOn" > false
            
             "lowResourcesConnections" > 5000
             "lowResourcesMaxIdleTime" > 5000
        
    

"addConnect or" >
    
         class = "org.eclipse.jetty.server.nio.SelectChannelConnector" >
             "host" > "jetty.host" />
             "port" > "jetty.port"  default = "8080" />
             "maxIdleTime" > 3000
             "Acceptors" > 5
             "statsOn" > false
            
             "lowResourcesConnections" > 5000
             "lowResourcesMaxIdleTime" > 5000
        
    

"addConnector" >

    

         class = "org.eclipse.jetty.server.nio.SelectChannelConnector" >

             "host" > "jetty.host" />

             "port" > "jetty.port"  default = "8080" />

             "maxIdleTime" > 3000

             "Acceptors" > 5

             "statsOn" > false

            

             "lowResourcesConnections" > 5000

             "lowResourcesMaxIdleTime" > 5000

        

    

Leave a Comment

Your email address will not be published.