diff --git a/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java b/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java index efa2dc85f4a..722324c7854 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java +++ b/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java @@ -63,8 +63,8 @@ public class AwsEc2Service extends AbstractLifecycleComponent { } ClientConfiguration clientConfiguration = new ClientConfiguration(); - String protocol = componentSettings.get("protocol", "https").toLowerCase(); - protocol = componentSettings.get("ec2.protocol", protocol).toLowerCase(); + String protocol = settings.get("cloud.aws.protocol", "https").toLowerCase(); + protocol = settings.get("cloud.aws.ec2.protocol", protocol).toLowerCase(); if ("http".equals(protocol)) { clientConfiguration.setProtocol(Protocol.HTTP); } else if ("https".equals(protocol)) { @@ -72,12 +72,12 @@ public class AwsEc2Service extends AbstractLifecycleComponent { } else { throw new ElasticsearchIllegalArgumentException("No protocol supported [" + protocol + "], can either be [http] or [https]"); } - String account = componentSettings.get("access_key", settings.get("cloud.account")); - String key = componentSettings.get("secret_key", settings.get("cloud.key")); + String account = settings.get("cloud.aws.access_key", settings.get("cloud.account")); + String key = settings.get("cloud.aws.secret_key", settings.get("cloud.key")); - String proxyHost = componentSettings.get("proxy_host"); + String proxyHost = settings.get("cloud.aws.proxy_host"); if (proxyHost != null) { - String portString = componentSettings.get("proxy_port", "80"); + String portString = settings.get("cloud.aws.proxy_port", "80"); Integer proxyPort; try { proxyPort = Integer.parseInt(portString, 10); @@ -103,12 +103,12 @@ public class AwsEc2Service extends AbstractLifecycleComponent { this.client = new AmazonEC2Client(credentials, clientConfiguration); - if (componentSettings.get("ec2.endpoint") != null) { - String endpoint = componentSettings.get("ec2.endpoint"); + if (settings.get("cloud.aws.ec2.endpoint") != null) { + String endpoint = settings.get("cloud.aws.ec2.endpoint"); logger.debug("using explicit ec2 endpoint [{}]", endpoint); client.setEndpoint(endpoint); - } else if (componentSettings.get("region") != null) { - String region = componentSettings.get("region").toLowerCase(); + } else if (settings.get("cloud.aws.region") != null) { + String region = settings.get("cloud.aws.region").toLowerCase(); String endpoint; if (region.equals("us-east-1") || region.equals("us-east")) { endpoint = "ec2.us-east-1.amazonaws.com"; diff --git a/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java b/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java index 9259f72e67d..ebf34ca71ec 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java +++ b/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java @@ -32,7 +32,6 @@ import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsFilter; import java.util.HashMap; import java.util.Map; @@ -55,8 +54,8 @@ public class InternalAwsS3Service extends AbstractLifecycleComponent availabilityZones = Sets.newHashSet(componentSettings.getAsArray("availability_zones")); - if (componentSettings.get("availability_zones") != null) { - availabilityZones.addAll(Strings.commaDelimitedListToSet(componentSettings.get("availability_zones"))); + Set availabilityZones = Sets.newHashSet(settings.getAsArray("discovery.ec2.availability_zones")); + if (settings.get("discovery.ec2.availability_zones") != null) { + availabilityZones.addAll(Strings.commaDelimitedListToSet(settings.get("discovery.ec2.availability_zones"))); } this.availabilityZones = ImmutableSet.copyOf(availabilityZones); diff --git a/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java b/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java index de85ce1d931..80e5c0226d0 100755 --- a/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java +++ b/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java @@ -21,7 +21,6 @@ package org.elasticsearch.discovery.ec2; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; -import org.elasticsearch.cluster.node.DiscoveryNodeService; import org.elasticsearch.cluster.settings.DynamicSettings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -41,9 +40,9 @@ public class Ec2Discovery extends ZenDiscovery { @Inject public Ec2Discovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService, ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService, - DiscoveryNodeService discoveryNodeService, DiscoverySettings discoverySettings, + DiscoverySettings discoverySettings, ElectMasterService electMasterService, DynamicSettings dynamicSettings) { super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService, - discoveryNodeService, pingService, electMasterService, discoverySettings, dynamicSettings); + pingService, electMasterService, discoverySettings, dynamicSettings); } } diff --git a/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java b/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java index ac097683982..1c624fc0725 100644 --- a/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java +++ b/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java @@ -74,15 +74,15 @@ public class S3Repository extends BlobStoreRepository { public S3Repository(RepositoryName name, RepositorySettings repositorySettings, IndexShardRepository indexShardRepository, AwsS3Service s3Service) throws IOException { super(name.getName(), repositorySettings, indexShardRepository); - String bucket = repositorySettings.settings().get("bucket", componentSettings.get("bucket")); + String bucket = repositorySettings.settings().get("bucket", settings.get("repositories.s3.bucket")); if (bucket == null) { throw new RepositoryException(name.name(), "No bucket defined for s3 gateway"); } - String endpoint = repositorySettings.settings().get("endpoint", componentSettings.get("endpoint")); - String protocol = repositorySettings.settings().get("protocol", componentSettings.get("protocol")); + String endpoint = repositorySettings.settings().get("endpoint", settings.get("repositories.s3.endpoint")); + String protocol = repositorySettings.settings().get("protocol", settings.get("repositories.s3.protocol")); - String region = repositorySettings.settings().get("region", componentSettings.get("region")); + String region = repositorySettings.settings().get("region", settings.get("repositories.s3.region")); if (region == null) { // Bucket setting is not set - use global region setting String regionSetting = repositorySettings.settings().get("cloud.aws.region", settings.get("cloud.aws.region")); @@ -113,11 +113,11 @@ public class S3Repository extends BlobStoreRepository { } } - boolean serverSideEncryption = repositorySettings.settings().getAsBoolean("server_side_encryption", componentSettings.getAsBoolean("server_side_encryption", false)); - ByteSizeValue bufferSize = repositorySettings.settings().getAsBytesSize("buffer_size", componentSettings.getAsBytesSize("buffer_size", null)); - Integer maxRetries = repositorySettings.settings().getAsInt("max_retries", componentSettings.getAsInt("max_retries", 3)); - this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size", componentSettings.getAsBytesSize("chunk_size", new ByteSizeValue(100, ByteSizeUnit.MB))); - this.compress = repositorySettings.settings().getAsBoolean("compress", componentSettings.getAsBoolean("compress", false)); + boolean serverSideEncryption = repositorySettings.settings().getAsBoolean("server_side_encryption", settings.getAsBoolean("repositories.s3.server_side_encryption", false)); + ByteSizeValue bufferSize = repositorySettings.settings().getAsBytesSize("buffer_size", settings.getAsBytesSize("repositories.s3.buffer_size", null)); + Integer maxRetries = repositorySettings.settings().getAsInt("max_retries", settings.getAsInt("repositories.s3.max_retries", 3)); + this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size", settings.getAsBytesSize("repositories.s3.chunk_size", new ByteSizeValue(100, ByteSizeUnit.MB))); + this.compress = repositorySettings.settings().getAsBoolean("compress", settings.getAsBoolean("repositories.s3.compress", false)); logger.debug("using bucket [{}], region [{}], endpoint [{}], protocol [{}], chunk_size [{}], server_side_encryption [{}], buffer_size [{}], max_retries [{}]", bucket, region, endpoint, protocol, chunkSize, serverSideEncryption, bufferSize, maxRetries); diff --git a/src/test/java/org/elasticsearch/cloud/aws/TestAmazonS3.java b/src/test/java/org/elasticsearch/cloud/aws/TestAmazonS3.java index cdf167be794..a3c26b48160 100644 --- a/src/test/java/org/elasticsearch/cloud/aws/TestAmazonS3.java +++ b/src/test/java/org/elasticsearch/cloud/aws/TestAmazonS3.java @@ -64,11 +64,11 @@ public class TestAmazonS3 extends AmazonS3Wrapper { return 1; } - public TestAmazonS3(AmazonS3 delegate, Settings componentSettings) { + public TestAmazonS3(AmazonS3 delegate, Settings settings) { super(delegate); - randomPrefix = componentSettings.get("test.random"); - writeFailureRate = componentSettings.getAsDouble("test.write_failures", 0.0); - readFailureRate = componentSettings.getAsDouble("test.read_failures", 0.0); + randomPrefix = settings.get("cloud.aws.test.random"); + writeFailureRate = settings.getAsDouble("cloud.aws.test.write_failures", 0.0); + readFailureRate = settings.getAsDouble("cloud.aws.test.read_failures", 0.0); } @Override diff --git a/src/test/java/org/elasticsearch/cloud/aws/TestAwsS3Service.java b/src/test/java/org/elasticsearch/cloud/aws/TestAwsS3Service.java index ec1e84ad757..920441a51ba 100644 --- a/src/test/java/org/elasticsearch/cloud/aws/TestAwsS3Service.java +++ b/src/test/java/org/elasticsearch/cloud/aws/TestAwsS3Service.java @@ -22,7 +22,6 @@ import com.amazonaws.services.s3.AmazonS3; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsFilter; import java.util.IdentityHashMap; @@ -57,7 +56,7 @@ public class TestAwsS3Service extends InternalAwsS3Service { private AmazonS3 cachedWrapper(AmazonS3 client) { TestAmazonS3 wrapper = clients.get(client); if (wrapper == null) { - wrapper = new TestAmazonS3(client, componentSettings); + wrapper = new TestAmazonS3(client, settings); clients.put(client, wrapper); } return wrapper;