Search in sources :

Example 11 with StorageContainerRequest

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

the class TestKvUtils method testNewKvRangeRequest.

@Test
public void testNewKvRangeRequest() {
    try (RangeOption<ByteBuf> rangeOption = optionFactory.newRangeOption().endKey(key.retainedDuplicate()).countOnly(true).keysOnly(true).limit(10).maxCreateRev(1234L).minCreateRev(234L).maxModRev(2345L).minModRev(1235L).build()) {
        RangeRequest.Builder rrBuilder = newRangeRequest(key, rangeOption);
        StorageContainerRequest request = newKvRangeRequest(scId, rrBuilder);
        assertEquals(scId, request.getScId());
        assertEquals(KV_RANGE_REQ, request.getRequestCase());
        assertEquals(rrBuilder.build(), request.getKvRangeReq());
    }
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) KvUtils.newKvRangeRequest(org.apache.bookkeeper.clients.impl.kv.KvUtils.newKvRangeRequest) RangeRequest(org.apache.bookkeeper.stream.proto.kv.rpc.RangeRequest) DeleteRangeRequest(org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest) KvUtils.newRangeRequest(org.apache.bookkeeper.clients.impl.kv.KvUtils.newRangeRequest) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 12 with StorageContainerRequest

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

the class TestGrpcTableService method testRangeActiveRangesException.

@Test
public void testRangeActiveRangesException() throws Exception {
    RangeStore rangeService = mock(RangeStore.class);
    GrpcTableService grpcService = new GrpcTableService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setKvRangeReq(RangeRequest.newBuilder().setKey(TEST_KEY).setHeader(ROUTING_HEADER)).build();
    when(rangeService.range(request)).thenReturn(FutureUtils.exception(new StatusRuntimeException(Status.NOT_FOUND)));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.range(request, responseObserver);
    responseObserver.verifyException(Status.NOT_FOUND);
    verify(rangeService, times(1)).range(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 13 with StorageContainerRequest

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

the class TestGrpcTableService method testPutFailure.

@Test
public void testPutFailure() throws Exception {
    RangeStore rangeService = mock(RangeStore.class);
    GrpcTableService grpcService = new GrpcTableService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setKvPutReq(PutRequest.newBuilder().setKey(TEST_KEY).setValue(TEST_VAL).setHeader(ROUTING_HEADER)).build();
    StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.INTERNAL_SERVER_ERROR).build();
    when(rangeService.put(request)).thenReturn(FutureUtils.exception(CAUSE));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.put(request, responseObserver);
    responseObserver.verifySuccess(response);
    verify(rangeService, times(1)).put(request);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) TestResponseObserver(org.apache.bookkeeper.stream.server.TestResponseObserver) RangeStore(org.apache.bookkeeper.stream.storage.api.RangeStore) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 14 with StorageContainerRequest

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

the class TestGrpcTableService method testPutSuccess.

// 
// Meta KeyRange Server Requests tests
// 
@Test
public void testPutSuccess() throws Exception {
    RangeStore rangeService = mock(RangeStore.class);
    GrpcTableService grpcService = new GrpcTableService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setKvPutReq(PutRequest.newBuilder().setKey(TEST_KEY).setValue(TEST_VAL).setHeader(ROUTING_HEADER)).build();
    StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.SUCCESS).setKvPutResp(PutResponse.newBuilder()).build();
    when(rangeService.put(request)).thenReturn(CompletableFuture.completedFuture(response));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.put(request, responseObserver);
    responseObserver.verifySuccess(response);
    verify(rangeService, times(1)).put(request);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) TestResponseObserver(org.apache.bookkeeper.stream.server.TestResponseObserver) RangeStore(org.apache.bookkeeper.stream.storage.api.RangeStore) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 15 with StorageContainerRequest

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

the class TestGrpcTableService method testRangeSuccess.

@Test
public void testRangeSuccess() throws Exception {
    RangeStore rangeService = mock(RangeStore.class);
    GrpcTableService grpcService = new GrpcTableService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setKvRangeReq(RangeRequest.newBuilder().setKey(TEST_KEY).setHeader(ROUTING_HEADER)).build();
    StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.SUCCESS).setKvRangeResp(RangeResponse.newBuilder()).build();
    when(rangeService.range(request)).thenReturn(CompletableFuture.completedFuture(response));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.range(request, responseObserver);
    responseObserver.verifySuccess(response);
    verify(rangeService, times(1)).range(request);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) TestResponseObserver(org.apache.bookkeeper.stream.server.TestResponseObserver) RangeStore(org.apache.bookkeeper.stream.storage.api.RangeStore) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) 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