本文整理汇总了Java中com.amazonaws.services.s3.model.Region.fromValue方法的典型用法代码示例。如果您正苦于以下问题:Java Region.fromValue方法的具体用法?Java Region.fromValue怎么用?Java Region.fromValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.model.Region
的用法示例。
在下文中一共展示了Region.fromValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: regionForUri
import com.amazonaws.services.s3.model.Region; //导入方法依赖的package包/类
private String regionForUri(AmazonS3 client, AmazonS3URI uri) {
String bucketRegion = client.getBucketLocation(uri.getBucket());
Region region = Region.fromValue(bucketRegion);
// S3 doesn't have a US East 1 region, US East 1 is really the region
// US Standard. US Standard places the data in either an east coast
// or west coast data center geographically closest to you.
// SigV4 requires you to mention a region while signing a request
// and for the S3's US standard endpoints the value to be used is "us-east-1"
// US West 1 has an endpoint and so is treated as a stand alone region,
// US East 1 doesn't and so is bundled into US Standard
if (region.equals(Region.US_Standard)) {
bucketRegion = "us-east-1";
} else {
bucketRegion = region.toString();
}
return bucketRegion;
}
示例2: validate
import com.amazonaws.services.s3.model.Region; //导入方法依赖的package包/类
@Override
public void validate(String name, String value) throws ParameterException {
try {
Region.fromValue(value);
} catch (IllegalArgumentException e) {
throw new ParameterException("Parameter " + name + " is not a valid AWS region (found " + value + ")", e);
}
}
示例3: getRegion
import com.amazonaws.services.s3.model.Region; //导入方法依赖的package包/类
@Override
public synchronized Region getRegion() {
String authority = super.endpoint.getAuthority();
if (Constants.S3_HOSTNAME.equals(authority)) {
return Region.US_Standard;
} else {
Matcher m = Region.S3_REGIONAL_ENDPOINT_PATTERN.matcher(authority);
if (m.matches()) {
return Region.fromValue(m.group(1));
} else {
throw new IllegalStateException(
"S3 client with invalid S3 endpoint configured: " + authority);
}
}
}
示例4: addBucketFSEntry
import com.amazonaws.services.s3.model.Region; //导入方法依赖的package包/类
/**
* To reuse code for accountbased and external buckets
* @param s3
* @param parentConf
* @param bucketName
* @throws IOException
*/
private FileSystem addBucketFSEntry(AmazonS3 s3, Configuration parentConf, String bucketName) throws AmazonS3Exception, IOException {
final String bucketRegion = s3.getBucketLocation(bucketName);
final String projectedBucketEndPoint = "s3." + bucketRegion + ".amazonaws.com";
String regionEndPoint = projectedBucketEndPoint;
try {
Region region = Region.fromValue(bucketRegion);
com.amazonaws.regions.Region awsRegion = region.toAWSRegion();
if (awsRegion != null) {
regionEndPoint = awsRegion.getServiceEndpoint("s3");
}
} catch (IllegalArgumentException iae) {
// try heuristic mapping if not found
regionEndPoint = projectedBucketEndPoint;
logger.warn("Unknown or unmapped region {} for bucket {}. Will use following fs.s3a.endpoint: {}",
bucketRegion, bucketName, regionEndPoint);
}
// it could be null because no mapping from Region to aws region or there is no such region is the map of endpoints
// not sure if latter is possible
if (regionEndPoint == null) {
logger.error("Could not get AWSRegion for bucket {}. Will use following fs.s3a.endpoint: " + "{} ",
bucketName, projectedBucketEndPoint);
}
String location = S3_URI_SCHEMA + bucketName + "/";
Configuration bucketConf = new Configuration(parentConf);
bucketConf.set(ENDPOINT, (regionEndPoint != null) ? regionEndPoint : projectedBucketEndPoint);
FileSystem.setDefaultUri(bucketConf, new Path(location).toUri());
return FileSystem.get(bucketConf);
}
示例5: setRegion
import com.amazonaws.services.s3.model.Region; //导入方法依赖的package包/类
void setRegion(String region) {
Region.fromValue(region);
this.region = region;
}
示例6: build
import com.amazonaws.services.s3.model.Region; //导入方法依赖的package包/类
private void build() {
jophielBaseUrl = requireStringValue("jophiel.baseUrl");
jophielBaseDataDir = requireDirectoryValue("jophiel.baseDataDir");
jophielClientLabels = requireStringListValue("jophiel.client.labels");
jophielClientTargets = requireStringListValue("jophiel.client.targets");
idTokenPrivateKey = requireStringValue("jophiel.idToken.key.private");
noreplyName = requireStringValue("noreply.name");
noreplyEmail = requireStringValue("noreply.email");
requireStringValue("play.mailer.host");
requireIntegerValue("play.mailer.port");
requireStringValue("play.mailer.ssl");
requireStringValue("play.mailer.user");
requireStringValue("play.mailer.password");
avatarUsingAWSS3 = requireBooleanValue("aws.avatar.s3.use");
if (avatarUsingAWSS3) {
avatarAWSUsingKeys = requireBooleanValue("aws.avatar.key.use");
avatarAWSAccessKey = requireStringValue("aws.avatar.key.access");
avatarAWSSecretKey = requireStringValue("aws.avatar.key.secret");
avatarAWSS3BucketName = requireStringValue("aws.avatar.s3.bucket.name");
avatarAWSS3BucketRegion = Region.fromValue(requireStringValue("aws.avatar.s3.bucket.regionId"));
avatarAWSCloudFrontUrl = requireStringValue("aws.avatar.cloudFront.baseUrl");
} else {
try {
avatarLocalDir = new File(jophielBaseDataDir, "avatar");
FileUtils.forceMkdir(avatarLocalDir);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
registrationUsingRecaptcha = requireBooleanValue("recaptcha.registration.use");
if (registrationUsingRecaptcha) {
registrationRecaptchaSiteKey = requireStringValue("recaptcha.registration.key.site");
registrationRecaptchaSecretKey = requireStringValue("recaptcha.registration.key.secret");
}
}