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();
}
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));
}
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);
}
Aggregations