Search in sources :

Example 11 with StreamProperties

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

Aggregations

StreamProperties (org.apache.bookkeeper.stream.proto.StreamProperties)11 Test (org.junit.Test)7 StreamConfiguration (org.apache.bookkeeper.stream.proto.StreamConfiguration)5 NamespaceProperties (org.apache.bookkeeper.stream.proto.NamespaceProperties)4 KeyValue (org.apache.bookkeeper.api.kv.result.KeyValue)3 NamespaceConfiguration (org.apache.bookkeeper.stream.proto.NamespaceConfiguration)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 ByteBuf (io.netty.buffer.ByteBuf)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Slf4j (lombok.extern.slf4j.Slf4j)2 CompareResult (org.apache.bookkeeper.api.kv.op.CompareResult)2 TxnOp (org.apache.bookkeeper.api.kv.op.TxnOp)2 FutureUtils (org.apache.bookkeeper.common.concurrent.FutureUtils)2 Bytes (org.apache.bookkeeper.common.util.Bytes)2 MVCCAsyncStore (org.apache.bookkeeper.statelib.api.mvcc.MVCCAsyncStore)2 Endpoint (org.apache.bookkeeper.stream.proto.common.Endpoint)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 UTF_8 (com.google.common.base.Charsets.UTF_8)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1