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


Java AWSConfigConstants类代码示例

本文整理汇总了Java中org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants的典型用法代码示例。如果您正苦于以下问题:Java AWSConfigConstants类的具体用法?Java AWSConfigConstants怎么用?Java AWSConfigConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AWSConfigConstants类属于org.apache.flink.streaming.connectors.kinesis.config包,在下文中一共展示了AWSConfigConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	ParameterTool pt = ParameterTool.fromArgs(args);

	StreamExecutionEnvironment see = StreamExecutionEnvironment.getExecutionEnvironment();
	see.setParallelism(1);

	DataStream<String> simpleStringStream = see.addSource(new EventsGenerator());

	Properties kinesisProducerConfig = new Properties();
	kinesisProducerConfig.setProperty(AWSConfigConstants.AWS_REGION, pt.getRequired("region"));
	kinesisProducerConfig.setProperty(AWSConfigConstants.AWS_ACCESS_KEY_ID, pt.getRequired("accessKey"));
	kinesisProducerConfig.setProperty(AWSConfigConstants.AWS_SECRET_ACCESS_KEY, pt.getRequired("secretKey"));

	FlinkKinesisProducer<String> kinesis = new FlinkKinesisProducer<>(
			new SimpleStringSchema(), kinesisProducerConfig);

	kinesis.setFailOnError(true);
	kinesis.setDefaultStream("flink-test");
	kinesis.setDefaultPartition("0");

	simpleStringStream.addSink(kinesis);

	see.execute();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:ProduceIntoKinesis.java

示例2: createKinesisClient

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
/**
 * Creates an AmazonKinesis client.
 * @param configProps configuration properties containing the access key, secret key, and region
 * @return a new AmazonKinesis client
 */
public static AmazonKinesis createKinesisClient(Properties configProps) {
	// set a Flink-specific user agent
	ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig()
			.withUserAgentPrefix(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)
			.withRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION)));

	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));
	}
	return builder.build();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:AWSUtil.java

示例3: createKinesisClient

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
/**
 * Creates an Amazon Kinesis Client.
 * @param configProps configuration properties containing the access key, secret key, and region
 * @return a new Amazon Kinesis Client
 */
public static AmazonKinesisClient createKinesisClient(Properties configProps) {
	// set a Flink-specific user agent
	ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
	awsClientConfig.setUserAgent("Apache Flink " + EnvironmentInformation.getVersion() +
		" (" + EnvironmentInformation.getRevisionInformation().commitId + ") Kinesis Connector");

	// utilize automatic refreshment of credentials by directly passing the AWSCredentialsProvider
	AmazonKinesisClient client = new AmazonKinesisClient(
		AWSUtil.getCredentialsProvider(configProps), awsClientConfig);

	client.setRegion(Region.getRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION))));
	if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) {
		client.setEndpoint(configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT));
	}
	return client;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:AWSUtil.java

示例4: getValidatedProducerConfiguration

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
/**
 * Validate configuration properties for {@link FlinkKinesisProducer},
 * and return a constructed KinesisProducerConfiguration.
 */
public static KinesisProducerConfiguration getValidatedProducerConfiguration(Properties config) {
	checkNotNull(config, "config can not be null");

	validateAwsConfiguration(config);

	KinesisProducerConfiguration kpc = KinesisProducerConfiguration.fromProperties(config);
	kpc.setRegion(config.getProperty(AWSConfigConstants.AWS_REGION));

	kpc.setCredentialsProvider(AWSUtil.getCredentialsProvider(config));

	// we explicitly lower the credential refresh delay (default is 5 seconds)
	// to avoid an ignorable interruption warning that occurs when shutting down the
	// KPL client. See https://github.com/awslabs/amazon-kinesis-producer/issues/10.
	kpc.setCredentialsRefreshDelay(100);

	// Override default values if they aren't specified by users
	if (!config.containsKey(RATE_LIMIT)) {
		kpc.setRateLimit(DEFAULT_RATE_LIMIT);
	}
	if (!config.containsKey(THREADING_MODEL)) {
		kpc.setThreadingModel(DEFAULT_THREADING_MODEL);
	}
	if (!config.containsKey(THREAD_POOL_SIZE)) {
		kpc.setThreadPoolSize(DEFAULT_THREAD_POOL_SIZE);
	}

	return kpc;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:33,代码来源:KinesisConfigUtil.java

示例5: testUnparsableLongForProducerConfiguration

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
@Test
public void testUnparsableLongForProducerConfiguration() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Error trying to set field RateLimit with the value 'unparsableLong'");

	Properties testConfig = new Properties();
	testConfig.setProperty(AWSConfigConstants.AWS_REGION, "us-east-1");
	testConfig.setProperty("RateLimit", "unparsableLong");

	KinesisConfigUtil.getValidatedProducerConfiguration(testConfig);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:KinesisConfigUtilTest.java

示例6: testRateLimitInProducerConfiguration

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
@Test
public void testRateLimitInProducerConfiguration() {
	Properties testConfig = new Properties();
	testConfig.setProperty(AWSConfigConstants.AWS_REGION, "us-east-1");
	KinesisProducerConfiguration kpc = KinesisConfigUtil.getValidatedProducerConfiguration(testConfig);

	assertEquals(100, kpc.getRateLimit());

	testConfig.setProperty(KinesisConfigUtil.RATE_LIMIT, "150");
	kpc = KinesisConfigUtil.getValidatedProducerConfiguration(testConfig);

	assertEquals(150, kpc.getRateLimit());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:KinesisConfigUtilTest.java

示例7: testThreadingModelInProducerConfiguration

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
@Test
public void testThreadingModelInProducerConfiguration() {
	Properties testConfig = new Properties();
	testConfig.setProperty(AWSConfigConstants.AWS_REGION, "us-east-1");
	KinesisProducerConfiguration kpc = KinesisConfigUtil.getValidatedProducerConfiguration(testConfig);

	assertEquals(KinesisProducerConfiguration.ThreadingModel.POOLED, kpc.getThreadingModel());

	testConfig.setProperty(KinesisConfigUtil.THREADING_MODEL, "PER_REQUEST");
	kpc = KinesisConfigUtil.getValidatedProducerConfiguration(testConfig);

	assertEquals(KinesisProducerConfiguration.ThreadingModel.PER_REQUEST, kpc.getThreadingModel());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:KinesisConfigUtilTest.java

示例8: testThreadPoolSizeInProducerConfiguration

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
@Test
public void testThreadPoolSizeInProducerConfiguration() {
	Properties testConfig = new Properties();
	testConfig.setProperty(AWSConfigConstants.AWS_REGION, "us-east-1");
	KinesisProducerConfiguration kpc = KinesisConfigUtil.getValidatedProducerConfiguration(testConfig);

	assertEquals(10, kpc.getThreadPoolSize());

	testConfig.setProperty(KinesisConfigUtil.THREAD_POOL_SIZE, "12");
	kpc = KinesisConfigUtil.getValidatedProducerConfiguration(testConfig);

	assertEquals(12, kpc.getThreadPoolSize());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:KinesisConfigUtilTest.java

示例9: testReplaceDeprecatedKeys

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
@Test
public void testReplaceDeprecatedKeys() {
	Properties testConfig = new Properties();
	testConfig.setProperty(AWSConfigConstants.AWS_REGION, "us-east-1");
	// these deprecated keys should be replaced
	testConfig.setProperty(ProducerConfigConstants.AGGREGATION_MAX_COUNT, "1");
	testConfig.setProperty(ProducerConfigConstants.COLLECTION_MAX_COUNT, "2");
	Properties replacedConfig = KinesisConfigUtil.replaceDeprecatedProducerKeys(testConfig);

	assertEquals("1", replacedConfig.getProperty(KinesisConfigUtil.AGGREGATION_MAX_COUNT));
	assertEquals("2", replacedConfig.getProperty(KinesisConfigUtil.COLLECTION_MAX_COUNT));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:KinesisConfigUtilTest.java

示例10: testCorrectlySetRegionInProducerConfiguration

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
@Test
public void testCorrectlySetRegionInProducerConfiguration() {
	String region = "us-east-1";
	Properties testConfig = new Properties();
	testConfig.setProperty(AWSConfigConstants.AWS_REGION, region);
	KinesisProducerConfiguration kpc = KinesisConfigUtil.getValidatedProducerConfiguration(testConfig);

	assertEquals("incorrect region", region, kpc.getRegion());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:KinesisConfigUtilTest.java

示例11: testMissingAwsRegionInConfig

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
@Test
public void testMissingAwsRegionInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("The AWS region ('" + AWSConfigConstants.AWS_REGION + "') must be set in the config.");

	Properties testConfig = new Properties();
	testConfig.setProperty(AWSConfigConstants.AWS_ACCESS_KEY_ID, "accessKey");
	testConfig.setProperty(AWSConfigConstants.AWS_SECRET_ACCESS_KEY, "secretKey");

	KinesisConfigUtil.validateAwsConfiguration(testConfig);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:KinesisConfigUtilTest.java

示例12: testUnrecognizableAwsRegionInConfig

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
@Test
public void testUnrecognizableAwsRegionInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid AWS region");

	Properties testConfig = new Properties();
	testConfig.setProperty(AWSConfigConstants.AWS_REGION, "wrongRegionId");
	testConfig.setProperty(AWSConfigConstants.AWS_ACCESS_KEY_ID, "accessKeyId");
	testConfig.setProperty(AWSConfigConstants.AWS_SECRET_ACCESS_KEY, "secretKey");

	KinesisConfigUtil.validateAwsConfiguration(testConfig);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:KinesisConfigUtilTest.java

示例13: testCredentialProviderTypeSetToBasicButNoCredentialSetInConfig

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
@Test
public void testCredentialProviderTypeSetToBasicButNoCredentialSetInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Please set values for AWS Access Key ID ('" + AWSConfigConstants.AWS_ACCESS_KEY_ID + "') " +
			"and Secret Key ('" + AWSConfigConstants.AWS_SECRET_ACCESS_KEY + "') when using the BASIC AWS credential provider type.");

	Properties testConfig = new Properties();
	testConfig.setProperty(AWSConfigConstants.AWS_REGION, "us-east-1");
	testConfig.setProperty(AWSConfigConstants.AWS_CREDENTIALS_PROVIDER, "BASIC");

	KinesisConfigUtil.validateAwsConfiguration(testConfig);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:KinesisConfigUtilTest.java

示例14: testUnrecognizableCredentialProviderTypeInConfig

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
@Test
public void testUnrecognizableCredentialProviderTypeInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid AWS Credential Provider Type");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(AWSConfigConstants.AWS_CREDENTIALS_PROVIDER, "wrongProviderType");

	KinesisConfigUtil.validateAwsConfiguration(testConfig);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:11,代码来源:KinesisConfigUtilTest.java

示例15: getStandardProperties

import org.apache.flink.streaming.connectors.kinesis.config.AWSConfigConstants; //导入依赖的package包/类
/**
 * Get standard Kinesis-related config properties.
 */
public static Properties getStandardProperties() {
	Properties config = new Properties();
	config.setProperty(AWSConfigConstants.AWS_REGION, "us-east-1");
	config.setProperty(AWSConfigConstants.AWS_ACCESS_KEY_ID, "accessKeyId");
	config.setProperty(AWSConfigConstants.AWS_SECRET_ACCESS_KEY, "secretKey");

	return config;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:TestUtils.java


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