本文整理汇总了Java中com.amazonaws.regions.Regions类的典型用法代码示例。如果您正苦于以下问题:Java Regions类的具体用法?Java Regions怎么用?Java Regions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Regions类属于com.amazonaws.regions包,在下文中一共展示了Regions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: client
import com.amazonaws.regions.Regions; //导入依赖的package包/类
private AmazonIdentityManagement client() {
return AmazonIdentityManagementClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(new AWSCredentials() {
@Override
public String getAWSAccessKeyId() {
return bookmark.getCredentials().getUsername();
}
@Override
public String getAWSSecretKey() {
return bookmark.getCredentials().getPassword();
}
}))
.withClientConfiguration(configuration)
.withRegion(Regions.DEFAULT_REGION).build();
}
示例2: obtainResource
import com.amazonaws.regions.Regions; //导入依赖的package包/类
@Override
protected void obtainResource() throws Exception {
// See https://github.com/mhart/kinesalite#cbor-protocol-issues-with-the-java-sdk
System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
this.resource = AmazonKinesisAsyncClientBuilder.standard()
.withClientConfiguration(
new ClientConfiguration()
.withMaxErrorRetry(0)
.withConnectionTimeout(1000))
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration("http://localhost:" + this.port,
Regions.DEFAULT_REGION.getName()))
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("", "")))
.build();
// Check connection
this.resource.listStreams();
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:20,代码来源:LocalKinesisResource.java
示例3: getClient
import com.amazonaws.regions.Regions; //导入依赖的package包/类
private static AmazonDynamoDB getClient() {
if (null != dynamodbClient) {
return dynamodbClient;
}
String region = System.getProperty("DYNAMODB_REGION");
if (null == region) {
System.err.println("Region not set, default \"" + Regions.US_EAST_1.name() + "\" is used");
region = Regions.US_EAST_1.name();
}
System.out.println("DynamoDB region: " + region);
dynamodbClient = AmazonDynamoDBClientBuilder.standard()
.withRegion(region)
.build();
return dynamodbClient;
}
示例4: configure
import com.amazonaws.regions.Regions; //导入依赖的package包/类
private void configure() {
Matcher matcher = REGIONAL_ENDPOINT_PATTERN.matcher(uri.toString());
if (matcher.find()) {
String bucketName = matcher.group(1);
String region = matcher.group(2);
String key = matcher.group(4);
Region derivedRegion;
if (region.equals("external-1")) {
derivedRegion = Region.getRegion(Regions.US_EAST_1);
} else {
derivedRegion = RegionUtils.getRegion(region);
}
this.region = Optional.of(derivedRegion);
this.bucketName = bucketName;
this.key = key;
} else {
this.region = Optional.absent();
this.bucketName = getBucketName(uri.getHost());
this.key = getS3BucketKey(uri);
}
}
示例5: setCredentialProfile
import com.amazonaws.regions.Regions; //导入依赖的package包/类
@Override
public void setCredentialProfile(CredentialProfileEntry credentialProfileEntry) {
BasicProfile basicProfile = credentialProfileEntry.getBasicProfile();
Regions lastSelectedRegion = getLastSelectedRegion();
Regions region = lastSelectedRegion;
if(!isEmpty(basicProfile.getRegion())) {
region = tryGetRegionBy(basicProfile.getRegion());
}
if(region == null){
region = lastSelectedRegion;
}
String credentialProfile = credentialProfileEntry.getName();
connectorSettings.setLastSelectedCredentialProfile(credentialProfile);
setRegionAndProfile(region, credentialProfile);
if(!lastSelectedRegion.getName().equals(region.getName())){
view.setRegion(region);
}
CredentialProfileEntry profileEntry = view.getSelectedCredentialProfileEntry();
if(profileEntry == null) {
view.logInfo("Credential profile is not selected.");
} else {
view.logInfo("Selected Credential profile: \"%s\"", profileEntry.getName());
}
refreshStatus();
}
开发者ID:satr,项目名称:intellij-idea-plugin-connector-for-aws-lambda,代码行数:26,代码来源:ConnectorPresenterImpl.java
示例6: tryConfigureEndpointOrRegion
import com.amazonaws.regions.Regions; //导入依赖的package包/类
/**
* Common support code: attempts to configure client endpoint and/or region.
*
* @param client A constructed writer-specific service client.
* @param endpoint A possibly-null endpoint specification.
*/
protected <T extends AmazonWebServiceClient> T tryConfigureEndpointOrRegion(T client, String endpoint)
{
// explicit endpoint takes precedence over region retrieved from environment
if (endpoint != null)
{
LogLog.debug(getClass().getSimpleName() + ": configuring endpoint: " + endpoint);
client.setEndpoint(endpoint);
return client;
}
String region = System.getenv("AWS_REGION");
if (region != null)
{
LogLog.debug(getClass().getSimpleName() + ": configuring region: " + region);
client.configureRegion(Regions.fromName(region));
return client;
}
return client;
}
示例7: init
import com.amazonaws.regions.Regions; //导入依赖的package包/类
@Before
public void init() {
copierOptions.put(CREDENTIAL_PROVIDER, URI.create("localjceks://file/foo/bar.jceks"));
copierOptions.put(MULTIPART_UPLOAD_CHUNK_SIZE, 4096);
copierOptions.put(S3_SERVER_SIDE_ENCRYPTION, true);
copierOptions.put(STORAGE_CLASS, StorageClass.Glacier.toString());
copierOptions.put(TASK_BANDWIDTH, 1024);
copierOptions.put(NUMBER_OF_WORKERS_PER_MAP, 12);
copierOptions.put(MULTIPART_UPLOAD_THRESHOLD, 2048L);
copierOptions.put(MAX_MAPS, 5);
copierOptions.put(COPY_STRATEGY, "mycopystrategy");
copierOptions.put(LOG_PATH, new Path("hdfs:///tmp/logs"));
copierOptions.put(REGION, Regions.EU_WEST_1.getName());
copierOptions.put(IGNORE_FAILURES, false);
copierOptions.put(S3_ENDPOINT_URI, "http://s3.endpoint/");
copierOptions.put(UPLOAD_RETRY_COUNT, 5);
copierOptions.put(UPLOAD_RETRY_DELAY_MS, 520);
copierOptions.put(UPLOAD_BUFFER_SIZE, 1024);
parser = new S3MapReduceCpOptionsParser(SOURCES, TARGET, DEFAULT_CREDS_PROVIDER);
}
示例8: assertDefaults
import com.amazonaws.regions.Regions; //导入依赖的package包/类
private void assertDefaults(S3MapReduceCpOptions options) {
assertThat(options.getCredentialsProvider(), is(URI.create("localjceks://file/foo/bar.jceks")));
assertThat(options.getMultipartUploadPartSize(), is(4096L));
assertThat(options.isS3ServerSideEncryption(), is(true));
assertThat(options.getStorageClass(), is(StorageClass.Glacier.toString()));
assertThat(options.getMaxBandwidth(), is(1024L));
assertThat(options.getNumberOfUploadWorkers(), is(12));
assertThat(options.getMultipartUploadThreshold(), is(2048L));
assertThat(options.getMaxMaps(), is(5));
assertThat(options.getCopyStrategy(), is("mycopystrategy"));
assertThat(options.getLogPath(), is(new Path("hdfs:///tmp/logs")));
assertThat(options.getRegion(), is(Regions.EU_WEST_1.getName()));
assertThat(options.isIgnoreFailures(), is(false));
assertThat(options.getS3EndpointUri(), is(URI.create("http://s3.endpoint/")));
assertThat(options.getUploadRetryCount(), is(5));
assertThat(options.getUploadRetryDelayMs(), is(520L));
assertThat(options.getUploadBufferSize(), is(1024));
}
示例9: webHookDump
import com.amazonaws.regions.Regions; //导入依赖的package包/类
public static String webHookDump(InputStream stream, String school, String extension) {
if (stream != null) {
extension = extension == null || extension.isEmpty() ? ".xml" : extension.contains(".") ? extension : "." + extension;
String fileName = "webhooks/" + school + "/" + school + "_" + Clock.getCurrentDateDashes() + "_" + Clock.getCurrentTime() + extension;
AmazonS3 s3 = new AmazonS3Client();
Region region = Region.getRegion(Regions.US_WEST_2);
s3.setRegion(region);
try {
File file = CustomUtilities.inputStreamToFile(stream);
s3.putObject(new PutObjectRequest(name, fileName, file));
return CustomUtilities.fileToString(file);
} catch (Exception e) {
e.printStackTrace();
}
}
return "";
}
示例10: doLaunch
import com.amazonaws.regions.Regions; //导入依赖的package包/类
@Override
public void doLaunch(MessageInput input) throws MisfireException {
serverStatus.awaitRunning(() -> lifecycleStateChange(Lifecycle.RUNNING));
LOG.info("Starting s3 subscriber");
final String legacyRegionName = input.getConfiguration().getString(CK_LEGACY_AWS_REGION, DEFAULT_REGION.getName());
final String sqsRegionName = input.getConfiguration().getString(CK_AWS_SQS_REGION, legacyRegionName);
final String s3RegionName = input.getConfiguration().getString(CK_AWS_S3_REGION, legacyRegionName);
subscriber = new S3Subscriber(
Region.getRegion(Regions.fromName(sqsRegionName)),
Region.getRegion(Regions.fromName(s3RegionName)),
input.getConfiguration().getString(CK_SQS_NAME),
input,
input.getConfiguration().getString(CK_ACCESS_KEY),
input.getConfiguration().getString(CK_SECRET_KEY),
input.getConfiguration().getInt(CK_THREAD_COUNT)
);
subscriber.start();
}
示例11: setRegion
import com.amazonaws.regions.Regions; //导入依赖的package包/类
@Override
public void setRegion(Regions region) {
if(setRegionOperationInProgress){
return;
}
try {
setRegionOperationInProgress = true;
for (int i = 0; i < regionList.getItemCount(); i++) {
if(((RegionEntry) regionList.getItemAt(i)).getName().equals(region.getName())){
regionList.setSelectedIndex(i);
return;
}
}
} finally {
setRegionOperationInProgress = false;
}
}
开发者ID:satr,项目名称:intellij-idea-plugin-connector-for-aws-lambda,代码行数:18,代码来源:ConnectorViewFactory.java
示例12: createStandardAsyncClientBuilder
import com.amazonaws.regions.Regions; //导入依赖的package包/类
private AmazonSQSAsyncClientBuilder createStandardAsyncClientBuilder(SQSQueue queue, AWSCredentialsProvider credentials) {
ClientConfiguration clientConfiguration = this.getClientConfiguration(queue);
AmazonSQSAsyncClientBuilder builder = AmazonSQSAsyncClientBuilder.standard()
.withClientConfiguration(clientConfiguration)
.withCredentials(credentials)
.withExecutorFactory(this.SQSExecutorFactory);
if (queue != null) {
Regions region = queue.getRegion();
if (region != null) {
builder.withRegion(region);
}
}
return builder;
}
示例13: getRegion
import com.amazonaws.regions.Regions; //导入依赖的package包/类
public static String getRegion() {
if (userSetRegion.isPresent()) {
return userSetRegion.get().getName();
}
if (cachedRegion.isPresent()) {
return cachedRegion.get().getName();
}
CustomRegionProviderChain regionProvider = new CustomRegionProviderChain();
try {
Region region = regionProvider.resolveRegion();
cachedRegion = Optional.of(region);
return region.getName();
} catch (FailedToResolveRegionException e) {
return Regions.DEFAULT_REGION.getName();
}
}
示例14: amazonS3Client
import com.amazonaws.regions.Regions; //导入依赖的package包/类
/**
* S3 储存客户端
*
* @return 客户端
*/
@Bean
@ConditionalOnProperty(value = "bigbug.storage.s3.enable", havingValue = "true")
AmazonS3Client amazonS3Client() {
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setProtocol(Protocol.HTTP);
BasicAWSCredentials basicAWSCredentials =
new BasicAWSCredentials(
storageProperties.getStorage().getS3().getAccessKey(),
storageProperties.getStorage().getS3().getSecretKey());
return (AmazonS3Client) AmazonS3ClientBuilder.standard()
.withClientConfiguration(clientConfig)
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(
storageProperties.getStorage().getS3().getEndpoint(), Regions.DEFAULT_REGION.getName()))
.withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials))
.build();
}
示例15: cleanUpKMSKeys
import com.amazonaws.regions.Regions; //导入依赖的package包/类
private static void cleanUpKMSKeys(Regions testRegion, String testResourcePrefix, Date createdBeforeThreshold,
AWSCredentialsProvider awsCredentials) {
LOG.info("Cleaning KMS...");
AWSKMS kmsClient = AWSKMSClientBuilder.standard()
.withCredentials(awsCredentials)
.withRegion(testRegion)
.build();
List<AliasListEntry> keys = kmsClient.listAliases().getAliases();
for (AliasListEntry entry: keys) {
if (!entry.getAliasName().startsWith("alias/" + testResourcePrefix)) {
continue;
}
DescribeKeyRequest request = new DescribeKeyRequest().withKeyId(entry.getTargetKeyId());
KeyMetadata metadata = kmsClient.describeKey(request).getKeyMetadata();
if (KMSKeyState.fromString(metadata.getKeyState()) != KMSKeyState.PENDING_DELETION &&
metadata.getCreationDate().before(createdBeforeThreshold)) {
LOG.info("Scheduling KMS key for deletion:" + entry.getAliasName());
scheduleKeyDeletion(kmsClient, entry);
}
}
}