ApacheHttpClientConfigurations.java org::apache::iceberg::aws::ApacheHttpClientConfigurations org::apache::iceberg::aws /* *LicensedtotheApacheSoftwareFoundation(ASF)underone *ormorecontributorlicenseagreements.SeetheNOTICEfile *distributedwiththisworkforadditionalinformation *regardingcopyrightownership.TheASFlicensesthisfile *toyouundertheApacheLicense,Version2.0(the *"License");youmaynotusethisfileexceptincompliance *withtheLicense.YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting, *softwaredistributedundertheLicenseisdistributedonan *"ASIS"BASIS,WITHOUTWARRANTIESORCONDITIONSOFANY *KIND,eitherexpressorimplied.SeetheLicenseforthe *specificlanguagegoverningpermissionsandlimitations *undertheLicense. */ packageorg.apache.iceberg.aws; importjava.net.URI; importjava.time.Duration; importjava.util.Map; importorg.apache.iceberg.relocated.com.google.common.annotations.VisibleForTesting; importorg.apache.iceberg.util.PropertyUtil; importsoftware.amazon.awssdk.awscore.client.builder.AwsSyncClientBuilder; importsoftware.amazon.awssdk.http.apache.ApacheHttpClient; importsoftware.amazon.awssdk.http.apache.ProxyConfiguration; classApacheHttpClientConfigurations{ privateLongconnectionTimeoutMs; privateLongsocketTimeoutMs; privateLongacquisitionTimeoutMs; privateLongconnectionMaxIdleTimeMs; privateLongconnectionTimeToLiveMs; privateBooleanexpectContinueEnabled; privateIntegermaxConnections; privateBooleantcpKeepAliveEnabled; privateBooleanuseIdleConnectionReaperEnabled; privateStringproxyEndpoint; privateApacheHttpClientConfigurations(){} public<TextendsAwsSyncClientBuilder>voidconfigureHttpClientBuilder(TawsClientBuilder){ ApacheHttpClient.BuilderapacheHttpClientBuilder=ApacheHttpClient.builder(); configureApacheHttpClientBuilder(apacheHttpClientBuilder); awsClientBuilder.httpClientBuilder(apacheHttpClientBuilder); } privatevoidinitialize(Map<String,String>httpClientProperties){ this.connectionTimeoutMs= PropertyUtil.propertyAsNullableLong( httpClientProperties,HttpClientProperties.APACHE_CONNECTION_TIMEOUT_MS); this.socketTimeoutMs= PropertyUtil.propertyAsNullableLong( httpClientProperties,HttpClientProperties.APACHE_SOCKET_TIMEOUT_MS); this.acquisitionTimeoutMs= PropertyUtil.propertyAsNullableLong( httpClientProperties,HttpClientProperties.APACHE_CONNECTION_ACQUISITION_TIMEOUT_MS); this.connectionMaxIdleTimeMs= PropertyUtil.propertyAsNullableLong( httpClientProperties,HttpClientProperties.APACHE_CONNECTION_MAX_IDLE_TIME_MS); this.connectionTimeToLiveMs= PropertyUtil.propertyAsNullableLong( httpClientProperties,HttpClientProperties.APACHE_CONNECTION_TIME_TO_LIVE_MS); this.expectContinueEnabled= PropertyUtil.propertyAsNullableBoolean( httpClientProperties,HttpClientProperties.APACHE_EXPECT_CONTINUE_ENABLED); this.maxConnections= PropertyUtil.propertyAsNullableInt( httpClientProperties,HttpClientProperties.APACHE_MAX_CONNECTIONS); this.tcpKeepAliveEnabled= PropertyUtil.propertyAsNullableBoolean( httpClientProperties,HttpClientProperties.APACHE_TCP_KEEP_ALIVE_ENABLED); this.useIdleConnectionReaperEnabled= PropertyUtil.propertyAsNullableBoolean( httpClientProperties,HttpClientProperties.APACHE_USE_IDLE_CONNECTION_REAPER_ENABLED); this.proxyEndpoint= PropertyUtil.propertyAsString( httpClientProperties,HttpClientProperties.PROXY_ENDPOINT,null); } @VisibleForTesting voidconfigureApacheHttpClientBuilder(ApacheHttpClient.BuilderapacheHttpClientBuilder){ if(connectionTimeoutMs!=null){ apacheHttpClientBuilder.connectionTimeout(Duration.ofMillis(connectionTimeoutMs)); } if(socketTimeoutMs!=null){ apacheHttpClientBuilder.socketTimeout(Duration.ofMillis(socketTimeoutMs)); } if(acquisitionTimeoutMs!=null){ apacheHttpClientBuilder.connectionAcquisitionTimeout(Duration.ofMillis(acquisitionTimeoutMs)); } if(connectionMaxIdleTimeMs!=null){ apacheHttpClientBuilder.connectionMaxIdleTime(Duration.ofMillis(connectionMaxIdleTimeMs)); } if(connectionTimeToLiveMs!=null){ apacheHttpClientBuilder.connectionTimeToLive(Duration.ofMillis(connectionTimeToLiveMs)); } if(expectContinueEnabled!=null){ apacheHttpClientBuilder.expectContinueEnabled(expectContinueEnabled); } if(maxConnections!=null){ apacheHttpClientBuilder.maxConnections(maxConnections); } if(tcpKeepAliveEnabled!=null){ apacheHttpClientBuilder.tcpKeepAlive(tcpKeepAliveEnabled); } if(useIdleConnectionReaperEnabled!=null){ apacheHttpClientBuilder.useIdleConnectionReaper(useIdleConnectionReaperEnabled); } if(proxyEndpoint!=null){ apacheHttpClientBuilder.proxyConfiguration( ProxyConfiguration.builder().endpoint(URI.create(proxyEndpoint)).build()); } } publicstaticApacheHttpClientConfigurationscreate(Map<String,String>properties){ ApacheHttpClientConfigurationsconfigurations=newApacheHttpClientConfigurations(); configurations.initialize(properties); returnconfigurations; } }