Search in sources :

Example 1 with RootRangeServiceImplBase

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

the class RootRangeClientImplTestBase method testRequestFailure.

@Test
public void testRequestFailure() throws Exception {
    CompletableFuture<StorageServerChannel> serviceFuture = FutureUtils.createFuture();
    rootRangeClient.getStorageContainerClient().setStorageServerChannelFuture(serviceFuture);
    RootRangeServiceImplBase rootRangeService = createRootRangeServiceForRequestFailure();
    serviceRegistry.addService(rootRangeService.bindService());
    StorageServerChannel rsChannel = new StorageServerChannel(InProcessChannelBuilder.forName(serverName).directExecutor().build(), Optional.empty());
    serviceFuture.complete(rsChannel);
    verifyRequestFailure(rootRangeClient);
}
Also used : StorageServerChannel(org.apache.bookkeeper.clients.impl.channel.StorageServerChannel) RootRangeServiceImplBase(org.apache.bookkeeper.stream.proto.storage.RootRangeServiceGrpc.RootRangeServiceImplBase) Test(org.junit.Test)

Example 2 with RootRangeServiceImplBase

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

the class RootRangeClientImplTestBase method testRequestSuccess.

@Test
public void testRequestSuccess() throws Exception {
    CompletableFuture<StorageServerChannel> serviceFuture = FutureUtils.createFuture();
    rootRangeClient.getStorageContainerClient().setStorageServerChannelFuture(serviceFuture);
    RootRangeServiceImplBase rootRangeService = createRootRangeServiceForSuccess();
    serviceRegistry.addService(rootRangeService.bindService());
    StorageServerChannel rsChannel = new StorageServerChannel(InProcessChannelBuilder.forName(serverName).directExecutor().build(), Optional.empty());
    serviceFuture.complete(rsChannel);
    verifySuccess(rootRangeClient);
}
Also used : StorageServerChannel(org.apache.bookkeeper.clients.impl.channel.StorageServerChannel) RootRangeServiceImplBase(org.apache.bookkeeper.stream.proto.storage.RootRangeServiceGrpc.RootRangeServiceImplBase) Test(org.junit.Test)

Example 3 with RootRangeServiceImplBase

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

the class RootRangeClientImplTestBase method testRpcFailure.

@Test
public void testRpcFailure() throws Exception {
    CompletableFuture<StorageServerChannel> serviceFuture = FutureUtils.createFuture();
    rootRangeClient.getStorageContainerClient().setStorageServerChannelFuture(serviceFuture);
    RootRangeServiceImplBase rootRangeService = createRootRangeServiceForRpcFailure();
    serviceRegistry.addService(rootRangeService.bindService());
    StorageServerChannel rsChannel = new StorageServerChannel(InProcessChannelBuilder.forName(serverName).directExecutor().build(), Optional.empty());
    serviceFuture.complete(rsChannel);
    verifyRpcFailure(rootRangeClient);
}
Also used : StorageServerChannel(org.apache.bookkeeper.clients.impl.channel.StorageServerChannel) RootRangeServiceImplBase(org.apache.bookkeeper.stream.proto.storage.RootRangeServiceGrpc.RootRangeServiceImplBase) Test(org.junit.Test)

Example 4 with RootRangeServiceImplBase

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

RootRangeServiceImplBase (org.apache.bookkeeper.stream.proto.storage.RootRangeServiceGrpc.RootRangeServiceImplBase)4 Test (org.junit.Test)4 StorageServerChannel (org.apache.bookkeeper.clients.impl.channel.StorageServerChannel)3 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