tomcat8关键性源码分析

tomcat8的连接配置如下:
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
      
         maxThreads="1000"
         minSpareThreads="100"
         prestartminSpareThreads =  "true"
         maxQueueSize = "100"

       />

<Connector port="8080" protocol="org.apache.coyote.http11.Http11Nio2Protocol"  
        connectionTimeout="30000"
        redirectPort="8443"
         maxConnections="2000"
        executor="tomcatThreadPool"
        enableLookups="false"
        acceptCount="100"
        maxPostSize="-1"   
        compression="on"        
         disableUploadTimeout="true"   
        compressionMinSize="2048"   
        noCompressionUserAgents="gozilla, traviata"   
        acceptorThreadCount="2"   
        compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/javascript"   
        URIEncoding="utf-8"
      />
protocol用的是:org.apache.coyote.http11.Http11Nio2Protocol,如果配置protocol="HTTP/1.1"就是用的
org.apache.coyote.http11.Http11NioProtocol
,源代码如下,在Connector类中的Connector的构造方法:
    public Connector(String protocol) {
        boolean aprConnector = AprLifecycleListener.isAprAvailable() &&
                AprLifecycleListener.getUseAprConnector();

        if ("HTTP/1.1".equals(protocol) || protocol == null) {
            if (aprConnector) {
                protocolHandlerClassName = "org.apache.coyote.http11.Http11AprProtocol";
            } else {
                protocolHandlerClassName = "org.apache.coyote.http11.Http11NioProtocol";
            }
        } else if ("AJP/1.3".equals(protocol)) {
            if (aprConnector) {
                protocolHandlerClassName = "org.apache.coyote.ajp.AjpAprProtocol";
            } else {
                protocolHandlerClassName = "org.apache.coyote.ajp.AjpNioProtocol";
            }
        } else {
            protocolHandlerClassName = protocol;
        }
Executor中的maxThreads和maxConnections是在AbstractProcotol中,如下:
    public int getMaxThreads() { return endpoint.getMaxThreads(); }
    public void setMaxThreads(int maxThreads) {
        endpoint.setMaxThreads(maxThreads);
    }

    public int getMaxConnections() { return endpoint.getMaxConnections(); }
    public void setMaxConnections(int maxConnections) {
        endpoint.setMaxConnections(maxConnections);
    }
到此为止,server.xml中相关的配置就通过源码解释完毕了。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值