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


Java DescribeStreamRequest类代码示例

本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.DescribeStreamRequest的典型用法代码示例。如果您正苦于以下问题:Java DescribeStreamRequest类的具体用法?Java DescribeStreamRequest怎么用?Java DescribeStreamRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DescribeStreamRequest类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了DescribeStreamRequest类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getShardIterator

import com.amazonaws.services.dynamodbv2.model.DescribeStreamRequest; //导入依赖的package包/类
String getShardIterator(String resumeFromSequenceNumber) {
    ShardIteratorType iteratorType = getEndpoint().getIteratorType();
    String sequenceNumber = getEndpoint().getSequenceNumber();
    if (resumeFromSequenceNumber != null) {
        // Reset things as we're in an error condition.
        currentShard = null;
        currentShardIterator = null;
        iteratorType = ShardIteratorType.AFTER_SEQUENCE_NUMBER;
        sequenceNumber = resumeFromSequenceNumber;
    }
    // either return a cached one or get a new one via a GetShardIterator request.
    if (currentShardIterator == null) {
        ListStreamsResult streamsListResult = getClient().listStreams(
                new ListStreamsRequest().withTableName(getEndpoint().getTableName())
        );
        final String streamArn = streamsListResult.getStreams().get(0).getStreamArn(); // XXX assumes there is only one stream
        DescribeStreamResult streamDescriptionResult = getClient().describeStream(
                new DescribeStreamRequest().withStreamArn(streamArn)
        );
        shardList.addAll(streamDescriptionResult.getStreamDescription().getShards());

        LOG.trace("Current shard is: {} (in {})", currentShard, shardList);
        if (currentShard == null) {
            currentShard = resolveNewShard(iteratorType, resumeFromSequenceNumber);
        } else {
            currentShard = shardList.nextAfter(currentShard);
        }
        shardList.removeOlderThan(currentShard);
        LOG.trace("Next shard is: {} (in {})", currentShard, shardList);

        GetShardIteratorResult result = getClient().getShardIterator(
                buildGetShardIteratorRequest(streamArn, iteratorType, sequenceNumber)
        );
        currentShardIterator = result.getShardIterator();
    }
    LOG.trace("Shard Iterator is: {}", currentShardIterator);
    return currentShardIterator;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:ShardIteratorHandler.java

示例2: setup

import com.amazonaws.services.dynamodbv2.model.DescribeStreamRequest; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    endpoint.setAmazonDynamoDbStreamsClient(amazonDynamoDBStreams);
    undertest = new ShardIteratorHandler(endpoint);

    when(amazonDynamoDBStreams.listStreams(any(ListStreamsRequest.class))).thenReturn(
        new ListStreamsResult()
            .withStreams(new Stream()
                    .withStreamArn("arn:aws:dynamodb:region:12345:table/table_name/stream/timestamp")
            )
    );

    when(amazonDynamoDBStreams.describeStream(any(DescribeStreamRequest.class))).thenReturn(
        new DescribeStreamResult()
            .withStreamDescription(
                    new StreamDescription()
                    .withTableName("table_name")
                    .withShards(
                            ShardListTest.createShardsWithSequenceNumbers(null,
                                    "a", "1", "5",
                                    "b", "8", "15",
                                    "c", "16", "16",
                                    "d", "20", null
                            )
                    )
            )
    );

    when(amazonDynamoDBStreams.getShardIterator(any(GetShardIteratorRequest.class))).thenAnswer(new Answer<GetShardIteratorResult>() {
        @Override
        public GetShardIteratorResult answer(InvocationOnMock invocation) throws Throwable {
            return new GetShardIteratorResult()
                    .withShardIterator("shard_iterator_"
                            + ((GetShardIteratorRequest) invocation.getArguments()[0]).getShardId()
                            + "_000");
        }
    });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:ShardIteratorHandlerTest.java


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