Search in sources :

Example 1 with RangeId

use of org.apache.bookkeeper.stream.protocol.RangeId 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));
    }
}
Also used : DeleteRangeRequest(org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest) 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 2 with RangeId

use of org.apache.bookkeeper.stream.protocol.RangeId in project bookkeeper by apache.

the class MVCCStoreFactoryImpl method addStore.

private synchronized void addStore(long scId, long streamId, long rangeId, MVCCAsyncStore<byte[], byte[]> store) {
    Map<RangeId, MVCCAsyncStore<byte[], byte[]>> scStores = stores.get(scId);
    if (null == scStores) {
        scStores = Maps.newHashMap();
    }
    RangeId rid = RangeId.of(streamId, rangeId);
    MVCCAsyncStore<byte[], byte[]> oldStore = scStores.get(rid);
    if (null != oldStore) {
        store.closeAsync();
    } else {
        log.info("Add store (scId = {}, streamId = {}, rangeId = {})", scId, streamId, rangeId);
        scStores.put(rid, store);
    }
}
Also used : MVCCAsyncStore(org.apache.bookkeeper.statelib.api.mvcc.MVCCAsyncStore) RangeId(org.apache.bookkeeper.stream.protocol.RangeId)

Example 3 with RangeId

use of org.apache.bookkeeper.stream.protocol.RangeId 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));
    }
}
Also used : RangeRequest(org.apache.bookkeeper.stream.proto.kv.rpc.RangeRequest) DeleteRangeRequest(org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest) 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 4 with RangeId

use of org.apache.bookkeeper.stream.protocol.RangeId 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));
    }
}
Also used : IncrementRequest(org.apache.bookkeeper.stream.proto.kv.rpc.IncrementRequest) 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 5 with RangeId

use of org.apache.bookkeeper.stream.protocol.RangeId 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)

Aggregations

RangeId (org.apache.bookkeeper.stream.protocol.RangeId)7 TableStore (org.apache.bookkeeper.stream.storage.api.kv.TableStore)6 RoutingHeader (org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader)5 DeleteRangeRequest (org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Maps (com.google.common.collect.Maps)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 FutureUtils (org.apache.bookkeeper.common.concurrent.FutureUtils)1 MVCCAsyncStore (org.apache.bookkeeper.statelib.api.mvcc.MVCCAsyncStore)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 TxnRequest (org.apache.bookkeeper.stream.proto.kv.rpc.TxnRequest)1 MVCCStoreFactory (org.apache.bookkeeper.stream.storage.impl.store.MVCCStoreFactory)1