use of org.apache.bookkeeper.stream.proto.kv.rpc.IncrementRequest in project bookkeeper by apache.
the class TestKvUtils method testNewIncrementRequest.
@Test
public void testNewIncrementRequest() {
try (IncrementOption<ByteBuf> option = Options.incrementAndGet()) {
IncrementRequest rr = newIncrementRequest(key, 100L, option).build();
assertEquals(keyBs, rr.getKey());
assertEquals(100L, rr.getAmount());
assertTrue(rr.getGetTotal());
assertFalse(rr.hasHeader());
}
}
use of org.apache.bookkeeper.stream.proto.kv.rpc.IncrementRequest in project bookkeeper by apache.
the class StorageContainerImpl method incr.
@Override
public CompletableFuture<StorageContainerResponse> incr(StorageContainerRequest request) {
checkArgument(KV_INCR_REQ == request.getRequestCase());
long scId = request.getScId();
IncrementRequest ir = request.getKvIncrReq();
RoutingHeader header = ir.getHeader();
RangeId rid = RangeId.of(header.getStreamId(), header.getRangeId());
TableStore store = tableStoreCache.getTableStore(rid);
if (null != store) {
return store.incr(request);
} else {
return tableStoreCache.openTableStore(scId, rid).thenCompose(s -> s.incr(request));
}
}
Aggregations