use of org.apache.bookkeeper.stream.proto.storage.RelatedRanges in project bookkeeper by apache.
the class ProtocolInternalUtils method createActiveRanges.
static HashStreamRanges createActiveRanges(GetActiveRangesResponse response) {
TreeMap<Long, RangeProperties> ranges = Maps.newTreeMap();
long lastEndKey = Long.MIN_VALUE;
for (RelatedRanges rr : response.getRangesList()) {
RangeProperties range = rr.getProps();
long startKey = range.getStartHashKey();
long endKey = range.getEndHashKey();
checkState(lastEndKey == startKey, "Invalid range key found : expected = %s, actual = %s", lastEndKey, startKey);
ranges.put(startKey, range);
lastEndKey = endKey;
}
checkState(Long.MAX_VALUE == lastEndKey, "Missing key range [%s - %s)", lastEndKey, Long.MAX_VALUE);
checkState(ranges.size() > 0, "No active range found");
return HashStreamRanges.ofHash(RangeKeyType.HASH, ranges);
}
use of org.apache.bookkeeper.stream.proto.storage.RelatedRanges in project bookkeeper by apache.
the class MetaRangeStoreImplTest method verifyGetResponse.
private void verifyGetResponse(GetActiveRangesResponse getResp) throws Exception {
MetaRangeImpl metaRange = new MetaRangeImpl(this.store, this.scheduler.chooseThread(), StorageContainerPlacementPolicyImpl.of(1024));
assertNotNull(FutureUtils.result(metaRange.load(streamProps.getStreamId())));
verifyStreamMetadata(metaRange, streamProps);
List<RelatedRanges> rangesList = getResp.getRangesList();
List<Long> currentRanges = metaRange.unsafeGetCurrentRanges();
assertEquals(currentRanges.size(), rangesList.size());
for (int i = 0; i < rangesList.size(); i++) {
RelatedRanges actualRR = rangesList.get(i);
long expectedRid = currentRanges.get(i);
RangeMetadata expectedRangeMetadata = metaRange.unsafeGetRanges().get(expectedRid);
assertNotNull(expectedRangeMetadata);
assertEquals(Collections.emptyList(), actualRR.getRelatedRangesList());
assertEquals(expectedRangeMetadata.getProps(), actualRR.getProps());
}
}
Aggregations