Java Code Examples for com.amazonaws.services.kinesis.AmazonKinesisClientBuilder#build()
The following examples show how to use
com.amazonaws.services.kinesis.AmazonKinesisClientBuilder#build() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWSUtil.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Creates an Amazon Kinesis Client. * @param configProps configuration properties containing the access key, secret key, and region * @param awsClientConfig preconfigured AWS SDK client configuration * @return a new Amazon Kinesis Client */ public static AmazonKinesis createKinesisClient(Properties configProps, ClientConfiguration awsClientConfig) { // set a Flink-specific user agent awsClientConfig.setUserAgentPrefix(String.format(USER_AGENT_FORMAT, EnvironmentInformation.getVersion(), EnvironmentInformation.getRevisionInformation().commitId)); // utilize automatic refreshment of credentials by directly passing the AWSCredentialsProvider AmazonKinesisClientBuilder builder = AmazonKinesisClientBuilder.standard() .withCredentials(AWSUtil.getCredentialsProvider(configProps)) .withClientConfiguration(awsClientConfig); if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) { // Set signingRegion as null, to facilitate mocking Kinesis for local tests builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration( configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT), null)); } else { builder.withRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION))); } return builder.build(); }
Example 2
Source File: AWSUtil.java From flink with Apache License 2.0 | 6 votes |
/** * Creates an Amazon Kinesis Client. * @param configProps configuration properties containing the access key, secret key, and region * @param awsClientConfig preconfigured AWS SDK client configuration * @return a new Amazon Kinesis Client */ public static AmazonKinesis createKinesisClient(Properties configProps, ClientConfiguration awsClientConfig) { // set a Flink-specific user agent awsClientConfig.setUserAgentPrefix(String.format(USER_AGENT_FORMAT, EnvironmentInformation.getVersion(), EnvironmentInformation.getRevisionInformation().commitId)); // utilize automatic refreshment of credentials by directly passing the AWSCredentialsProvider AmazonKinesisClientBuilder builder = AmazonKinesisClientBuilder.standard() .withCredentials(AWSUtil.getCredentialsProvider(configProps)) .withClientConfiguration(awsClientConfig); if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) { // Set signingRegion as null, to facilitate mocking Kinesis for local tests builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration( configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT), null)); } else { builder.withRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION))); } return builder.build(); }
Example 3
Source File: AWSUtil.java From flink with Apache License 2.0 | 6 votes |
/** * Creates an Amazon Kinesis Client. * @param configProps configuration properties containing the access key, secret key, and region * @param awsClientConfig preconfigured AWS SDK client configuration * @return a new Amazon Kinesis Client */ public static AmazonKinesis createKinesisClient(Properties configProps, ClientConfiguration awsClientConfig) { // set a Flink-specific user agent awsClientConfig.setUserAgentPrefix(String.format(USER_AGENT_FORMAT, EnvironmentInformation.getVersion(), EnvironmentInformation.getRevisionInformation().commitId)); // utilize automatic refreshment of credentials by directly passing the AWSCredentialsProvider AmazonKinesisClientBuilder builder = AmazonKinesisClientBuilder.standard() .withCredentials(AWSUtil.getCredentialsProvider(configProps)) .withClientConfiguration(awsClientConfig); if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) { // If an endpoint is specified, we give preference to using an endpoint and use the region property to // sign the request. builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration( configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT), configProps.getProperty(AWSConfigConstants.AWS_REGION))); } else { builder.withRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION))); } return builder.build(); }
Example 4
Source File: AWSClientUtils.java From camel-kafka-connector with Apache License 2.0 | 5 votes |
public static AmazonKinesis newKinesisClient() { LOG.debug("Creating a new AWS Kinesis client"); AmazonKinesisClientBuilder clientBuilder = AmazonKinesisClientBuilder.standard(); String awsInstanceType = System.getProperty("aws-service.kinesis.instance.type"); String region = getRegion(); if (awsInstanceType == null || awsInstanceType.equals("local-aws-container")) { String amazonHost = System.getProperty(AWSConfigs.AMAZON_AWS_HOST); LOG.debug("Creating a new AWS Kinesis client to access {}", amazonHost); ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setProtocol(Protocol.HTTP); clientBuilder .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(amazonHost, region)) .withClientConfiguration(clientConfiguration) .withCredentials(new TestAWSCredentialsProvider("accesskey", "secretkey")); } else { clientBuilder .withRegion(region) .withCredentials(new TestAWSCredentialsProvider()); } return clientBuilder.build(); }
Example 5
Source File: BasicKinesisProvider.java From beam with Apache License 2.0 | 5 votes |
@Override public AmazonKinesis getKinesisClient() { AmazonKinesisClientBuilder clientBuilder = AmazonKinesisClientBuilder.standard().withCredentials(getCredentialsProvider()); if (serviceEndpoint == null) { clientBuilder.withRegion(region); } else { clientBuilder.withEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration(serviceEndpoint, region.getName())); } return clientBuilder.build(); }
Example 6
Source File: KinesisUtil.java From datacollector with Apache License 2.0 | 5 votes |
private static AmazonKinesis getKinesisClient(ClientConfiguration awsClientConfig, KinesisConfigBean conf) throws StageException { AmazonKinesisClientBuilder builder = AmazonKinesisClientBuilder .standard() .withClientConfiguration(checkNotNull(awsClientConfig)) .withCredentials(AWSUtil.getCredentialsProvider(conf.awsConfig)); if (AwsRegion.OTHER == conf.region) { builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(conf.endpoint, null)); } else { builder.withRegion(conf.region.getId()); } return builder.build(); }
Example 7
Source File: TalendKinesisProvider.java From components with Apache License 2.0 | 5 votes |
@Override public AmazonKinesis getKinesisClient() { AmazonKinesisClientBuilder clientBuilder = AmazonKinesisClientBuilder.standard().withCredentials(getCredentialsProvier()); if (specifyEndpoint) { clientBuilder .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region.getName())); } else { clientBuilder.setRegion(region.getName()); } return clientBuilder.build(); }