最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

AsyncHttpClient的默認(rèn)配置源碼流程解讀

 更新時(shí)間:2023年12月06日 09:39:50   作者:codecraft  
這篇文章主要為大家介紹了AsyncHttpClient的默認(rèn)配置源碼流程解讀,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

本文主要研究一下AsyncHttpClient的默認(rèn)配置

maven

<dependency>
            <groupId>org.asynchttpclient</groupId>
            <artifactId>async-http-client</artifactId>
            <version>2.2.0</version>
        </dependency>

AsyncHttpClientConfig

org/asynchttpclient/AsyncHttpClientConfig.java

public interface AsyncHttpClientConfig {
  /**
   * @return the version of AHC
   */
  String getAhcVersion();
  /**
   * Return the name of {@link AsyncHttpClient}, which is used for thread naming and debugging.
   *
   * @return the name.
   */
  String getThreadPoolName();
  /**
   * Return the maximum number of connections an {@link AsyncHttpClient} can handle.
   *
   * @return the maximum number of connections an {@link AsyncHttpClient} can handle.
   */
  int getMaxConnections();
  /**
   * Return the maximum number of connections per hosts an {@link AsyncHttpClient} can handle.
   *
   * @return the maximum number of connections per host an {@link AsyncHttpClient} can handle.
   */
  int getMaxConnectionsPerHost();
  /**
   * Return the maximum time in millisecond an {@link AsyncHttpClient} can wait when connecting to a remote host
   *
   * @return the maximum time in millisecond an {@link AsyncHttpClient} can wait when connecting to a remote host
   */
  int getConnectTimeout();
  /**
   * Return the maximum time in millisecond an {@link AsyncHttpClient} can stay idle.
   *
   * @return the maximum time in millisecond an {@link AsyncHttpClient} can stay idle.
   */
  int getReadTimeout();
  /**
   * Return the maximum time in millisecond an {@link AsyncHttpClient} will keep connection in pool.
   *
   * @return the maximum time in millisecond an {@link AsyncHttpClient} will keep connection in pool.
   */
  int getPooledConnectionIdleTimeout();
  /**
   * @return the period in millis to clean the pool of dead and idle connections.
   */
  int getConnectionPoolCleanerPeriod();
  /**
   * Return the maximum time in millisecond an {@link AsyncHttpClient} waits until the response is completed.
   *
   * @return the maximum time in millisecond an {@link AsyncHttpClient} waits until the response is completed.
   */
  int getRequestTimeout();
  /**
   * Is HTTP redirect enabled
   *
   * @return true if enabled.
   */
  boolean isFollowRedirect();
  /**
   * Get the maximum number of HTTP redirect
   *
   * @return the maximum number of HTTP redirect
   */
  int getMaxRedirects();
  /**
   * Is the {@link ChannelPool} support enabled.
   *
   * @return true if keep-alive is enabled
   */
  boolean isKeepAlive();
  /**
   * Return the USER_AGENT header value
   *
   * @return the USER_AGENT header value
   */
  String getUserAgent();
  /**
   * Is HTTP compression enforced.
   *
   * @return true if compression is enforced
   */
  boolean isCompressionEnforced();
  /**
   * Return the {@link java.util.concurrent.ThreadFactory} an {@link AsyncHttpClient} use for handling asynchronous response.
   *
   * @return the {@link java.util.concurrent.ThreadFactory} an {@link AsyncHttpClient} use for handling asynchronous response. If no {@link ThreadFactory} has been explicitly
   * provided, this method will return <code>null</code>
   */
  ThreadFactory getThreadFactory();
  /**
   * An instance of {@link ProxyServer} used by an {@link AsyncHttpClient}
   *
   * @return instance of {@link ProxyServer}
   */
  ProxyServerSelector getProxyServerSelector();
  /**
   * Return an instance of {@link SslContext} used for SSL connection.
   *
   * @return an instance of {@link SslContext} used for SSL connection.
   */
  SslContext getSslContext();
  /**
   * Return the current {@link Realm}
   *
   * @return the current {@link Realm}
   */
  Realm getRealm();
  /**
   * Return the list of {@link RequestFilter}
   *
   * @return Unmodifiable list of {@link ResponseFilter}
   */
  List<RequestFilter> getRequestFilters();
  /**
   * Return the list of {@link ResponseFilter}
   *
   * @return Unmodifiable list of {@link ResponseFilter}
   */
  List<ResponseFilter> getResponseFilters();
  /**
   * Return the list of {@link java.io.IOException}
   *
   * @return Unmodifiable list of {@link java.io.IOException}
   */
  List<IOExceptionFilter> getIoExceptionFilters();
  /**
   * Return cookie store that is used to store and retrieve cookies
   *
   * @return {@link CookieStore} object
   */
  CookieStore getCookieStore();
  /**
   * Return the number of time the library will retry when an {@link java.io.IOException} is throw by the remote server
   *
   * @return the number of time the library will retry when an {@link java.io.IOException} is throw by the remote server
   */
  int getMaxRequestRetry();
  /**
   * @return the disableUrlEncodingForBoundRequests
   */
  boolean isDisableUrlEncodingForBoundRequests();
  /**
   * @return true if AHC is to use a LAX cookie encoder, eg accept illegal chars in cookie value
   */
  boolean isUseLaxCookieEncoder();
  /**
   * In the case of a POST/Redirect/Get scenario where the server uses a 302 for the redirect, should AHC respond to the redirect with a GET or whatever the original method was.
   * Unless configured otherwise, for a 302, AHC, will use a GET for this case.
   *
   * @return <code>true</code> if strict 302 handling is to be used, otherwise <code>false</code>.
   */
  boolean isStrict302Handling();
  /**
   * @return the maximum time in millisecond an {@link AsyncHttpClient} will keep connection in the pool, or -1 to keep connection while possible.
   */
  int getConnectionTtl();
  boolean isUseOpenSsl();
  boolean isUseInsecureTrustManager();
  /**
   * @return true to disable all HTTPS behaviors AT ONCE, such as hostname verification and SNI
   */
  boolean isDisableHttpsEndpointIdentificationAlgorithm();
  /**
   * @return the array of enabled protocols
   */
  String[] getEnabledProtocols();
  /**
   * @return the array of enabled cipher suites
   */
  String[] getEnabledCipherSuites();
  /**
   * @return the size of the SSL session cache, 0 means using the default value
   */
  int getSslSessionCacheSize();
  /**
   * @return the SSL session timeout in seconds, 0 means using the default value
   */
  int getSslSessionTimeout();
  //......
}
AsyncHttpClientConfig接口定義了一系列獲取配置的接口,比如getMaxConnections、getConnectTimeout、getReadTimeout、getPooledConnectionIdleTimeout等

DefaultAsyncHttpClientConfig

org/asynchttpclient/DefaultAsyncHttpClientConfig.java

public class DefaultAsyncHttpClientConfig implements AsyncHttpClientConfig {
  //......
  public static class Builder {
      // timeouts
      // keep-alive
      // ssl
      // cookie store
      // tuning
      // internals
  }
}
DefaultAsyncHttpClientConfig實(shí)現(xiàn)了AsyncHttpClientConfig接口,它還定義了一個(gè)Builder來(lái)用于創(chuàng)建AsyncHttpClient,其配置主要分為timeouts、keep-alive、ssl、cookie store、tuning、internals幾個(gè)部分,它們的默認(rèn)值讀取的是jar包的ahc-default.properties的配置

timeouts

// org.asynchttpclient.connectTimeout=5000
    private int connectTimeout = defaultConnectTimeout();
    // org.asynchttpclient.requestTimeout=60000
    private int requestTimeout = defaultRequestTimeout();
    // org.asynchttpclient.readTimeout=60000
    private int readTimeout = defaultReadTimeout();
    // org.asynchttpclient.shutdownQuietPeriod=2000
    private int shutdownQuietPeriod = defaultShutdownQuietPeriod();
    // org.asynchttpclient.shutdownTimeout=15000
    private int shutdownTimeout = defaultShutdownTimeout();
connectTimeout默認(rèn)為5s、requestTimeout默認(rèn)為60s、readTimeout默認(rèn)為60s、shutdownQuietPeriod默認(rèn)為2s、shutdownTimeout默認(rèn)為15s

keep-alive

// org.asynchttpclient.keepAlive=true
    private boolean keepAlive = defaultKeepAlive();
    // org.asynchttpclient.pooledConnectionIdleTimeout=60000
    private int pooledConnectionIdleTimeout = defaultPooledConnectionIdleTimeout();
    // org.asynchttpclient.connectionPoolCleanerPeriod=1000
    private int connectionPoolCleanerPeriod = defaultConnectionPoolCleanerPeriod();
    // org.asynchttpclient.connectionTtl=-1
    private int connectionTtl = defaultConnectionTtl();
    // org.asynchttpclient.maxConnections=-1
    private int maxConnections = defaultMaxConnections();
    // org.asynchttpclient.maxConnectionsPerHost=-1
    private int maxConnectionsPerHost = defaultMaxConnectionsPerHost();
    private ChannelPool channelPool;
    private KeepAliveStrategy keepAliveStrategy = new DefaultKeepAliveStrategy();
默認(rèn)開(kāi)啟keepAlive、pooledConnectionIdleTimeout默認(rèn)為60s、connectionPoolCleanerPeriod默認(rèn)為1s、connectionTtl默認(rèn)為-1、maxConnectionsPerHost默認(rèn)為-1

tuning

// org.asynchttpclient.tcpNoDelay=true
    private boolean tcpNoDelay = defaultTcpNoDelay();
    // org.asynchttpclient.soReuseAddress=false
    private boolean soReuseAddress = defaultSoReuseAddress();
    // org.asynchttpclient.soLinger=-1
    private int soLinger = defaultSoLinger();
    // org.asynchttpclient.soSndBuf=-1
    private int soSndBuf = defaultSoSndBuf();
    // org.asynchttpclient.soRcvBuf=-1
    private int soRcvBuf = defaultSoRcvBuf();
tcpNoDelay默認(rèn)為true、soReuseAddress默認(rèn)為false、soLinger、soSndBuf、soRcvBuf默認(rèn)為-1

internals

// org.asynchttpclient.threadPoolName=AsyncHttpClient
    private String threadPoolName = defaultThreadPoolName();
    // org.asynchttpclient.httpClientCodecMaxInitialLineLength=4096
    private int httpClientCodecMaxInitialLineLength = defaultHttpClientCodecMaxInitialLineLength();
    // org.asynchttpclient.httpClientCodecMaxHeaderSize=8192
    private int httpClientCodecMaxHeaderSize = defaultHttpClientCodecMaxHeaderSize();
    // org.asynchttpclient.httpClientCodecMaxChunkSize=8192
    private int httpClientCodecMaxChunkSize = defaultHttpClientCodecMaxChunkSize();
    // org.asynchttpclient.httpClientCodecInitialBufferSize=128
    private int httpClientCodecInitialBufferSize = defaultHttpClientCodecInitialBufferSize();
    // org.asynchttpclient.chunkedFileChunkSize=8192
    private int chunkedFileChunkSize = defaultChunkedFileChunkSize();
    // org.asynchttpclient.useNativeTransport=false
    private boolean useNativeTransport = defaultUseNativeTransport();
    private ByteBufAllocator allocator;
    private Map<ChannelOption<Object>, Object> channelOptions = new HashMap<>();
    private EventLoopGroup eventLoopGroup;
    private Timer nettyTimer;
    private ThreadFactory threadFactory;
    private Consumer<Channel> httpAdditionalChannelInitializer;
    private Consumer<Channel> wsAdditionalChannelInitializer;
    private ResponseBodyPartFactory responseBodyPartFactory = ResponseBodyPartFactory.EAGER;
    // org.asynchttpclient.ioThreadsCount=0
    private int ioThreadsCount = defaultIoThreadsCount();
threadPoolName默認(rèn)為AsyncHttpClient、httpClientCodecMaxInitialLineLength默認(rèn)為4096、httpClientCodecMaxHeaderSize默認(rèn)為8192、httpClientCodecMaxChunkSize默認(rèn)為8192、httpClientCodecInitialBufferSize默認(rèn)為128、chunkedFileChunkSize默認(rèn)為8192、ioThreadsCount默認(rèn)為0

小結(jié)

DefaultAsyncHttpClientConfig實(shí)現(xiàn)了AsyncHttpClientConfig接口,它還定義了一個(gè)Builder來(lái)用于創(chuàng)建AsyncHttpClient,其配置主要分為timeouts、keep-alive、ssl、cookie store、tuning、internals幾個(gè)部分,它們的默認(rèn)值讀取的是jar包的ahc-default.properties的配置。

以上就是AsyncHttpClient的默認(rèn)配置源碼流程解讀的詳細(xì)內(nèi)容,更多關(guān)于AsyncHttpClient默認(rèn)配置的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • java中串行流和并行流區(qū)別小結(jié)

    java中串行流和并行流區(qū)別小結(jié)

    串行流和并行流是兩種處理流操作的方式,串行流適用于小數(shù)據(jù)量且簡(jiǎn)單的數(shù)據(jù)處理,并行流則適用于大規(guī)模數(shù)據(jù)處理和需要并行計(jì)算的場(chǎng)景,能夠利用多線程并行處理,選擇使用哪種流取決于數(shù)據(jù)量大小、處理復(fù)雜度和是否需要并行計(jì)算,下面就來(lái)具體介紹一下兩者的區(qū)別
    2024-09-09
  • 淺談一下單體架構(gòu)的缺點(diǎn)是什么

    淺談一下單體架構(gòu)的缺點(diǎn)是什么

    這篇文章主要介紹了單體架構(gòu)的缺點(diǎn)是什么,通常我們所使用的傳統(tǒng)單體應(yīng)用架構(gòu)都是模塊化的設(shè)計(jì)邏輯,程序在編寫完成后會(huì)被打包并部署為一個(gè)具體的應(yīng)用,而應(yīng)用的格式則依賴于相應(yīng)的應(yīng)用語(yǔ)言和框架,需要的朋友可以參考下
    2023-04-04
  • MyBatis元素resultMap介紹及使用詳解

    MyBatis元素resultMap介紹及使用詳解

    這篇文章主要介紹了MyBatis元素resultMap介紹及使用,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • 淺析scala中map與flatMap的區(qū)別

    淺析scala中map與flatMap的區(qū)別

    這篇文章主要介紹了淺析scala中map與flatMap的區(qū)別,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-06-06
  • Spring事務(wù)Transaction配置的五種注入方式詳解

    Spring事務(wù)Transaction配置的五種注入方式詳解

    這篇文章主要介紹了Spring事務(wù)Transaction配置的五種注入方式詳解,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2017-04-04
  • mybatisplus 配置二級(jí)緩存及實(shí)戰(zhàn)示例

    mybatisplus 配置二級(jí)緩存及實(shí)戰(zhàn)示例

    這篇文章主要介紹了mybatisplus 配置二級(jí)緩存及實(shí)戰(zhàn)示例,包含基礎(chǔ)配置、高級(jí)特征及實(shí)戰(zhàn)示例,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),感興趣的朋友一起看看吧
    2025-08-08
  • 在Spring中使用JDBC和JDBC模板的講解

    在Spring中使用JDBC和JDBC模板的講解

    今天小編就為大家分享一篇關(guān)于在Spring中使用JDBC和JDBC模板的講解,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2019-01-01
  • Java禁止使用finalize方法

    Java禁止使用finalize方法

    這篇文章主要介紹了Java禁止使用finalize方法,需要的朋友可以參考下
    2017-10-10
  • Java基礎(chǔ)知識(shí)總結(jié)之繼承

    Java基礎(chǔ)知識(shí)總結(jié)之繼承

    這一篇我們來(lái)學(xué)習(xí)面向?qū)ο蟮牡诙€(gè)特征——繼承,文中有非常詳細(xì)的基礎(chǔ)知識(shí)總結(jié),對(duì)正在學(xué)習(xí)java的小伙伴們很有幫助,需要的朋友可以參考下
    2021-06-06
  • Mybatis的核心架構(gòu)及源碼解讀

    Mybatis的核心架構(gòu)及源碼解讀

    這篇文章主要介紹了Mybatis的核心架構(gòu)及源碼解讀,mybatis是一款半自動(dòng)化的持久層框架,它封裝了JDBC操作,支持定制化SQL,高級(jí)映射,但它的數(shù)據(jù)庫(kù)無(wú)關(guān)性較低,需要的朋友可以參考下
    2023-08-08

最新評(píng)論

黄龙县| 新兴县| 无为县| 石泉县| 全南县| 周口市| 汤阴县| 额尔古纳市| 冕宁县| 汉阴县| 龙口市| 定结县| 金阳县| 客服| 瓮安县| 镇雄县| 双鸭山市| 尉犁县| 南城县| 扎囊县| 紫金县| 赣州市| 乐安县| 搜索| 富宁县| 婺源县| 永州市| 池州市| 泾川县| 恩平市| 济宁市| 志丹县| 中江县| 木兰县| 汤阴县| 泾川县| 尉氏县| 喀喇沁旗| 宜城市| 泾川县| 汾西县|