use of org.apache.bookkeeper.stream.proto.StreamProperties 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