Search in sources :

Example 6 with GetStreamRequest

use of org.apache.bookkeeper.stream.proto.storage.GetStreamRequest in project bookkeeper by apache.

the class TestStorageServerClientManagerImpl method testGetMetaRangeClientByStreamId.

@Test
public void testGetMetaRangeClientByStreamId() throws Exception {
    long streamId = 3456L;
    StreamProperties props = StreamProperties.newBuilder().setStorageContainerId(1234L).setStreamId(streamId).setStreamName("metaclient-stream").setStreamConf(StreamConfiguration.newBuilder().build()).build();
    RootRangeServiceImplBase rootRangeService = new RootRangeServiceImplBase() {

        @Override
        public void getStream(GetStreamRequest request, StreamObserver<GetStreamResponse> responseObserver) {
            responseObserver.onNext(GetStreamResponse.newBuilder().setCode(StatusCode.SUCCESS).setStreamProps(props).build());
            responseObserver.onCompleted();
        }
    };
    serviceRegistry.addService(rootRangeService.bindService());
    // the stream properties will be cached here
    assertEquals(props, FutureUtils.result(serverManager.getStreamProperties(streamId)));
    // the metadata range client is cached as well
    MetaRangeClient client = FutureUtils.result(serverManager.openMetaRangeClient(streamId));
    assertEquals(props, client.getStreamProps());
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) MetaRangeClient(org.apache.bookkeeper.clients.impl.internal.api.MetaRangeClient) StreamProperties(org.apache.bookkeeper.stream.proto.StreamProperties) GetStreamRequest(org.apache.bookkeeper.stream.proto.storage.GetStreamRequest) RootRangeServiceImplBase(org.apache.bookkeeper.stream.proto.storage.RootRangeServiceGrpc.RootRangeServiceImplBase) Test(org.junit.Test)

Aggregations

GetStreamRequest (org.apache.bookkeeper.stream.proto.storage.GetStreamRequest)6 GetStreamResponse (org.apache.bookkeeper.stream.proto.storage.GetStreamResponse)5 Test (org.junit.Test)5 StreamObserver (io.grpc.stub.StreamObserver)3 ProtoUtils.createGetStreamRequest (org.apache.bookkeeper.stream.protocol.util.ProtoUtils.createGetStreamRequest)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 StreamProperties (org.apache.bookkeeper.stream.proto.StreamProperties)2 RangeStoreImpl (org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl)2 UTF_8 (com.google.common.base.Charsets.UTF_8)1 ByteString (com.google.protobuf.ByteString)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 URI (java.net.URI)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Slf4j (lombok.extern.slf4j.Slf4j)1 CompareResult (org.apache.bookkeeper.api.kv.op.CompareResult)1 RangeOp (org.apache.bookkeeper.api.kv.op.RangeOp)1 TxnOp (org.apache.bookkeeper.api.kv.op.TxnOp)1 Options (org.apache.bookkeeper.api.kv.options.Options)1