本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.Shard类的典型用法代码示例。如果您正苦于以下问题:Java Shard类的具体用法?Java Shard怎么用?Java Shard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Shard类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了Shard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: atAfterSeq
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
Shard atAfterSeq(String sequenceNumber, BigIntComparisons condition) {
BigInteger atAfter = new BigInteger(sequenceNumber);
List<Shard> sorted = new ArrayList<>();
sorted.addAll(shards.values());
Collections.sort(sorted, StartingSequenceNumberComparator.INSTANCE);
for (Shard shard : sorted) {
if (shard.getSequenceNumberRange().getEndingSequenceNumber() != null) {
BigInteger end = new BigInteger(shard.getSequenceNumberRange().getEndingSequenceNumber());
// essentially: after < end or after <= end
if (condition.matches(atAfter, end)) {
return shard;
}
}
}
if (shards.size() > 0) {
return sorted.get(sorted.size() - 1);
}
throw new IllegalStateException("Unable to find a shard with appropriate sequence numbers for " + sequenceNumber + " in " + shards);
}
示例2: removeOlderThan
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
/**
* Removes shards that are older than the provided shard. Does not remove
* the provided shard.
*
* @param removeBefore
*/
void removeOlderThan(Shard removeBefore) {
String current = removeBefore.getParentShardId();
int removedShards = 0;
while (current != null) {
Shard s = shards.remove(current);
if (s == null) {
current = null;
} else {
removedShards++;
current = s.getParentShardId();
}
}
log.trace("removed {} shards from the store, new size is {}", removedShards, shards.size());
}
示例3: reAddingEntriesMaintainsOrder
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
@Test
public void reAddingEntriesMaintainsOrder() throws Exception {
Shard first = new Shard()
.withShardId("first_shard");
Shard second = new Shard()
.withParentShardId("first_shard")
.withShardId("second_shard");
ShardList shards = new ShardList();
shards.add(first);
shards.add(second);
assertThat(shards.nextAfter(first), is(second));
Shard second2 = new Shard()
.withParentShardId("first_shard")
.withShardId("second_shard");
Shard third = new Shard()
.withParentShardId("second_shard")
.withShardId("third_shard");
shards.add(second2);
shards.add(third);
assertThat(shards.nextAfter(first), is(second));
assertThat(shards.nextAfter(second), is(third));
}
示例4: createShardsWithSequenceNumbers
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
static List<Shard> createShardsWithSequenceNumbers(String initialParent, String... shardIdsAndSeqNos) {
String previous = initialParent;
List<Shard> result = new ArrayList<>();
for (int i = 0; i < shardIdsAndSeqNos.length; i += 3) {
String id = shardIdsAndSeqNos[i];
String seqStart = shardIdsAndSeqNos[i + 1];
String seqEnd = shardIdsAndSeqNos[i + 2];
result.add(new Shard()
.withShardId(id)
.withParentShardId(previous)
.withSequenceNumberRange(new SequenceNumberRange()
.withStartingSequenceNumber(seqStart)
.withEndingSequenceNumber(seqEnd)
)
);
previous = id;
}
return result;
}
示例5: taskConfigs
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
@Override
public List<Map<String, String>> taskConfigs(int maxTasks) {
return ConnectorUtils.groupPartitions(new ArrayList<>(streamShards.keySet()), maxTasks).stream().map(taskShards -> {
final Map<String, String> taskConfig = new HashMap<>();
taskConfig.put(TaskConfig.Keys.REGION, config.region.getName());
taskConfig.put(TaskConfig.Keys.TOPIC_FORMAT, config.topicFormat);
taskConfig.put(TaskConfig.Keys.SHARDS, taskShards.stream().map(Shard::getShardId).collect(Collectors.joining(",")));
taskShards.forEach(shard -> {
final TableDescription tableDesc = streamShards.get(shard);
taskConfig.put(shard.getShardId() + "." + TaskConfig.Keys.TABLE, tableDesc.getTableName());
taskConfig.put(shard.getShardId() + "." + TaskConfig.Keys.STREAM_ARN, tableDesc.getLatestStreamArn());
});
return taskConfig;
}).collect(Collectors.toList());
}
示例6: nextAfter
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
Shard nextAfter(Shard previous) {
for (Shard shard : shards.values()) {
if (previous.getShardId().equals(shard.getParentShardId())) {
return shard;
}
}
throw new IllegalStateException("Unable to find the next shard for " + previous + " in " + shards);
}
示例7: first
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
Shard first() {
// Potential optimisation: if the two provided sequence numbers are the
// same then we can skip the shard entirely. Need to confirm this with AWS.
for (Shard shard : shards.values()) {
if (!shards.containsKey(shard.getParentShardId())) {
return shard;
}
}
throw new IllegalStateException("Unable to find an unparented shard in " + shards);
}
示例8: resolveNewShard
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
private Shard resolveNewShard(ShardIteratorType type, String resumeFrom) {
switch(type) {
case AFTER_SEQUENCE_NUMBER:
return shardList.afterSeq(resumeFrom != null ? resumeFrom : getEndpoint().getSequenceNumber());
case AT_SEQUENCE_NUMBER:
return shardList.atSeq(getEndpoint().getSequenceNumber());
case TRIM_HORIZON:
return shardList.first();
case LATEST:
default:
return shardList.last();
}
}
示例9: nextReturnsShardWithParent
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
@Test
public void nextReturnsShardWithParent() throws Exception {
Shard first = new Shard()
.withShardId("first_shard")
.withParentShardId("other_shard_id");
Shard second = new Shard()
.withParentShardId("first_shard")
.withShardId("second_shard");
ShardList shards = new ShardList();
shards.add(first);
shards.add(second);
assertThat(shards.nextAfter(first), is(second));
}
示例10: nextWithNullReturnsFirstKnownShard
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
@Test
public void nextWithNullReturnsFirstKnownShard() throws Exception {
Shard first = new Shard()
.withShardId("first_shard");
Shard second = new Shard()
.withParentShardId("first_shard")
.withShardId("second_shard");
ShardList shards = new ShardList();
shards.add(first);
shards.add(second);
assertThat(shards.nextAfter(first), is(second));
}
示例11: removingShards
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
@Test
public void removingShards() throws Exception {
ShardList shards = new ShardList();
shards.addAll(createShards(null, "a", "b", "c", "d"));
Shard removeBefore = new Shard().withShardId("c").withParentShardId("b");
shards.removeOlderThan(removeBefore);
assertThat(shards.first().getShardId(), is("c"));
}
示例12: createShards
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
static List<Shard> createShards(String initialParent, String... shardIds) {
String previous = initialParent;
List<Shard> result = new ArrayList<>();
for (String s : shardIds) {
result.add(new Shard().withShardId(s).withParentShardId(previous));
previous = s;
}
return result;
}
示例13: addAll
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
void addAll(Collection<Shard> shards) {
for (Shard shard : shards) {
add(shard);
}
}
示例14: add
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
void add(Shard shard) {
shards.put(shard.getShardId(), shard);
}
示例15: afterSeq
import com.amazonaws.services.dynamodbv2.model.Shard; //导入依赖的package包/类
Shard afterSeq(String sequenceNumber) {
return atAfterSeq(sequenceNumber, BigIntComparisons.Conditions.LT);
}