Search in sources :

Example 1 with RawPutRequest

use of org.tikv.kvproto.Kvrpcpb.RawPutRequest in project tispark by pingcap.

the class RegionStoreClient method rawPut.

public void rawPut(BackOffer backOffer, ByteString key, ByteString value, long ttl) {
    Supplier<RawPutRequest> factory = () -> RawPutRequest.newBuilder().setContext(region.getContext()).setKey(key).setValue(value).setTtl(ttl).build();
    KVErrorHandler<RawPutResponse> handler = new KVErrorHandler<>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
    RawPutResponse resp = callWithRetry(backOffer, TikvGrpc.getRawPutMethod(), factory, handler);
    rawPutHelper(resp);
}
Also used : RawPutRequest(org.tikv.kvproto.Kvrpcpb.RawPutRequest) RawPutResponse(org.tikv.kvproto.Kvrpcpb.RawPutResponse) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler)

Example 2 with RawPutRequest

use of org.tikv.kvproto.Kvrpcpb.RawPutRequest in project client-java by tikv.

the class RegionStoreClient method rawPut.

public void rawPut(BackOffer backOffer, ByteString key, ByteString value, long ttl, boolean atomicForCAS) {
    Long clusterId = pdClient.getClusterId();
    Histogram.Timer requestTimer = GRPC_RAW_REQUEST_LATENCY.labels("client_grpc_raw_put", clusterId.toString()).startTimer();
    try {
        Supplier<RawPutRequest> factory = () -> RawPutRequest.newBuilder().setContext(makeContext(storeType, backOffer.getSlowLog())).setKey(key).setValue(value).setTtl(ttl).setForCas(atomicForCAS).build();
        RegionErrorHandler<RawPutResponse> handler = new RegionErrorHandler<RawPutResponse>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
        RawPutResponse resp = callWithRetry(backOffer, TikvGrpc.getRawPutMethod(), factory, handler);
        rawPutHelper(resp);
    } finally {
        requestTimer.observeDuration();
    }
}
Also used : Histogram(io.prometheus.client.Histogram) RawPutRequest(org.tikv.kvproto.Kvrpcpb.RawPutRequest) RawPutResponse(org.tikv.kvproto.Kvrpcpb.RawPutResponse) RegionErrorHandler(org.tikv.common.operation.RegionErrorHandler)

Aggregations

RawPutRequest (org.tikv.kvproto.Kvrpcpb.RawPutRequest)2 RawPutResponse (org.tikv.kvproto.Kvrpcpb.RawPutResponse)2 KVErrorHandler (com.pingcap.tikv.operation.KVErrorHandler)1 Histogram (io.prometheus.client.Histogram)1 RegionErrorHandler (org.tikv.common.operation.RegionErrorHandler)1