From 0a03a62ab611631f5acf66c117036e4c81d89ce7 Mon Sep 17 00:00:00 2001 From: Alexander Kazakov Date: Tue, 6 Dec 2016 21:13:28 +0300 Subject: [PATCH] Using ClientConfiguration.DEFAULT_SOCKET_TIMEOUT as default value for read timeout --- docs/plugins/discovery-ec2.asciidoc | 2 +- docs/plugins/repository-s3.asciidoc | 2 +- .../main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java | 5 +++-- .../java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java | 5 +---- .../main/java/org/elasticsearch/cloud/aws/AwsS3Service.java | 5 +++-- .../org/elasticsearch/cloud/aws/InternalAwsS3Service.java | 4 +--- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/docs/plugins/discovery-ec2.asciidoc b/docs/plugins/discovery-ec2.asciidoc index 7116c4b323d..3bb20391d3d 100644 --- a/docs/plugins/discovery-ec2.asciidoc +++ b/docs/plugins/discovery-ec2.asciidoc @@ -133,7 +133,7 @@ with the right signer to use. ===== Read timeout Read timeout determines the amount of time to wait for data to be transferred over an established, -open connection before the connection is timed out. +open connection before the connection is timed out. Defaults to AWS SDK default value (`50 s`). It can be configured with `cloud.aws.read_timeout` (or `cloud.aws.ec2.read_timeout`) setting: [source, yaml] diff --git a/docs/plugins/repository-s3.asciidoc b/docs/plugins/repository-s3.asciidoc index f568c17dcde..1964ae00c0c 100644 --- a/docs/plugins/repository-s3.asciidoc +++ b/docs/plugins/repository-s3.asciidoc @@ -141,7 +141,7 @@ use `S3SignerType`, which is Signature Version 2. ===== Read timeout Read timeout determines the amount of time to wait for data to be transferred over an established, -open connection before the connection is timed out. +open connection before the connection is timed out. Defaults to AWS SDK default value (`50s`). It can be configured with `cloud.aws.read_timeout` (or `cloud.aws.s3.read_timeout`) setting: [source, yaml] diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java index 20c6398fbc2..d15e96f36ab 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java @@ -19,6 +19,7 @@ package org.elasticsearch.cloud.aws; +import com.amazonaws.ClientConfiguration; import com.amazonaws.Protocol; import com.amazonaws.services.ec2.AmazonEC2; import org.elasticsearch.common.settings.Setting; @@ -83,8 +84,8 @@ public interface AwsEc2Service { /** * cloud.aws.read_timeout: Socket read timeout. Shared with repository-s3 plugin */ - Setting READ_TIMEOUT = Setting.timeSetting("cloud.aws.read_timeout", TimeValue.MINUS_ONE, - Property.NodeScope, Property.Shared); + Setting READ_TIMEOUT = Setting.timeSetting("cloud.aws.read_timeout", + TimeValue.timeValueMillis(ClientConfiguration.DEFAULT_SOCKET_TIMEOUT), Property.NodeScope, Property.Shared); /** * Defines specific ec2 settings starting with cloud.aws.ec2. diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java index e35be7332c2..262334c3fa7 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java @@ -125,10 +125,7 @@ public class AwsEc2ServiceImpl extends AbstractComponent implements AwsEc2Servic 10, false); clientConfiguration.setRetryPolicy(retryPolicy); - - if (READ_TIMEOUT.exists(settings) || CLOUD_EC2.READ_TIMEOUT.exists(settings)) { - clientConfiguration.setSocketTimeout((int) CLOUD_EC2.READ_TIMEOUT.get(settings).millis()); - } + clientConfiguration.setSocketTimeout((int) CLOUD_EC2.READ_TIMEOUT.get(settings).millis()); return clientConfiguration; } diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java index 93996ce248a..ddaa45d15fd 100644 --- a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java +++ b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java @@ -19,6 +19,7 @@ package org.elasticsearch.cloud.aws; +import com.amazonaws.ClientConfiguration; import com.amazonaws.Protocol; import com.amazonaws.services.s3.AmazonS3; import org.elasticsearch.common.component.LifecycleComponent; @@ -80,8 +81,8 @@ public interface AwsS3Service extends LifecycleComponent { /** * cloud.aws.read_timeout: Socket read timeout. Shared with discovery-ec2 plugin */ - Setting READ_TIMEOUT = Setting.timeSetting("cloud.aws.read_timeout", TimeValue.MINUS_ONE, - Property.NodeScope, Property.Shared); + Setting READ_TIMEOUT = Setting.timeSetting("cloud.aws.read_timeout", + TimeValue.timeValueMillis(ClientConfiguration.DEFAULT_SOCKET_TIMEOUT), Property.NodeScope, Property.Shared); /** * Defines specific s3 settings starting with cloud.aws.s3. diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java index cdb5e812905..5ecd5f507ad 100644 --- a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java +++ b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java @@ -116,9 +116,7 @@ public class InternalAwsS3Service extends AbstractLifecycleComponent implements AwsSigner.configureSigner(awsSigner, clientConfiguration, endpoint); } - if (READ_TIMEOUT.exists(settings) || CLOUD_S3.READ_TIMEOUT.exists(settings)) { - clientConfiguration.setSocketTimeout((int) CLOUD_S3.READ_TIMEOUT.get(settings).millis()); - } + clientConfiguration.setSocketTimeout((int) CLOUD_S3.READ_TIMEOUT.get(settings).millis()); return clientConfiguration; }