use of org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader in project bookkeeper by apache.
the class StorageContainerImpl method delete.
@Override
public CompletableFuture<StorageContainerResponse> delete(StorageContainerRequest request) {
checkArgument(KV_DELETE_REQ == request.getRequestCase());
long scId = request.getScId();
DeleteRangeRequest rr = request.getKvDeleteReq();
RoutingHeader header = rr.getHeader();
RangeId rid = RangeId.of(header.getStreamId(), header.getRangeId());
TableStore store = tableStoreCache.getTableStore(rid);
if (null != store) {
return store.delete(request);
} else {
return tableStoreCache.openTableStore(scId, rid).thenCompose(s -> s.delete(request));
}
}
use of org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader in project bookkeeper by apache.
the class TableStoreImpl method buildTxnOp.
private TxnOp<byte[], byte[]> buildTxnOp(TxnRequest request) {
RoutingHeader header = request.getHeader();
TxnOpBuilder<byte[], byte[]> txnBuilder = store.getOpFactory().newTxn();
for (RequestOp requestOp : request.getSuccessList()) {
txnBuilder.Then(buildTxnOp(header, requestOp));
}
for (RequestOp requestOp : request.getFailureList()) {
txnBuilder.Else(buildTxnOp(header, requestOp));
}
for (Compare compare : request.getCompareList()) {
txnBuilder.If(fromProtoCompare(store.getOpFactory(), header, compare));
}
return txnBuilder.build();
}
use of org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader 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.kv.rpc.RoutingHeader in project bookkeeper by apache.
the class StorageContainerImpl method range.
//
// Table API
//
@Override
public CompletableFuture<StorageContainerResponse> range(StorageContainerRequest request) {
checkArgument(KV_RANGE_REQ == request.getRequestCase());
long scId = request.getScId();
RangeRequest rr = request.getKvRangeReq();
RoutingHeader header = rr.getHeader();
RangeId rid = RangeId.of(header.getStreamId(), header.getRangeId());
TableStore store = tableStoreCache.getTableStore(rid);
if (null != store) {
return store.range(request);
} else {
return tableStoreCache.openTableStore(scId, rid).thenCompose(s -> s.range(request));
}
}
use of org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader 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