Search in sources :

Example 1 with MetaRangeClient

use of org.apache.bookkeeper.clients.impl.internal.api.MetaRangeClient 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

StreamObserver (io.grpc.stub.StreamObserver)1 MetaRangeClient (org.apache.bookkeeper.clients.impl.internal.api.MetaRangeClient)1 StreamProperties (org.apache.bookkeeper.stream.proto.StreamProperties)1 GetStreamRequest (org.apache.bookkeeper.stream.proto.storage.GetStreamRequest)1 RootRangeServiceImplBase (org.apache.bookkeeper.stream.proto.storage.RootRangeServiceGrpc.RootRangeServiceImplBase)1 Test (org.junit.Test)1