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


Java GetRecordsResult.getRecords方法代码示例

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


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

示例1: processNextIterator

import com.amazonaws.services.kinesis.model.GetRecordsResult; //导入方法依赖的package包/类
public String processNextIterator(String iterator)
{
  GetRecordsRequest getRequest = new GetRecordsRequest();
  getRequest.setLimit(1000);

  getRequest.setShardIterator(iterator);
  // call "get" operation and get everything in this shard range
  GetRecordsResult getResponse = client.getRecords(getRequest);

  iterator = getResponse.getNextShardIterator();

  List<Record> records = getResponse.getRecords();
  processResponseRecords(records);

  return iterator;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:KinesisTestConsumer.java

示例2: getPreviewRecords

import com.amazonaws.services.kinesis.model.GetRecordsResult; //导入方法依赖的package包/类
public static List<com.amazonaws.services.kinesis.model.Record> getPreviewRecords(
    ClientConfiguration awsClientConfig,
    KinesisConfigBean conf,
    int maxBatchSize,
    GetShardIteratorRequest getShardIteratorRequest
) throws StageException {
  AmazonKinesis kinesisClient = getKinesisClient(awsClientConfig, conf);

  GetShardIteratorResult getShardIteratorResult = kinesisClient.getShardIterator(getShardIteratorRequest);
  String shardIterator = getShardIteratorResult.getShardIterator();

  GetRecordsRequest getRecordsRequest = new GetRecordsRequest();
  getRecordsRequest.setShardIterator(shardIterator);
  getRecordsRequest.setLimit(maxBatchSize);

  GetRecordsResult getRecordsResult = kinesisClient.getRecords(getRecordsRequest);
  return getRecordsResult.getRecords();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:19,代码来源:KinesisUtil.java

示例3: poll

import com.amazonaws.services.kinesis.model.GetRecordsResult; //导入方法依赖的package包/类
@Override
public List<SourceRecord> poll() throws InterruptedException {
  List<SourceRecord> records;

  try {
    GetRecordsResult recordsResult = this.kinesisClient.getRecords(this.recordsRequest);
    records = new ArrayList<>(recordsResult.getRecords().size());
    log.trace("poll() - {} record(s) returned from shard {}.", this.config.kinesisShardId);

    for (Record record : recordsResult.getRecords()) {
      SourceRecord sourceRecord = this.recordConverter.sourceRecord(this.config.kinesisStreamName, this.config.kinesisShardId, record);
      records.add(sourceRecord);
    }

    log.trace("poll() - Changing shard iterator to {}", recordsResult.getNextShardIterator());
    this.recordsRequest.setShardIterator(recordsResult.getNextShardIterator());
  } catch (ProvisionedThroughputExceededException ex) {
    log.warn("poll() - Throughput exceeded sleeping {} ms", this.config.kinesisThroughputExceededBackoffMs, ex);
    this.time.sleep(this.config.kinesisThroughputExceededBackoffMs);
    return new ArrayList<>();
  }

  if (records.isEmpty()) {
    log.trace("poll() - No records returned. Sleeping {} ms.", this.config.kinesisEmptyRecordsBackoffMs);
    this.time.sleep(this.config.kinesisEmptyRecordsBackoffMs);
  }

  return records;
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-kinesis,代码行数:30,代码来源:KinesisSourceTask.java

示例4: main

import com.amazonaws.services.kinesis.model.GetRecordsResult; //导入方法依赖的package包/类
public static void main(String[] args) {
	AmazonKinesisClient kinesisClient = Helper.setupKinesisClient();

	// Retrieve the Shards from a Stream
	DescribeStreamRequest describeStreamRequest = new DescribeStreamRequest();
	describeStreamRequest.setStreamName(Helper.properties().getProperty("kinesisStreamName"));
	DescribeStreamResult describeStreamResult;
	List<Shard> shards = new ArrayList<>();
	String lastShardId = null;

	do {
	    describeStreamRequest.setExclusiveStartShardId(lastShardId);
	    describeStreamResult = kinesisClient.describeStream(describeStreamRequest);
	    shards.addAll(describeStreamResult.getStreamDescription().getShards());
	    if (shards.size() > 0) {
	        lastShardId = shards.get(shards.size() - 1).getShardId();
	    }
	} while (describeStreamResult.getStreamDescription().getHasMoreShards());

	// Get Data from the Shards in a Stream
	// Hard-coded to use only 1 shard
	String shardIterator;
	GetShardIteratorRequest getShardIteratorRequest = new GetShardIteratorRequest();
	getShardIteratorRequest.setStreamName(Helper.properties().getProperty("kinesisStreamName"));
	getShardIteratorRequest.setShardId(shards.get(0).getShardId());
	getShardIteratorRequest.setShardIteratorType("TRIM_HORIZON");

	GetShardIteratorResult getShardIteratorResult = kinesisClient.getShardIterator(getShardIteratorRequest);
	shardIterator = getShardIteratorResult.getShardIterator();

	// Continuously read data records from shard.
	List<Record> records;
	while (true) {
		// Create new GetRecordsRequest with existing shardIterator.
		// Set maximum records to return to 1000.
		GetRecordsRequest getRecordsRequest = new GetRecordsRequest();
		getRecordsRequest.setShardIterator(shardIterator);
		getRecordsRequest.setLimit(1000);

		GetRecordsResult result = kinesisClient.getRecords(getRecordsRequest);

		// Put result into record list. Result may be empty.
		records = result.getRecords();

		// Print records
		for (Record record : records) {
			ByteBuffer byteBuffer = record.getData();
			System.out.println(String.format("Seq No: %s - %s", record.getSequenceNumber(),
					new String(byteBuffer.array())));
		}

		try {
			Thread.sleep(1000);
		} catch (InterruptedException exception) {
			throw new RuntimeException(exception);
		}

		shardIterator = result.getNextShardIterator();
	}
}
 
开发者ID:twitterdev,项目名称:twttr-kinesis,代码行数:61,代码来源:TweetProcessor.java


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