Search in sources :

Example 6 with RoutingHeader

use of org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader in project bookkeeper by apache.

the class StorageContainerImpl method put.

@Override
public CompletableFuture<StorageContainerResponse> put(StorageContainerRequest request) {
    checkArgument(KV_PUT_REQ == request.getRequestCase());
    long scId = request.getScId();
    PutRequest rr = request.getKvPutReq();
    RoutingHeader header = rr.getHeader();
    RangeId rid = RangeId.of(header.getStreamId(), header.getRangeId());
    TableStore store = tableStoreCache.getTableStore(rid);
    if (null != store) {
        return store.put(request);
    } else {
        return tableStoreCache.openTableStore(scId, rid).thenCompose(s -> s.put(request));
    }
}
Also used : PutRequest(org.apache.bookkeeper.stream.proto.kv.rpc.PutRequest) RoutingHeader(org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader) RangeId(org.apache.bookkeeper.stream.protocol.RangeId) TableStore(org.apache.bookkeeper.stream.storage.api.kv.TableStore)

Example 7 with RoutingHeader

use of org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader in project bookkeeper by apache.

the class StorageContainerImpl method txn.

@Override
public CompletableFuture<StorageContainerResponse> txn(StorageContainerRequest request) {
    checkArgument(KV_TXN_REQ == request.getRequestCase());
    long scId = request.getScId();
    TxnRequest rr = request.getKvTxnReq();
    RoutingHeader header = rr.getHeader();
    RangeId rid = RangeId.of(header.getStreamId(), header.getRangeId());
    TableStore store = tableStoreCache.getTableStore(rid);
    if (null != store) {
        return store.txn(request);
    } else {
        return tableStoreCache.openTableStore(scId, rid).thenCompose(s -> s.txn(request));
    }
}
Also used : TxnRequest(org.apache.bookkeeper.stream.proto.kv.rpc.TxnRequest) RoutingHeader(org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader) RangeId(org.apache.bookkeeper.stream.protocol.RangeId) TableStore(org.apache.bookkeeper.stream.storage.api.kv.TableStore)

Aggregations

RoutingHeader (org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader)7 RangeId (org.apache.bookkeeper.stream.protocol.RangeId)5 TableStore (org.apache.bookkeeper.stream.storage.api.kv.TableStore)5 DeleteRangeRequest (org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest)2 Compare (org.apache.bookkeeper.stream.proto.kv.rpc.Compare)1 IncrementRequest (org.apache.bookkeeper.stream.proto.kv.rpc.IncrementRequest)1 PutRequest (org.apache.bookkeeper.stream.proto.kv.rpc.PutRequest)1 RangeRequest (org.apache.bookkeeper.stream.proto.kv.rpc.RangeRequest)1 RequestOp (org.apache.bookkeeper.stream.proto.kv.rpc.RequestOp)1 TxnRequest (org.apache.bookkeeper.stream.proto.kv.rpc.TxnRequest)1 StorageContainerRequest (org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest)1 TableStoreUtils.fromProtoCompare (org.apache.bookkeeper.stream.storage.impl.kv.TableStoreUtils.fromProtoCompare)1