本文整理汇总了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);
}
}
示例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());
}
}
示例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);
}