本文整理了Java中com.amazonaws.regions.Regions
类的一些代码示例,展示了Regions
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Regions
类的具体详情如下:
包路径:com.amazonaws.regions.Regions
类名称:Regions
[英]Enumeration of region names
[中]区域名称的枚举
代码示例来源:origin: brianfrankcooper/YCSB
clientConfig.setMaxConnections(Integer.parseInt(maxConnections));
s3Client = new AmazonS3Client(s3Credentials, clientConfig);
s3Client.setRegion(Region.getRegion(Regions.fromName(region)));
s3Client.setEndpoint(endPoint);
System.out.println("Connection successfully initialized");
} catch (Exception e){
代码示例来源:origin: aws/aws-sdk-java
/**
* Sets the region to be used for the default AWS SDK metric collector;
* or null if the default is to be used.
*/
public static void setRegion(Regions region) {
AwsSdkMetrics.region = RegionUtils.getRegion(region.getName());
}
代码示例来源:origin: prestodb/presto
clientBuilder = AmazonS3Client.builder()
.withCredentials(credentialsProvider)
.withClientConfiguration(clientConfig)
Region region = Regions.getCurrentRegion();
if (region != null) {
clientBuilder = clientBuilder.withRegion(region.getName());
regionOrEndpointSet = true;
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns a region enum corresponding to the given region name.
*
* @param regionName
* The name of the region. Ex.: eu-west-1
* @return Region enum representing the given region name.
*/
public static Regions fromName(String regionName) {
for (Regions region : Regions.values()) {
if (region.getName().equals(regionName)) {
return region;
}
}
throw new IllegalArgumentException("Cannot create enum from " + regionName + " value!");
}
代码示例来源:origin: apache/nifi
protected static AllowableValue createAllowableValue(final Regions region) {
return new AllowableValue(region.getName(), region.getDescription(), "AWS Region Code : " + region.getName());
}
代码示例来源:origin: apache/usergrid
private AmazonS3 getS3Client() throws Exception{
this.bucketName = properties.getProperty( "usergrid.binary.bucketname" );
if(bucketName == null){
logger.error( "usergrid.binary.bucketname not properly set so amazon bucket is null" );
throw new AwsPropertiesNotFoundException( "usergrid.binary.bucketname" );
}
final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider();
AWSCredentials credentials = ugProvider.getCredentials();
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setProtocol(Protocol.HTTP);
s3Client = new AmazonS3Client(credentials, clientConfig);
if(regionName != null)
s3Client.setRegion( Region.getRegion(Regions.fromName(regionName)) );
return s3Client;
}
代码示例来源:origin: apache/incubator-gobblin
@VisibleForTesting
AWSSdkClient createAWSSdkClient() {
return new AWSSdkClient(this.awsClusterSecurityManager,
Region.getRegion(Regions.fromName(this.awsRegion)));
}
代码示例来源:origin: apache/jackrabbit-oak
|| StringUtils.isNullOrEmpty(secretKey)) {
LOG.info("Configuring Amazon Client from environment");
s3service = new AmazonS3Client(getClientConfiguration(prop));
} else {
LOG.info("Configuring Amazon Client from property file.");
AWSCredentials credentials = new BasicAWSCredentials(accessKey,
secretKey);
s3service = new AmazonS3Client(credentials,
getClientConfiguration(prop));
} else {
if (StringUtils.isNullOrEmpty(region)) {
com.amazonaws.regions.Region s3Region = Regions.getCurrentRegion();
if (s3Region != null) {
region = s3Region.getName();
} else {
throw new AmazonClientException(
s3service.setEndpoint(endpoint);
LOG.info("S3 service endpoint [{}] ", endpoint);
return s3service;
代码示例来源:origin: apache/streams
clientOptions.setPathStyleAccess(false);
this.amazonS3Client = new AmazonS3Client(credentials, clientConfig);
if (StringUtils.isNotEmpty(s3ReaderConfiguration.getRegion())) {
this.amazonS3Client.setRegion(Region.getRegion(Regions.fromName(s3ReaderConfiguration.getRegion())));
this.amazonS3Client.setS3ClientOptions(clientOptions);
代码示例来源:origin: DSpace/DSpace
s3Service = new AmazonS3Client(awsCredentials);
Regions regions = Regions.fromName(awsRegionName);
Region region = Region.getRegion(regions);
s3Service.setRegion(region);
log.info("S3 Region set to: " + region.getName());
} catch (IllegalArgumentException e) {
log.warn("Invalid aws_region: " + awsRegionName);
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns the region configured for the default AWS SDK metric collector;
* or null if the default is to be used.
*
* @throws IllegalArgumentException when using a region not included in
* {@link Regions}
*
* @deprecated Use {@link #getRegionName()}
*/
public static Regions getRegion() throws IllegalArgumentException {
return Regions.fromName(region.getName());
}
代码示例来源:origin: com.bazaarvoice.emodb/emodb-sor
private static AmazonS3 getAmazonS3Client(AuditWriterConfiguration configuration) {
AWSCredentialsProvider credentialsProvider;
if (configuration.getS3AccessKey() != null && configuration.getS3SecretKey() != null) {
credentialsProvider = new StaticCredentialsProvider(
new BasicAWSCredentials(configuration.getS3AccessKey(), configuration.getS3SecretKey()));
} else {
credentialsProvider = new DefaultAWSCredentialsProviderChain();
}
AmazonS3 s3 = new AmazonS3Client(credentialsProvider)
.withRegion(Regions.fromName(configuration.getLogBucketRegion()));
if (configuration.getS3Endpoint() != null) {
s3.setEndpoint(configuration.getS3Endpoint());
}
return s3;
}
代码示例来源:origin: guardian/kinesis-logback-appender
/**
* Determine region. If not specified tries to determine region from where the
* application is running or fall back to the default.
*
* @return Region to configure the client
*/
private Region findRegion() {
boolean regionProvided = !Validator.isBlank(this.region);
if(!regionProvided) {
// Determine region from where application is running, or fall back to default region
Region currentRegion = Regions.getCurrentRegion();
if(currentRegion != null) {
return currentRegion;
}
return Region.getRegion(Regions.fromName(AppenderConstants.DEFAULT_REGION));
}
return Region.getRegion(Regions.fromName(this.region));
}
代码示例来源:origin: aws/aws-sdk-java
private URI getCreateBucketEndpoint(String requestRegion) {
// Route to the default endpoint if they're not trying to specify a different one in the request.
if(requestRegion == null || requestRegion.equals(clientRegion) || !clientOptions.isForceGlobalBucketAccessEnabled()) {
return endpoint;
}
// If they enabled global bucket access and they're trying to create a bucket in a region different than the default
// one specified when they created the client, it will probably fail because only us-east-1 (actually the global
// endpoint) is capable of creating buckets outside of its region. Override the endpoint to which the request
// is routed so that it will succeed.
com.amazonaws.regions.Region targetRegion = com.amazonaws.regions.Region.getRegion(Regions.fromName(requestRegion));
return new DefaultServiceEndpointBuilder(getEndpointPrefix(),
clientConfiguration.getProtocol().toString()).withRegion(targetRegion)
.getServiceEndpoint();
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testCreateSigner() {
s3.setS3ClientOptions(accelerateOption);
final Regions region = Regions.US_WEST_2;
s3.setRegion(Region.getRegion(region));
final String bucketName = "bucket";
final String key = "key";
final HttpMethodName method = HttpMethodName.GET;
final GetObjectRequest originalRequest = new GetObjectRequest(bucketName, key);
final Request<?> request = s3.createRequest(bucketName, key, originalRequest, method);
final Signer signer = s3.createSigner(request, bucketName, key);
assertTrue(signer instanceof AWSS3V4Signer);
signer.sign(request, creds);
final String authorization = request.getHeaders().get("Authorization");
assertNotNull(authorization);
final String regionName = authorization.split("/")[2];
assertEquals(region.getName(), regionName);
}
代码示例来源:origin: blox/blox
/**
* Setter for Jackson to deserialize Regions enum from string
*
* @param region
*/
public void setRegion(String region) {
this.region = Regions.fromName(region);
}
}
代码示例来源:origin: bazaarvoice/emodb
@Provides
@Singleton
protected Region provideAmazonRegion() {
return Objects.firstNonNull(Regions.getCurrentRegion(), Region.getRegion(Regions.US_EAST_1));
}
代码示例来源:origin: com.netflix.genie/genie-agent
tmpRegion = regionProvider.getRegion();
} catch (final SdkClientException e) {
tmpRegion = Regions.getCurrentRegion() != null
? Regions.getCurrentRegion().getName()
: Regions.US_EAST_1.getName();
log.warn(
"Couldn't determine the AWS region from the provider ({}) supplied. Defaulting to {}",
);
this.defaultRegion = Regions.fromName(tmpRegion);
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testSetRegion() {
final Regions region = Regions.US_WEST_2;
s3.setRegion(Region.getRegion(region));
assertEquals(region.getName(), s3.clientRegion);
}
代码示例来源:origin: org.jenkins-ci.plugins/s3
private void setRegion() {
Region region = RegionUtils.getRegion(Regions.fromName(selregion).getName());
getClient().setRegion(region);
}
}
内容来源于网络,如有侵权,请联系作者删除!