Java Code Examples for com.aliyun.oss.ClientBuilderConfiguration#setIdleConnectionTime()
The following examples show how to use
com.aliyun.oss.ClientBuilderConfiguration#setIdleConnectionTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AliOssAutoConfiguration.java From magic-starter with GNU Lesser General Public License v3.0 | 6 votes |
@Bean(destroyMethod = "shutdown") @ConditionalOnMissingBean public OSSClient ossClient() { // 创建ClientConfiguration。ClientConfiguration是OSSClient的配置类,可配置代理、连接超时、最大连接数等参数。 ClientBuilderConfiguration config = new ClientBuilderConfiguration(); // 设置OSSClient允许打开的最大HTTP连接数,默认为1024个。 config.setMaxConnections(1024); // 设置Socket层传输数据的超时时间,默认为50000毫秒。 config.setSocketTimeout(50000); // 设置建立连接的超时时间,默认为50000毫秒。 config.setConnectionTimeout(50000); // 设置从连接池中获取连接的超时时间(单位:毫秒),默认不超时。 config.setConnectionRequestTimeout(1000); // 设置连接空闲超时时间。超时则关闭连接,默认为60000毫秒。 config.setIdleConnectionTime(60000); // 设置失败请求重试次数,默认为3次。 config.setMaxErrorRetry(5); // 配置协议 config.setProtocol(ossProperties.getAliOss() .getHttps() ? Protocol.HTTPS : Protocol.HTTP); return (OSSClient) new OSSClientBuilder().build(ossProperties.getAliOss() .getEndpoint(), ossProperties.getAliOss() .getAccessKey(), ossProperties.getAliOss() .getSecretKey(), config); }
Example 2
Source File: AliYunOSSAutoConfiguration.java From jeecg-boot-with-activiti with MIT License | 6 votes |
@Bean @ConditionalOnMissingBean public ClientBuilderConfiguration clientConfiguration(OSSProperties ossProperties) { Properties properties = asProperties(ossProperties.getProperties()); ClientBuilderConfiguration configuration = new ClientBuilderConfiguration(); configuration.setMaxConnections(Integer.parseInt(properties.getProperty("aliyun.maxConnections", "5"))); configuration.setSocketTimeout(Integer.parseInt(properties.getProperty("aliyun.socketTimeout", "50000"))); configuration .setConnectionTimeout(Integer.parseInt(properties.getProperty("aliyun.connectionTimeout", "50000"))); configuration.setConnectionRequestTimeout( Integer.parseInt(properties.getProperty("aliyun.connectionRequestTimeout", "-1"))); configuration .setIdleConnectionTime(Integer.parseInt(properties.getProperty("aliyun.idleConnectionTime", "60000"))); configuration.setMaxErrorRetry(Integer.parseInt(properties.getProperty("aliyun.maxErrorRetry", "3"))); configuration.setSupportCname(Boolean.parseBoolean(properties.getProperty("aliyun.supportCname", "false"))); configuration.setSLDEnabled(Boolean.parseBoolean(properties.getProperty("aliyun.sldEnabled", "false"))); configuration.setProtocol(Protocol.HTTP); if (Protocol.HTTPS.toString().equals(properties.getProperty("aliyun.protocol"))) { configuration.setProtocol(Protocol.HTTPS); } if (properties.getProperty("aliyun.userAgent") != null) { configuration.setUserAgent(properties.getProperty("aliyun.userAgent")); } return configuration; }
Example 3
Source File: OssDownload.java From tools with MIT License | 5 votes |
private void ossInit() { ClientBuilderConfiguration conf = new ClientBuilderConfiguration(); conf.setMaxConnections(this.ossMeta.getMaxConnections()); conf.setSocketTimeout(this.ossMeta.getSocketTimeout()); conf.setConnectionTimeout(this.ossMeta.getConnectionTimeout()); conf.setIdleConnectionTime(this.ossMeta.getIdleTime()); this.ossClient = new OSSClientBuilder().build(this.ossMeta.getEndPoint(), this.aliyunMeta.getAccessKey(), this.aliyunMeta.getAccessKeySecret(), conf); }
Example 4
Source File: SimpleOssUpload.java From tools with MIT License | 5 votes |
private void ossInit() { ClientBuilderConfiguration conf = new ClientBuilderConfiguration(); conf.setMaxConnections(this.ossMeta.getMaxConnections()); conf.setSocketTimeout(this.ossMeta.getSocketTimeout()); conf.setConnectionTimeout(this.ossMeta.getConnectionTimeout()); conf.setIdleConnectionTime(this.ossMeta.getIdleTime()); this.ossClient = new OSSClientBuilder().build(this.ossMeta.getEndPoint(), this.aliyunMeta.getAccessKey(), this.aliyunMeta.getAccessKeySecret(), conf); }