当前位置: 首页>>代码示例>>Java>>正文


Java Region.getRegion方法代码示例

本文整理汇总了Java中com.amazonaws.regions.Region.getRegion方法的典型用法代码示例。如果您正苦于以下问题:Java Region.getRegion方法的具体用法?Java Region.getRegion怎么用?Java Region.getRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.regions.Region的用法示例。


在下文中一共展示了Region.getRegion方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import com.amazonaws.regions.Region; //导入方法依赖的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);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:S3RegionalResource.java

示例2: doLaunch

import com.amazonaws.regions.Region; //导入方法依赖的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();
}
 
开发者ID:sherzberg,项目名称:graylog-plugin-s3,代码行数:23,代码来源:S3Transport.java

示例3: webHookDump

import com.amazonaws.regions.Region; //导入方法依赖的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 "";
}
 
开发者ID:faizan-ali,项目名称:full-javaee-app,代码行数:18,代码来源:S3Object.java

示例4: masterKeyProvider

import com.amazonaws.regions.Region; //导入方法依赖的package包/类
private MasterKeyProvider<?> masterKeyProvider() {

        final AWSCredentialsProvider credentials
                = new DefaultAWSCredentialsProviderChain();

        List<KmsMasterKey> masterKeys
                = new LinkedList<>();

        for (String region : this.regions) {
            KmsMasterKeyProvider provider
                    = new KmsMasterKeyProvider(
                            credentials,
                            Region.getRegion(
                                    Regions.fromName(
                                            region)),
                            new ClientConfiguration(),
                            this.keyId);



            masterKeys.add(
                    provider.getMasterKey(
                            this.keyId));
        }

        return MultipleProviderFactory
                .buildMultiProvider(
                        masterKeys);
    }
 
开发者ID:eonian-technologies,项目名称:secrets-locker,代码行数:30,代码来源:KmsEncryptionService.java

示例5: JobManager

import com.amazonaws.regions.Region; //导入方法依赖的package包/类
public JobManager(JobInfoStore jobInfoStore, CloudInstanceStore cloudInstanceStore,
                  CmdbInstanceStore cmdbInstanceStore) {
  ;
  this.jobInfoStore = jobInfoStore;
  this.ec2InstanceStore = cloudInstanceStore;
  this.cmdbInstanceStore = cmdbInstanceStore;
  this.awsRegion = Region.getRegion(
      Regions.fromName(Configuration.getProperties().getString("aws_region", "us-east-1")));

  int numOfSubscribers = Configuration.getProperties().getInt("num_subscriber", 1);
  logger.info("JobManager starts with {} subscribers", numOfSubscribers);
  for (int i = 0; i < numOfSubscribers; i++) {
    Ec2InstanceUpdateHandler
        handler =
        new Ec2InstanceUpdateHandler(cmdbInstanceStore, cloudInstanceStore,
            new EsDailySnapshotStoreFactory());

    SqsClient client = new SqsClient(handler);
    SqsTriggeredJobExecutor
        executor =
        new SqsTriggeredJobExecutor(Configuration.getProperties().getString("update_queue"),
            15, msg -> client.processMessage(msg));
    executor.setMinimumReprocessingDuration(30);
    executors.add(executor);
    this.onEc2HandlerCreate(handler);
  }

  //Add recurring jobs
  addRecurringJobs();
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:31,代码来源:JobManager.java

示例6: doFillRegionItems

import com.amazonaws.regions.Region; //导入方法依赖的package包/类
public ListBoxModel doFillRegionItems() {
    ListBoxModel items = new ListBoxModel();
    items.add("", "");
    for (Regions region : Regions.values()) {
        Region r = Region.getRegion(region);
        if (r.isServiceSupported(AmazonSQS.ENDPOINT_PREFIX) && r.isServiceSupported("codecommit")) {
            items.add(region.getName(), region.name());
        }
    }
    return items;
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:12,代码来源:SQSTriggerQueue.java

示例7: getRegionConstant

import com.amazonaws.regions.Region; //导入方法依赖的package包/类
/**
 * Converts the configured region name to an aws region enum constant.
 */
@PostConstruct
public void getRegionConstant()
{
  awsRegion = Region.getRegion(Regions.valueOf(awsRegionName));
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:9,代码来源:AwsClientFactory.java

示例8: configure

import com.amazonaws.regions.Region; //导入方法依赖的package包/类
public void configure() throws Exception {
    if (!isConfigured) {
        validateConfig();

        try {
            String userAgent = "AWSKinesisManagedConsumer/" + this.version;

            if (this.positionInStream != null) {
                streamPosition = InitialPositionInStream.valueOf(this.positionInStream);
            } else {
                streamPosition = InitialPositionInStream.LATEST;
            }

            // append the environment name to the application name
            if (environmentName != null) {
                appName = String.format("%s-%s", appName, environmentName);
            }

            // ensure the JVM will refresh the cached IP values of AWS
            // resources
            // (e.g. service endpoints).
            java.security.Security.setProperty("networkaddress.cache.ttl", "60");

            String workerId = NetworkInterface.getNetworkInterfaces() + ":" + UUID.randomUUID();
            LOG.info("Using Worker ID: " + workerId);

            // obtain credentials using the default provider chain or the
            // credentials provider supplied
            AWSCredentialsProvider credentialsProvider = this.credentialsProvider == null ? new DefaultAWSCredentialsProviderChain()
                    : this.credentialsProvider;

            LOG.info("Using credentials with Access Key ID: "
                    + credentialsProvider.getCredentials().getAWSAccessKeyId());

            config = new KinesisClientLibConfiguration(appName, streamName,
                    credentialsProvider, workerId).withInitialPositionInStream(streamPosition).withKinesisEndpoint(
                    kinesisEndpoint);

            config.getKinesisClientConfiguration().setUserAgent(userAgent);

            if (regionName != null) {
                Region region = Region.getRegion(Regions.fromName(regionName));
                config.withRegionName(region.getName());
            }

            if (this.maxRecords != -1)
                config.withMaxRecords(maxRecords);

            if (this.positionInStream != null)
                config.withInitialPositionInStream(InitialPositionInStream.valueOf(this.positionInStream));

            LOG.info(String.format(
                    "Amazon Kinesis Managed Client prepared for %s on %s in %s (%s) using %s Max Records",
                    config.getApplicationName(), config.getStreamName(),
                    config.getRegionName(), config.getWorkerIdentifier(),
                    config.getMaxRecords()));

            isConfigured = true;
        } catch (Exception e) {
            throw new InvalidConfigurationException(e);
        }
    }
}
 
开发者ID:awslabs,项目名称:aws-kinesis-beanstalk-workers,代码行数:64,代码来源:ManagedConsumer.java


注:本文中的com.amazonaws.regions.Region.getRegion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。