Search in sources :

Example 21 with StorageContainerRequest

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

the class TestGrpcMetaRangeService method testGetActiveRangesFailure.

@Test
public void testGetActiveRangesFailure() throws Exception {
    RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
    GrpcMetaRangeService grpcService = new GrpcMetaRangeService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setGetActiveRangesReq(GetActiveRangesRequest.newBuilder().setStreamId(23456L).build()).build();
    StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.INTERNAL_SERVER_ERROR).build();
    when(rangeService.getActiveRanges(request)).thenReturn(FutureUtils.exception(CAUSE));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.getActiveRanges(request, responseObserver);
    responseObserver.verifySuccess(response);
    verify(rangeService, times(1)).getActiveRanges(request);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) TestResponseObserver(org.apache.bookkeeper.stream.server.TestResponseObserver) RangeStoreImpl(org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 22 with StorageContainerRequest

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

the class TestGrpcMetaRangeService method testGetActiveRangesSuccess.

// 
// Meta KeyRange Server Requests tests
// 
@Test
public void testGetActiveRangesSuccess() throws Exception {
    RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
    GrpcMetaRangeService grpcService = new GrpcMetaRangeService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setGetActiveRangesReq(GetActiveRangesRequest.newBuilder().setStreamId(23456L).build()).build();
    StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.SUCCESS).setGetActiveRangesResp(GetActiveRangesResponse.newBuilder()).build();
    when(rangeService.getActiveRanges(request)).thenReturn(CompletableFuture.completedFuture(response));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.getActiveRanges(request, responseObserver);
    responseObserver.verifySuccess(response);
    verify(rangeService, times(1)).getActiveRanges(request);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) TestResponseObserver(org.apache.bookkeeper.stream.server.TestResponseObserver) RangeStoreImpl(org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 23 with StorageContainerRequest

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

the class TestGrpcTableService method testDeleteException.

@Test
public void testDeleteException() throws Exception {
    RangeStore rangeService = mock(RangeStore.class);
    GrpcTableService grpcService = new GrpcTableService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setKvDeleteReq(DeleteRangeRequest.newBuilder().setKey(TEST_KEY).setHeader(ROUTING_HEADER)).build();
    when(rangeService.delete(request)).thenReturn(FutureUtils.exception(new StatusRuntimeException(Status.NOT_FOUND)));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.delete(request, responseObserver);
    responseObserver.verifyException(Status.NOT_FOUND);
    verify(rangeService, times(1)).delete(request);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) TestResponseObserver(org.apache.bookkeeper.stream.server.TestResponseObserver) StatusRuntimeException(io.grpc.StatusRuntimeException) RangeStore(org.apache.bookkeeper.stream.storage.api.RangeStore) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 24 with StorageContainerRequest

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

the class TestKvUtils method testNewKvIncrementRequest.

@Test
public void testNewKvIncrementRequest() {
    try (IncrementOption<ByteBuf> option = Options.incrementAndGet()) {
        IncrementRequest.Builder incrBuilder = newIncrementRequest(key, 100L, option);
        StorageContainerRequest request = newKvIncrementRequest(scId, incrBuilder);
        assertEquals(scId, request.getScId());
        assertEquals(KV_INCR_REQ, request.getRequestCase());
        assertEquals(incrBuilder.build(), request.getKvIncrReq());
    }
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) KvUtils.newIncrementRequest(org.apache.bookkeeper.clients.impl.kv.KvUtils.newIncrementRequest) KvUtils.newKvIncrementRequest(org.apache.bookkeeper.clients.impl.kv.KvUtils.newKvIncrementRequest) IncrementRequest(org.apache.bookkeeper.stream.proto.kv.rpc.IncrementRequest) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 25 with StorageContainerRequest

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

the class TestKvUtils method testNewKvPutRequest.

@Test
public void testNewKvPutRequest() {
    try (PutOption<ByteBuf> option = Options.putAndGet()) {
        PutRequest.Builder putBuilder = newPutRequest(key, value, option);
        StorageContainerRequest request = newKvPutRequest(scId, putBuilder);
        assertEquals(scId, request.getScId());
        assertEquals(KV_PUT_REQ, request.getRequestCase());
        assertEquals(putBuilder.build(), request.getKvPutReq());
    }
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) KvUtils.newPutRequest(org.apache.bookkeeper.clients.impl.kv.KvUtils.newPutRequest) PutRequest(org.apache.bookkeeper.stream.proto.kv.rpc.PutRequest) KvUtils.newKvPutRequest(org.apache.bookkeeper.clients.impl.kv.KvUtils.newKvPutRequest) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

StorageContainerRequest (org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest)33 Test (org.junit.Test)31 StorageContainerResponse (org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)27 TestResponseObserver (org.apache.bookkeeper.stream.server.TestResponseObserver)12 RangeStore (org.apache.bookkeeper.stream.storage.api.RangeStore)9 StatusRuntimeException (io.grpc.StatusRuntimeException)5 ByteBuf (io.netty.buffer.ByteBuf)4 StorageContainer (org.apache.bookkeeper.stream.storage.api.sc.StorageContainer)4 StreamObserver (io.grpc.stub.StreamObserver)3 StorageServerChannel (org.apache.bookkeeper.clients.impl.channel.StorageServerChannel)3 RangeStoreImpl (org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl)3 HashStreamRanges (org.apache.bookkeeper.clients.impl.internal.api.HashStreamRanges)2 DeleteRangeRequest (org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest)2 MetaRangeServiceImplBase (org.apache.bookkeeper.stream.proto.storage.MetaRangeServiceGrpc.MetaRangeServiceImplBase)2 ExecutionException (java.util.concurrent.ExecutionException)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Cleanup (lombok.Cleanup)1 StorageContainerChannel (org.apache.bookkeeper.clients.impl.container.StorageContainerChannel)1 KvUtils.newIncrementRequest (org.apache.bookkeeper.clients.impl.kv.KvUtils.newIncrementRequest)1