use of org.apache.bookkeeper.stream.storage.impl.metadata.stream.MetaRangeImpl 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());
}
}
use of org.apache.bookkeeper.stream.storage.impl.metadata.stream.MetaRangeImpl in project bookkeeper by apache.
the class MetaRangeStoreImpl method getActiveRanges.
@Override
public CompletableFuture<StorageContainerResponse> getActiveRanges(StorageContainerRequest request) {
checkState(GET_ACTIVE_RANGES_REQ == request.getRequestCase(), "Wrong request type: %s", request.getRequestCase());
final long streamId = request.getGetActiveRangesReq().getStreamId();
MetaRangeImpl metaRange = streams.get(streamId);
if (null == metaRange) {
final MetaRangeImpl metaRangeImpl = new MetaRangeImpl(store, executor, rangePlacementPolicy);
return metaRangeImpl.load(streamId).thenCompose(mr -> {
if (null == mr) {
StreamProperties streamProps = request.getGetActiveRangesReq().hasStreamProps() ? request.getGetActiveRangesReq().getStreamProps() : null;
return createStreamIfMissing(streamId, metaRangeImpl, streamProps);
} else {
synchronized (streams) {
streams.put(streamId, (MetaRangeImpl) mr);
}
return getActiveRanges(mr);
}
});
} else {
return getActiveRanges(metaRange);
}
}
Aggregations