Java 类com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration 实例源码

项目:zipkin-aws    文件:SQSCollectorTest.java   
@Before
public void setup() {
  store = new InMemoryStorage();
  metrics = new InMemoryCollectorMetrics();

  collector = new SQSCollector.Builder()
      .queueUrl(sqsRule.queueUrl())
      .parallelism(2)
      .waitTimeSeconds(1) // using short wait time to make test teardown faster
      .endpointConfiguration(new EndpointConfiguration(sqsRule.queueUrl(), "us-east-1"))
      .credentialsProvider(new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x")))
      .metrics(metrics)
      .sampler(CollectorSampler.ALWAYS_SAMPLE)
      .storage(store)
      .build()
      .start();
}
项目:para    文件:AWSDynamoUtils.java   
/**
 * Returns a client instance for AWS DynamoDB.
 * @return a client that talks to DynamoDB
 */
public static AmazonDynamoDB getClient() {
    if (ddbClient != null) {
        return ddbClient;
    }

    if (Config.IN_PRODUCTION) {
        ddbClient = AmazonDynamoDBClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY))).
                withRegion(Config.AWS_REGION).build();
    } else {
        ddbClient = AmazonDynamoDBClientBuilder.standard().
                withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("local", "null"))).
                withEndpointConfiguration(new EndpointConfiguration(LOCAL_ENDPOINT, "")).build();
    }

    if (!existsTable(Config.getRootAppIdentifier())) {
        createTable(Config.getRootAppIdentifier());
    }

    ddb = new DynamoDB(ddbClient);

    Para.addDestroyListener(new DestroyListener() {
        public void onDestroy() {
            shutdownClient();
        }
    });

    return ddbClient;
}
项目:para    文件:AWSQueueUtils.java   
/**
 * Returns a client instance for AWS SQS.
 * @return a client that talks to SQS
 */
public static AmazonSQS getClient() {
    if (sqsClient != null) {
        return sqsClient;
    }
    if (Config.IN_PRODUCTION) {
        sqsClient = AmazonSQSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY))).
                withRegion(Config.AWS_REGION).build();
    } else {
        sqsClient = AmazonSQSClientBuilder.standard().
                withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x"))).
                withEndpointConfiguration(new EndpointConfiguration(LOCAL_ENDPOINT, "")).build();
    }

    Para.addDestroyListener(new DestroyListener() {
        public void onDestroy() {
            sqsClient.shutdown();
        }
    });
    return sqsClient;
}
项目:xm-ms-entity    文件:AmazonS3Template.java   
/**
 * Gets an Amazon S3 client from basic session credentials.
 *
 * @return an authenticated Amazon S3 amazonS3
 */
public AmazonS3 getAmazonS3Client() {
    if (amazonS3 == null) {
        amazonS3 = AmazonS3ClientBuilder.standard()
            .withEndpointConfiguration(new EndpointConfiguration(endpoint, region))
            .withClientConfiguration(new ClientConfiguration().withProtocol(Protocol.HTTP))
            .withCredentials(
                new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKeyId, accessKeySecret)))
            .build();
    }
    return amazonS3;
}
项目:circus-train    文件:JceksAmazonS3ClientFactory.java   
private AmazonS3 newInstance(String region, S3S3CopierOptions s3s3CopierOptions) {
  HadoopAWSCredentialProviderChain credentialsChain = getCredentialsProviderChain();
  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard().withCredentials(credentialsChain);
  URI s3Endpoint = s3s3CopierOptions.getS3Endpoint(region);
  if (s3Endpoint != null) {
    EndpointConfiguration endpointConfiguration = new EndpointConfiguration(s3Endpoint.toString(), region);
    builder.withEndpointConfiguration(endpointConfiguration);
  } else {
    builder.withRegion(region);
  }
  return builder.build();
}
项目:circus-train    文件:JceksAmazonS3ClientFactory.java   
private AmazonS3 newGlobalInstance(S3S3CopierOptions s3s3CopierOptions) {
  HadoopAWSCredentialProviderChain credentialsChain = getCredentialsProviderChain();
  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder
      .standard()
      .withForceGlobalBucketAccessEnabled(Boolean.TRUE)
      .withCredentials(credentialsChain);
  URI s3Endpoint = s3s3CopierOptions.getS3Endpoint();
  if (s3Endpoint != null) {
    EndpointConfiguration endpointConfiguration = new EndpointConfiguration(s3Endpoint.toString(),
        Region.US_Standard.getFirstRegionId());
    builder.withEndpointConfiguration(endpointConfiguration);
  }
  return builder.build();
}
项目:circus-train    文件:AwsS3ClientFactory.java   
private static EndpointConfiguration getEndpointConfiguration(Configuration conf) {
  String endpointUrl = conf.get(ConfigurationVariable.S3_ENDPOINT_URI.getName());
  if (endpointUrl == null) {
    return null;
  }
  return new EndpointConfiguration(endpointUrl, getRegion(conf));
}
项目:circus-train    文件:AwsS3ClientFactory.java   
public AmazonS3 newInstance(Configuration conf) {
  int maxErrorRetry = conf.getInt(ConfigurationVariable.UPLOAD_RETRY_COUNT.getName(),
      ConfigurationVariable.UPLOAD_RETRY_COUNT.defaultIntValue());
  long errorRetryDelay = conf.getLong(ConfigurationVariable.UPLOAD_RETRY_DELAY_MS.getName(),
      ConfigurationVariable.UPLOAD_RETRY_DELAY_MS.defaultLongValue());

  LOG.info("Creating AWS S3 client with a retry policy of {} retries and {} ms of exponential backoff delay",
      maxErrorRetry, errorRetryDelay);

  RetryPolicy retryPolicy = new RetryPolicy(new CounterBasedRetryCondition(maxErrorRetry),
      new ExponentialBackoffStrategy(errorRetryDelay), maxErrorRetry, true);
  ClientConfiguration clientConfiguration = new ClientConfiguration();
  clientConfiguration.setRetryPolicy(retryPolicy);
  clientConfiguration.setMaxErrorRetry(maxErrorRetry);

  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder
      .standard()
      .withCredentials(new HadoopAWSCredentialProviderChain(conf))
      .withClientConfiguration(clientConfiguration);

  EndpointConfiguration endpointConfiguration = getEndpointConfiguration(conf);
  if (endpointConfiguration != null) {
    builder.withEndpointConfiguration(endpointConfiguration);
  } else {
    builder.withRegion(getRegion(conf));
  }

  return builder.build();
}
项目:unitstack    文件:MockSnsTest.java   
@Before
public void setup() {
  EndpointConfiguration endpoint =
      new EndpointConfiguration(UNIT_STACK_URL + ":" + SNS_PORT, Region.EU_Frankfurt.name());
  AWSCredentials credentials = new BasicAWSCredentials("key", "secret");
  AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);

  sns = AmazonSNSAsyncClientBuilder.standard().withEndpointConfiguration(endpoint)
      .withCredentials(credentialsProvider).build();
}
项目:unitstack    文件:MockS3Test.java   
@Before
public void setup() {
  MockParameters params = new MockParameters();
  params.setMockRegion("EU");
  mockS3(params);

  EndpointConfiguration endpoint =
      new EndpointConfiguration(UNIT_STACK_URL + ":" + S3_PORT, Region.EU_Frankfurt.name());
  AWSCredentials credentials = new BasicAWSCredentials("key", "secret");
  AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);

  s3 = AmazonS3ClientBuilder.standard().withEndpointConfiguration(endpoint)
      .withCredentials(credentialsProvider).build();
}
项目:unitstack    文件:MockSqsTest.java   
@Before
public void setup() {
  mockSqs(null);

  EndpointConfiguration endpoint =
      new EndpointConfiguration(UNIT_STACK_URL + ":" + SQS_PORT, "eu-central-1");
  AWSCredentials credentials = new BasicAWSCredentials("key", "secret");
  AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);

  sqs = AmazonSQSAsyncClientBuilder.standard().withEndpointConfiguration(endpoint)
      .withCredentials(credentialsProvider).build();
}
项目:ibm-cos-sdk-java    文件:AwsClientBuilderTest.java   
@Test
public void endpointAndSigningRegionCanBeUsedInPlaceOfSetRegion() {
    AmazonConcreteClient client = new ConcreteSyncBuilder()
            .withEndpointConfiguration(new EndpointConfiguration("https://mockprefix.ap-southeast-2.amazonaws.com", "us-east-1"))
            .build();
    assertEquals("us-east-1", client.getSignerRegionOverride());
    assertEquals(URI.create("https://mockprefix.ap-southeast-2.amazonaws.com"), client.getEndpoint());
}
项目:ibm-cos-sdk-java    文件:AwsClientBuilderTest.java   
@Test(expected = IllegalStateException.class)
public void cannotSetBothEndpointConfigurationAndRegionOnBuilder() {
    new ConcreteSyncBuilder()
            .withEndpointConfiguration(new EndpointConfiguration("http://localhost:3030", "us-west-2"))
            .withRegion("us-east-1")
            .build();
}
项目:S3Mock    文件:S3MockRule.java   
/**
 * @return An {@link AmazonS3} client instance that is configured to call the started S3Mock
 *         server using HTTPS.
 */
public AmazonS3 createS3Client() {
  final BasicAWSCredentials credentials = new BasicAWSCredentials("foo", "bar");

  return AmazonS3ClientBuilder.standard()
      .withCredentials(new AWSStaticCredentialsProvider(credentials))
      .withClientConfiguration(
          configureClientToIgnoreInvalidSslCertificates(new ClientConfiguration()))
      .withEndpointConfiguration(
          new EndpointConfiguration("https://localhost:" + getPort(), "us-east-1"))
      .enablePathStyleAccess()
      .build();
}
项目:S3Mock    文件:AmazonClientUploadIT.java   
/**
 * Configures the S3-Client to be used in the Test. Sets the SSL context to accept untrusted SSL
 * connections.
 */
@Before
public void prepareS3Client() {
  final BasicAWSCredentials credentials = new BasicAWSCredentials("foo", "bar");

  s3Client = AmazonS3ClientBuilder.standard()
      .withCredentials(new AWSStaticCredentialsProvider(credentials))
      .withClientConfiguration(ignoringInvalidSslCertificates(new ClientConfiguration()))
      .withEndpointConfiguration(
          new EndpointConfiguration("https://" + getHost() + ":" + getPort(), "us-east-1"))
      .enablePathStyleAccess()
      .build();
}
项目:zipkin-aws    文件:KinesisSenderTest.java   
@Before
public void setup() throws Exception {
  sender = KinesisSender.builder()
      .streamName("test")
      .endpointConfiguration(new EndpointConfiguration(server.url("/").toString(), "us-east-1"))
      .credentialsProvider(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()))
      .build();
}
项目:georocket    文件:S3Store.java   
/**
 * Get or initialize the S3 client.
 * Note: this method must be synchronized because we're accessing the
 * {@link #s3Client} field and we're calling this method from a worker thread.
 * @return the S3 client
 */
private synchronized AmazonS3 getS3Client() {
  if (s3Client == null) {
    BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);

    AmazonS3ClientBuilder builder = AmazonS3ClientBuilder
      .standard()
      .withCredentials(new AWSStaticCredentialsProvider(credentials));

    if (forceSignatureV2) {
      ClientConfigurationFactory configFactory = new ClientConfigurationFactory();
      ClientConfiguration config = configFactory.getConfig();
      config.setSignerOverride("S3SignerType");
      builder = builder.withClientConfiguration(config);
    }

    String endpoint = "http://" + host + ":" + port;
    String clientRegion = null;
    if (!ServiceUtils.isS3USStandardEndpoint(endpoint)) {
      clientRegion = AwsHostNameUtils.parseRegion(host,
          AmazonS3Client.S3_SERVICE_NAME);
    }

    builder = builder.withEndpointConfiguration(new EndpointConfiguration(
        endpoint, clientRegion));
    builder = builder.withPathStyleAccessEnabled(pathStyleAccess);

    s3Client = builder.build();
  }
  return s3Client;
}
项目:AssortmentOfJUnitRules    文件:S3MockRule.java   
protected void before() throws Throwable {
  s3Mock = S3Mock.create(Helper.findRandomOpenPortOnAllLocalInterfaces());
  localAddress = s3Mock.start().localAddress();
  amazonS3 = AmazonS3ClientBuilder.standard()
      .withEndpointConfiguration(new EndpointConfiguration(getEndpoint(), "eu-west-1"))
      .build();

  buckets.forEach(amazonS3::createBucket);
  files.forEach(fakeFile -> amazonS3.putObject(fakeFile.bucket, fakeFile.name, fakeFile.content));
}
项目:AssortmentOfJUnitRules    文件:HttpDynamoDbRuleTest.java   
@Test
public void getterSetterTest() {
  String randomValue = UUID.randomUUID().toString();

  DynamoExample exampleClient = new DynamoExample(AmazonDynamoDBClientBuilder
      .standard()
      .withEndpointConfiguration(new EndpointConfiguration(subject.getEndpoint(), "eu-west-1"))
      .build());
  exampleClient.createTable();
  exampleClient.setValue(1L, randomValue);

  assertThat(exampleClient.getValue(1L), is(randomValue));
}
项目:s3proxy    文件:AwsSdkTest.java   
@Before
public void setUp() throws Exception {
    TestUtils.S3ProxyLaunchInfo info = TestUtils.startS3Proxy(
            "s3proxy.conf");
    awsCreds = new BasicAWSCredentials(info.getS3Identity(),
            info.getS3Credential());
    context = info.getBlobStore().getContext();
    s3Proxy = info.getS3Proxy();
    s3Endpoint = info.getSecureEndpoint();
    servicePath = info.getServicePath();
    s3EndpointConfig = new EndpointConfiguration(
            s3Endpoint.toString() + servicePath, "us-east-1");
    client = AmazonS3ClientBuilder.standard()
            .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
            .withEndpointConfiguration(s3EndpointConfig)
            .build();

    containerName = createRandomContainerName();
    info.getBlobStore().createContainerInLocation(null, containerName);

    blobStoreType = context.unwrap().getProviderMetadata().getId();
    if (Quirks.OPAQUE_ETAG.contains(blobStoreType)) {
        System.setProperty(
                SkipMd5CheckStrategy
                        .DISABLE_GET_OBJECT_MD5_VALIDATION_PROPERTY,
                "true");
        System.setProperty(
                SkipMd5CheckStrategy
                        .DISABLE_PUT_OBJECT_MD5_VALIDATION_PROPERTY,
                "true");
    }
}
项目:s3proxy    文件:AwsSdkAnonymousTest.java   
@Before
public void setUp() throws Exception {
    TestUtils.S3ProxyLaunchInfo info = TestUtils.startS3Proxy(
            "s3proxy-anonymous.conf");
    awsCreds = new AnonymousAWSCredentials();
    context = info.getBlobStore().getContext();
    s3Proxy = info.getS3Proxy();
    s3Endpoint = info.getSecureEndpoint();
    servicePath = info.getServicePath();
    s3EndpointConfig = new EndpointConfiguration(
            s3Endpoint.toString() + servicePath, "us-east-1");
    client = AmazonS3ClientBuilder.standard()
            .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
            .withEndpointConfiguration(s3EndpointConfig)
            .build();

    containerName = createRandomContainerName();
    info.getBlobStore().createContainerInLocation(null, containerName);

    blobStoreType = context.unwrap().getProviderMetadata().getId();
    if (Quirks.OPAQUE_ETAG.contains(blobStoreType)) {
        System.setProperty(
                SkipMd5CheckStrategy
                        .DISABLE_GET_OBJECT_MD5_VALIDATION_PROPERTY,
                "true");
        System.setProperty(
                SkipMd5CheckStrategy
                        .DISABLE_PUT_OBJECT_MD5_VALIDATION_PROPERTY,
                "true");
    }
}
项目:ats-framework    文件:S3Operations.java   
/**
 * Gets configured AmazonS3 client instance. Does not perform actual request until first remote data is needed
 */
private AmazonS3 getClient() {

    if (s3Client != null) {
        return s3Client; // already cached
    }

    ClientConfiguration config = new ClientConfiguration();
    if (endpoint != null && endpoint.startsWith("https://")) {
        config.setProtocol(Protocol.HTTPS);
    } else {
        config.setProtocol(Protocol.HTTP);
    }

    BasicAWSCredentials creds = new BasicAWSCredentials(accessKey, secretKey);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Creating S3 client to " + ( (endpoint == null)
                                                                  ? "default Amazon"
                                                                  : endpoint)
                  + " endpoint with access key " + accessKey);
    }

    if (this.endpoint != null) {
        if (region == null || region.trim().length() == 0) {
            region = Regions.DEFAULT_REGION.name();
        }
        s3Client = AmazonS3ClientBuilder.standard()
                                        .withCredentials(new AWSStaticCredentialsProvider(creds))
                                        .withEndpointConfiguration(new EndpointConfiguration(endpoint, region))
                                        .withClientConfiguration(config)
                                        .withPathStyleAccessEnabled(true)
                                        .build();
    } else {
        s3Client = AmazonS3ClientBuilder.standard()
                                        .withCredentials(new AWSStaticCredentialsProvider(creds))
                                        .withClientConfiguration(config)
                                        .withPathStyleAccessEnabled(true)
                                        .build();
    }
    return s3Client;
}
项目:mturk-code-samples    文件:CreateHITSample.java   
private static AmazonMTurk getSandboxClient() {
    AmazonMTurkClientBuilder builder = AmazonMTurkClientBuilder.standard();
    builder.setEndpointConfiguration(new EndpointConfiguration(SANDBOX_ENDPOINT, SIGNING_REGION));
    return builder.build();
}
项目:mturk-code-samples    文件:CreateHITSample.java   
private static AmazonMTurk getProdClient() {
    AmazonMTurkClientBuilder builder = AmazonMTurkClientBuilder.standard();
    builder.setEndpointConfiguration(new EndpointConfiguration(PROD_ENDPOINT, SIGNING_REGION));
    return builder.build();
}
项目:mturk-code-samples    文件:ApproveAssignmentsSample.java   
private static AmazonMTurk getSandboxClient() {
    AmazonMTurkClientBuilder builder = AmazonMTurkClientBuilder.standard();
    builder.setEndpointConfiguration(new EndpointConfiguration(SANDBOX_ENDPOINT, SIGNING_REGION));
    return builder.build();
}
项目:mturk-code-samples    文件:GetAccountBalanceSample.java   
private static AmazonMTurk getProductionClient() {
    AmazonMTurkClientBuilder builder = AmazonMTurkClientBuilder.standard();
    builder.setEndpointConfiguration(new EndpointConfiguration(PRODUCTION_ENDPOINT, SIGNING_REGION));
    return builder.build();
}
项目:mturk-code-samples    文件:GetAccountBalanceSample.java   
private static AmazonMTurk getSandboxClient() {
    AmazonMTurkClientBuilder builder = AmazonMTurkClientBuilder.standard();
    builder.setEndpointConfiguration(new EndpointConfiguration(SANDBOX_ENDPOINT, SIGNING_REGION));
    return builder.build();
}
项目:adeptj-modules    文件:AwsUtil.java   
public static EndpointConfiguration getEndpointConfig(String serviceEndpoint, String signingRegion) {
    return new EndpointConfiguration(serviceEndpoint, signingRegion);
}
项目:zipkin-aws    文件:KinesisSender.java   
@Nullable abstract EndpointConfiguration endpointConfiguration();
项目:zipkin-aws    文件:SQSSender.java   
@Nullable abstract EndpointConfiguration endpointConfiguration();