Search in sources :

Example 31 with StorageContainerRequest

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

the class StorageContainerImplTest method newStorageContainerRequest.

// 
// Table API
// 
private StorageContainerRequest newStorageContainerRequest(RequestCase type) {
    StorageContainerRequest.Builder reqBuilder = StorageContainerRequest.newBuilder().setScId(SCID);
    RoutingHeader header = RoutingHeader.newBuilder().setStreamId(STREAM_ID).setRangeId(RANGE_ID).build();
    switch(type) {
        case KV_PUT_REQ:
            reqBuilder = reqBuilder.setKvPutReq(PutRequest.newBuilder().setHeader(header));
            break;
        case KV_DELETE_REQ:
            reqBuilder = reqBuilder.setKvDeleteReq(DeleteRangeRequest.newBuilder().setHeader(header));
            break;
        case KV_RANGE_REQ:
            reqBuilder = reqBuilder.setKvRangeReq(RangeRequest.newBuilder().setHeader(header));
            break;
        case KV_TXN_REQ:
            reqBuilder = reqBuilder.setKvTxnReq(TxnRequest.newBuilder().setHeader(header));
            break;
        case KV_INCR_REQ:
            reqBuilder = reqBuilder.setKvIncrReq(IncrementRequest.newBuilder().setHeader(header));
            break;
        default:
            break;
    }
    return reqBuilder.build();
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) RoutingHeader(org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader)

Example 32 with StorageContainerRequest

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

the class StorageContainerImplTest method testPutWhenTableStoreNotCached.

@Test
public void testPutWhenTableStoreNotCached() throws Exception {
    mockStorageContainer(SCID);
    StorageContainerResponse expectedResp = StorageContainerResponse.getDefaultInstance();
    when(trStore.put(any(StorageContainerRequest.class))).thenReturn(FutureUtils.value(expectedResp));
    StorageContainerRequest request = newStorageContainerRequest(KV_PUT_REQ);
    StorageContainerResponse response = FutureUtils.result(container.put(request));
    assertSame(expectedResp, response);
    assertSame(trStore, container.getTableStoreCache().getTableStore(RID));
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 33 with StorageContainerRequest

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

the class StorageContainerImplTest method testDeleteWhenTableStoreCached.

@Test
public void testDeleteWhenTableStoreCached() throws Exception {
    mockStorageContainer(SCID);
    StorageContainerResponse expectedResp = StorageContainerResponse.getDefaultInstance();
    when(trStore.delete(any(StorageContainerRequest.class))).thenReturn(FutureUtils.value(expectedResp));
    container.getTableStoreCache().getTableStores().put(RID, trStore);
    StorageContainerRequest request = newStorageContainerRequest(KV_DELETE_REQ);
    StorageContainerResponse response = FutureUtils.result(container.delete(request));
    assertSame(expectedResp, response);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) 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