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


Java AmazonKinesis.setRegion方法代码示例

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


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

示例1: main

import com.amazonaws.services.kinesis.AmazonKinesis; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    verify(args);
    String stream = args[0];
    Region region = RegionUtils.getRegion(args[1]);

    AWSCredentials credentials = getCreds();
    AmazonKinesis client = new AmazonKinesisClient(credentials, CLIENT_CONF);
    client.setRegion(region);
    checkStream(client.describeStream(stream));

    System.out.println("Let's start putting records!");
    Random rnd = new Random(System.currentTimeMillis());
    for (;;) {
        putEventRecord(client, stream);
        Thread.sleep(rnd.nextInt(500) + 650);
    }
}
 
开发者ID:lenards,项目名称:spark-cstar-canaries,代码行数:18,代码来源:Producer.java

示例2: scanKinesis

import com.amazonaws.services.kinesis.AmazonKinesis; //导入方法依赖的package包/类
/**
 * Collect data for Kinesis.
 *
 * @param stats
 *            current statistics object.
 * @param account
 *            currently used credentials object.
 * @param region
 *            currently used aws region.
 */
public static void scanKinesis(AwsStats stats, AwsAccount account, Regions region) {
	LOG.debug("Scan for Kinesis in region " + region.getName() + " in account " + account.getAccountId());

	try {
		AmazonKinesis kinesis = new AmazonKinesisClient(account.getCredentials());
		kinesis.setRegion(Region.getRegion(region));

		List<String> list = kinesis.listStreams().getStreamNames();

		int totalItems = list.size();
		for (String streamName : list) {
			stats.add(new AwsResource(streamName, account.getAccountId(), AwsResourceType.Kinesis, region));
		}

		LOG.info(totalItems + " Kinesis streams in region " + region.getName() + " in account " + account.getAccountId());
	} catch (AmazonServiceException ase) {
		LOG.error("Exception of Kinesis: " + ase.getMessage());
	}
}
 
开发者ID:janloeffler,项目名称:aws-utilization-monitor,代码行数:30,代码来源:AwsScan.java

示例3: run

import com.amazonaws.services.kinesis.AmazonKinesis; //导入方法依赖的package包/类
private void run(final int events, final OutputFormat format,
		final String streamName, final String region) throws Exception {
	AmazonKinesis kinesisClient = new AmazonKinesisClient(
			new DefaultAWSCredentialsProviderChain());
	kinesisClient.setRegion(Region.getRegion(Regions.fromName(region)));
	int count = 0;
	SensorReading r = null;
	do {
		r = nextSensorReading(format);

		try {
			PutRecordRequest req = new PutRecordRequest()
					.withPartitionKey("" + rand.nextLong())
					.withStreamName(streamName)
					.withData(ByteBuffer.wrap(r.toString().getBytes()));
			kinesisClient.putRecord(req);
		} catch (ProvisionedThroughputExceededException e) {
			Thread.sleep(BACKOFF);
		}

		System.out.println(r);
		count++;
	} while (count < events);
}
 
开发者ID:awslabs,项目名称:amazon-kinesis-aggregators,代码行数:25,代码来源:SensorReadingProducer.java


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