Search in sources :

Example 1 with RelatedRanges

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);
}
Also used : RangeProperties(org.apache.bookkeeper.stream.proto.RangeProperties) RelatedRanges(org.apache.bookkeeper.stream.proto.storage.RelatedRanges)

Example 2 with RelatedRanges

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());
    }
}
Also used : MetaRangeImpl(org.apache.bookkeeper.stream.storage.impl.metadata.stream.MetaRangeImpl) RelatedRanges(org.apache.bookkeeper.stream.proto.storage.RelatedRanges) RangeMetadata(org.apache.bookkeeper.stream.proto.RangeMetadata)

Aggregations

RelatedRanges (org.apache.bookkeeper.stream.proto.storage.RelatedRanges)2 RangeMetadata (org.apache.bookkeeper.stream.proto.RangeMetadata)1 RangeProperties (org.apache.bookkeeper.stream.proto.RangeProperties)1 MetaRangeImpl (org.apache.bookkeeper.stream.storage.impl.metadata.stream.MetaRangeImpl)1