mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-18 19:05:06 +00:00
Cloud AWS: Change endpoint parameters to distinguish between ec2 and s3, closes #574.
This commit is contained in:
parent
f869951364
commit
9361e3bd2b
@ -70,8 +70,31 @@ public class AwsEc2Service extends AbstractLifecycleComponent<AwsEc2Service> {
|
|||||||
|
|
||||||
this.client = new AmazonEC2Client(new BasicAWSCredentials(account, key), clientConfiguration);
|
this.client = new AmazonEC2Client(new BasicAWSCredentials(account, key), clientConfiguration);
|
||||||
|
|
||||||
if (componentSettings.get("endpoint") != null) {
|
if (componentSettings.get("ec2.endpoint") != null) {
|
||||||
client.setEndpoint(componentSettings.get("endpoint"));
|
client.setEndpoint(componentSettings.get("ec2.endpoint"));
|
||||||
|
} else if (componentSettings.get("region") != null) {
|
||||||
|
String endpoint;
|
||||||
|
String region = componentSettings.get("region");
|
||||||
|
if ("us-east".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "ec2.us-east-1.amazonaws.com";
|
||||||
|
} else if ("us-east-1".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "ec2.us-east-1.amazonaws.com";
|
||||||
|
} else if ("us-west".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "ec2.us-west-1.amazonaws.com";
|
||||||
|
} else if ("us-west-1".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "ec2.us-west-1.amazonaws.com";
|
||||||
|
} else if ("ap-southeast".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "ec2.ap-southeast-1.amazonaws.com";
|
||||||
|
} else if ("ap-southeast-1".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "ec2.ap-southeast-1.amazonaws.com";
|
||||||
|
} else if ("eu-west".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "ec2.eu-west-1.amazonaws.com";
|
||||||
|
} else if ("eu-west-1".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "ec2.eu-west-1.amazonaws.com";
|
||||||
|
} else {
|
||||||
|
throw new ElasticSearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
|
||||||
|
}
|
||||||
|
client.setEndpoint(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.client;
|
return this.client;
|
||||||
|
@ -70,8 +70,31 @@ public class AwsS3Service extends AbstractLifecycleComponent<AwsS3Service> {
|
|||||||
|
|
||||||
this.client = new AmazonS3Client(new BasicAWSCredentials(account, key), clientConfiguration);
|
this.client = new AmazonS3Client(new BasicAWSCredentials(account, key), clientConfiguration);
|
||||||
|
|
||||||
if (componentSettings.get("endpoint") != null) {
|
if (componentSettings.get("s3.endpoint") != null) {
|
||||||
client.setEndpoint(componentSettings.get("endpoint"));
|
client.setEndpoint(componentSettings.get("s3.endpoint"));
|
||||||
|
} else if (componentSettings.get("region") != null) {
|
||||||
|
String endpoint;
|
||||||
|
String region = componentSettings.get("region");
|
||||||
|
if ("us-east".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "s3.amazonaws.com";
|
||||||
|
} else if ("us-east-1".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "s3.amazonaws.com";
|
||||||
|
} else if ("us-west".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "s3-us-west-1.amazonaws.com";
|
||||||
|
} else if ("us-west-1".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "s3-us-west-1.amazonaws.com";
|
||||||
|
} else if ("ap-southeast".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "s3-ap-southeast-1.amazonaws.com";
|
||||||
|
} else if ("ap-southeast-1".equals(region.toLowerCase())) {
|
||||||
|
endpoint = "s3-ap-southeast-1.amazonaws.com";
|
||||||
|
} else if ("eu-west".equals(region.toLowerCase())) {
|
||||||
|
endpoint = null; // no specific endpoint for EU (still can be used for region)
|
||||||
|
} else if ("eu-west-1".equals(region.toLowerCase())) {
|
||||||
|
endpoint = null; // no specific endpoint for EU (still can be used for region)
|
||||||
|
} else {
|
||||||
|
throw new ElasticSearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
|
||||||
|
}
|
||||||
|
client.setEndpoint(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.client;
|
return this.client;
|
||||||
|
@ -35,13 +35,13 @@ import java.io.InputStream;
|
|||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class AbstarctS3BlobContainer extends AbstractBlobContainer {
|
public class AbstractS3BlobContainer extends AbstractBlobContainer {
|
||||||
|
|
||||||
protected final S3BlobStore blobStore;
|
protected final S3BlobStore blobStore;
|
||||||
|
|
||||||
protected final String keyPath;
|
protected final String keyPath;
|
||||||
|
|
||||||
public AbstarctS3BlobContainer(BlobPath path, S3BlobStore blobStore) {
|
public AbstractS3BlobContainer(BlobPath path, S3BlobStore blobStore) {
|
||||||
super(path);
|
super(path);
|
||||||
this.blobStore = blobStore;
|
this.blobStore = blobStore;
|
||||||
this.keyPath = path.buildAsString("/") + "/";
|
this.keyPath = path.buildAsString("/") + "/";
|
@ -31,7 +31,7 @@ import java.io.InputStream;
|
|||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class S3ImmutableBlobContainer extends AbstarctS3BlobContainer implements ImmutableBlobContainer {
|
public class S3ImmutableBlobContainer extends AbstractS3BlobContainer implements ImmutableBlobContainer {
|
||||||
|
|
||||||
public S3ImmutableBlobContainer(BlobPath path, S3BlobStore blobStore) {
|
public S3ImmutableBlobContainer(BlobPath path, S3BlobStore blobStore) {
|
||||||
super(path, blobStore);
|
super(path, blobStore);
|
||||||
|
@ -52,6 +52,28 @@ public class S3Gateway extends BlobStoreGateway {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String region = componentSettings.get("region");
|
String region = componentSettings.get("region");
|
||||||
|
if (region == null) {
|
||||||
|
if (settings.get("cloud.aws.region") != null) {
|
||||||
|
String regionSetting = settings.get("cloud.aws.region");
|
||||||
|
if ("us-east".equals(regionSetting.toLowerCase())) {
|
||||||
|
region = null;
|
||||||
|
} else if ("us-east-1".equals(regionSetting.toLowerCase())) {
|
||||||
|
region = null;
|
||||||
|
} else if ("us-west".equals(regionSetting.toLowerCase())) {
|
||||||
|
region = "us-west-1";
|
||||||
|
} else if ("us-west-1".equals(regionSetting.toLowerCase())) {
|
||||||
|
region = "us-west-1";
|
||||||
|
} else if ("ap-southeast".equals(regionSetting.toLowerCase())) {
|
||||||
|
region = "ap-southeast-1";
|
||||||
|
} else if ("ap-southeast-1".equals(regionSetting.toLowerCase())) {
|
||||||
|
region = "ap-southeast-1";
|
||||||
|
} else if ("eu-west".equals(regionSetting.toLowerCase())) {
|
||||||
|
region = "EU";
|
||||||
|
} else if ("eu-west-1".equals(regionSetting.toLowerCase())) {
|
||||||
|
region = "EU";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ByteSizeValue chunkSize = componentSettings.getAsBytesSize("chunk_size", new ByteSizeValue(100, ByteSizeUnit.MB));
|
ByteSizeValue chunkSize = componentSettings.getAsBytesSize("chunk_size", new ByteSizeValue(100, ByteSizeUnit.MB));
|
||||||
|
|
||||||
logger.debug("using bucket [{}], region [{}], chunk_size [{}]", bucket, region, chunkSize);
|
logger.debug("using bucket [{}], region [{}], chunk_size [{}]", bucket, region, chunkSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user