本文整理了Java中com.amazonaws.regions.Region.getServiceEndpoint
方法的一些代码示例,展示了Region.getServiceEndpoint
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Region.getServiceEndpoint
方法的具体详情如下:
包路径:com.amazonaws.regions.Region
类名称:Region
方法名:getServiceEndpoint
[英]Returns the endpoint for the service given.
[中]返回给定服务的终结点。
代码示例来源:origin: aws/aws-sdk-java
@Override
public URI getServiceEndpoint() {
String serviceEndpoint = region.getServiceEndpoint(serviceName);
if (serviceEndpoint == null) {
serviceEndpoint = String.format("%s.%s.%s", serviceName, region.getName(), region.getDomain());
log.info("{" + serviceName + ", " + region.getName() + "} was not "
+ "found in region metadata, trying to construct an "
+ "endpoint using the standard pattern for this region: '" + serviceEndpoint + "'.");
}
return toURI(stripProtocol(serviceEndpoint));
}
代码示例来源:origin: aws/aws-sdk-java
@SdkTestInternalApi
SnsMessageManager(String region, SignatureVerifier signatureVerifier) {
this.endpoint = RegionUtils.getRegion(region).getServiceEndpoint(AmazonSNS.ENDPOINT_PREFIX);
this.signatureVerifier = signatureVerifier;
this.messageUnmarshaller = new SnsMessageUnmarshaller(client);
}
代码示例来源:origin: aws/aws-sdk-java
private URI createEndpoint(String regionName, String serviceName) {
final Region region = RegionUtils.getRegion(regionName);
if (region == null) {
throw new AmazonClientException("{" + serviceName + ", " + regionName + "} was not "
+ "found in region metadata. Update to latest version of SDK and try again.");
}
return toURI(region.getServiceEndpoint(serviceName));
}
代码示例来源:origin: aws/aws-sdk-java
private URI createEndpoint(String regionName, String serviceName) {
final Region region = RegionUtils.getRegion(regionName);
if (region == null) {
throw new AmazonClientException("{" + serviceName + ", " + regionName + "} was not "
+ "found in region metadata. Update to latest version of SDK and try again.");
}
return toURI(region.getServiceEndpoint(serviceName));
}
代码示例来源:origin: apache/nifi
protected String getUrlForObject(final String bucket, final String key) {
Region region = getRegion();
if (region == null) {
return DEFAULT_PROTOCOL.toString() + "://s3.amazonaws.com/" + bucket + "/" + key;
} else {
final String endpoint = region.getServiceEndpoint("s3");
return DEFAULT_PROTOCOL.toString() + "://" + endpoint + "/" + bucket + "/" + key;
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Creates an {@link SnsMessageManager} pinned to the given region. This handler will throw an exception if it
* recieves a message from another region. If you must handle messages from multiple regions then you should
* maintain a cache of region to {@link SnsMessageManager} instances.
*
* @param region Region to pin handler to.
*/
public SnsMessageManager(String region) {
this.endpoint = RegionUtils.getRegion(region).getServiceEndpoint(AmazonSNS.ENDPOINT_PREFIX);
this.signatureVerifier = new SignatureVerifier(client, endpoint, resolveCertCommonName(region));
this.messageUnmarshaller = new SnsMessageUnmarshaller(client);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Specifically made package access for testing.
* Used for internal consumption of AWS SDK.
*
* Tries to determine the service endpoint for the bucket name.
* Returns the endpoint configured in the client if the region cannot be determined.
*/
URI resolveServiceEndpoint(String bucketName) {
if (getSignerRegion() != null || isSignerOverridden()) return endpoint;
final String regionStr = fetchRegionFromCache(bucketName);
final com.amazonaws.regions.Region region = RegionUtils.getRegion(regionStr);
if (region == null) {
log.warn("Region information for "
+ regionStr
+ " is not available. Please upgrade to latest version of AWS Java SDK");
}
return region != null
? RuntimeHttpUtils.toUri(region.getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration)
: endpoint;
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns a instance of the Amazon CloudWatch request metric collector either by
* starting up a new one or returning an existing one if it's already
* started; null if any failure.
*/
@Override
public MetricCollector getInstance() {
AWSCredentialsProvider provider = AwsSdkMetrics.getCredentialProvider();
Region region = RegionUtils.getRegion(AwsSdkMetrics.getRegionName());
Integer qSize = AwsSdkMetrics.getMetricQueueSize();
Long timeoutMilli = AwsSdkMetrics.getQueuePollTimeoutMilli();
CloudWatchMetricConfig config = new CloudWatchMetricConfig();
ClientConfiguration clientConfig = new ClientConfiguration();
if (provider != null)
config.setCredentialsProvider(provider);
if (region != null) {
String endPoint = region.getServiceEndpoint(AmazonCloudWatch.ENDPOINT_PREFIX);
config.setCloudWatchEndPoint(endPoint);
}
if (qSize != null)
config.setMetricQueueSize(qSize.intValue());
if (timeoutMilli != null)
config.setQueuePollTimeoutMilli(timeoutMilli.longValue());
config.setClientConfiguration(clientConfig);
MetricCollectorSupport.startSingleton(config);
return MetricCollectorSupport.getInstance();
}
}
代码示例来源:origin: aws/aws-sdk-java
resolveRequestEndpoint(request, bucketName, key, RuntimeHttpUtils.toUri(RegionUtils.getRegion(region).getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration));
return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, region);
} else if (request.getOriginalRequest() instanceof GeneratePresignedUrlRequest) {
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
@Override
public URI getServiceEndpoint() {
String serviceEndpoint = region.getServiceEndpoint(serviceName);
if (serviceEndpoint == null) {
serviceEndpoint = String.format("%s.%s.%s", serviceName, region.getName(), region.getDomain());
log.info("{" + serviceName + ", " + region.getName() + "} was not "
+ "found in region metadata, trying to construct an "
+ "endpoint using the standard pattern for this region: '" + serviceEndpoint + "'.");
}
return toURI(stripProtocol(serviceEndpoint));
}
代码示例来源:origin: aws-amplify/aws-sdk-android
serviceEndpoint = region.getServiceEndpoint(serviceName);
final int protocolIdx = serviceEndpoint.indexOf("://");
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testGetRegionByEndpoint() {
Region usWest2 = RegionUtils.getRegionByEndpoint("s3.us-west-2.amazonaws.com");
Region standard = RegionUtils.getRegionByEndpoint("s3.amazonaws.com");
assertEquals(usWest2.getName(), "us-west-2");
assertEquals(usWest2.getServiceEndpoint(ServiceAbbreviations.S3),
"s3.us-west-2.amazonaws.com");
assertEquals(standard.getName(), "us-east-1");
assertEquals(standard.getServiceEndpoint(ServiceAbbreviations.S3), "s3.amazonaws.com");
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testGetRegionsForService() {
List<Region> regions = RegionUtils.getRegionsForService(ServiceAbbreviations.SimpleDB);
assertEquals(regions.size(), 8);
boolean usEast1 = false;
boolean usWest1 = false;
for (Region curr : regions) {
if (curr.getName().equalsIgnoreCase("us-east-1")) {
usEast1 = true;
assertEquals(curr.getServiceEndpoint(ServiceAbbreviations.SimpleDB),
"sdb.amazonaws.com");
}
if (curr.getName().equalsIgnoreCase("us-west-1"))
usWest1 = true;
}
assertTrue(usEast1);
assertTrue(usWest1);
}
代码示例来源:origin: aws-amplify/aws-sdk-android
RegionUtils.getRegion(region).getServiceEndpoint(S3_SERVICE_NAME),
clientConfiguration));
代码示例来源:origin: aws-amplify/aws-sdk-android
.getServiceEndpoint(serviceName));
代码示例来源:origin: spring-cloud/spring-cloud-aws
@Override
public URL getURL() throws IOException {
Region region = this.amazonS3.getRegion().toAWSRegion();
return new URL("https", region.getServiceEndpoint(AmazonS3Client.S3_SERVICE_NAME), "/" + this.bucketName + "/" + this.objectName);
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-rds
private URI createEndpoint(String regionName, String serviceName) {
final Region region = RegionUtils.getRegion(regionName);
if (region == null) {
throw new AmazonClientException("{" + serviceName + ", " + regionName + "} was not "
+ "found in region metadata. Update to latest version of SDK and try again.");
}
return toURI(region.getServiceEndpoint(serviceName));
}
代码示例来源:origin: Nextdoor/bender
@Override
public URI getServiceEndpoint() {
String serviceEndpoint = region.getServiceEndpoint(serviceName);
if (serviceEndpoint == null) {
serviceEndpoint = String.format("%s.%s.%s", serviceName, region.getName(), region.getDomain());
log.info("{" + serviceName + ", " + region.getName() + "} was not "
+ "found in region metadata, trying to construct an "
+ "endpoint using the standard pattern for this region: '" + serviceEndpoint + "'.");
}
return toURI(stripProtocol(serviceEndpoint));
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-ec2
private URI createEndpoint(String regionName, String serviceName) {
final Region region = RegionUtils.getRegion(regionName);
if (region == null) {
throw new AmazonClientException("{" + serviceName + ", " + regionName + "} was not "
+ "found in region metadata. Update to latest version of SDK and try again.");
}
return toURI(region.getServiceEndpoint(serviceName));
}
代码示例来源:origin: awslabs/emr-dynamodb-connector
@Test
public void getsEndpointFromConf() {
conf.set(DynamoDBConstants.ENDPOINT, TEST_ENDPOINT);
assertEquals(TEST_ENDPOINT, DynamoDBUtil.getDynamoDBEndpoint(conf, null));
verify(region, never()).getServiceEndpoint(ServiceAbbreviations.Dynamodb);
}
内容来源于网络,如有侵权,请联系作者删除!