Search in sources :

Example 1 with PutRequest

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

the class TestKvUtils method testNewPutRequest.

@Test
public void testNewPutRequest() {
    try (PutOption<ByteBuf> option = Options.putAndGet()) {
        PutRequest rr = newPutRequest(key, value, option).build();
        assertEquals(keyBs, rr.getKey());
        assertEquals(valueBs, rr.getValue());
        assertTrue(rr.getPrevKv());
        assertFalse(rr.hasHeader());
    }
}
Also used : KvUtils.newPutRequest(org.apache.bookkeeper.clients.impl.kv.KvUtils.newPutRequest) PutRequest(org.apache.bookkeeper.stream.proto.kv.rpc.PutRequest) KvUtils.newKvPutRequest(org.apache.bookkeeper.clients.impl.kv.KvUtils.newKvPutRequest) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with PutRequest

use of org.apache.bookkeeper.stream.proto.kv.rpc.PutRequest 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

PutRequest (org.apache.bookkeeper.stream.proto.kv.rpc.PutRequest)2 ByteBuf (io.netty.buffer.ByteBuf)1 KvUtils.newKvPutRequest (org.apache.bookkeeper.clients.impl.kv.KvUtils.newKvPutRequest)1 KvUtils.newPutRequest (org.apache.bookkeeper.clients.impl.kv.KvUtils.newPutRequest)1 RoutingHeader (org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader)1 RangeId (org.apache.bookkeeper.stream.protocol.RangeId)1 TableStore (org.apache.bookkeeper.stream.storage.api.kv.TableStore)1 Test (org.junit.Test)1