Search in sources :

Example 1 with RawBatchPutResponse

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

the class RegionStoreClient method rawBatchPut.

public void rawBatchPut(BackOffer backOffer, List<KvPair> kvPairs, long ttl, boolean atomic) {
    if (kvPairs.isEmpty()) {
        return;
    }
    Supplier<RawBatchPutRequest> factory = () -> RawBatchPutRequest.newBuilder().setContext(region.getContext()).addAllPairs(kvPairs).setTtl(ttl).setForCas(atomic).build();
    KVErrorHandler<RawBatchPutResponse> handler = new KVErrorHandler<>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
    RawBatchPutResponse resp = callWithRetry(backOffer, TikvGrpc.getRawBatchPutMethod(), factory, handler);
    handleRawBatchPut(resp);
}
Also used : RawBatchPutRequest(org.tikv.kvproto.Kvrpcpb.RawBatchPutRequest) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler) RawBatchPutResponse(org.tikv.kvproto.Kvrpcpb.RawBatchPutResponse)

Example 2 with RawBatchPutResponse

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

the class RegionStoreClient method rawBatchPut.

public void rawBatchPut(BackOffer backOffer, List<KvPair> kvPairs, long ttl, boolean atomicForCAS) {
    Long clusterId = pdClient.getClusterId();
    Histogram.Timer requestTimer = GRPC_RAW_REQUEST_LATENCY.labels("client_grpc_raw_batch_put", clusterId.toString()).startTimer();
    try {
        if (kvPairs.isEmpty()) {
            return;
        }
        Supplier<RawBatchPutRequest> factory = () -> RawBatchPutRequest.newBuilder().setContext(makeContext(storeType, backOffer.getSlowLog())).addAllPairs(kvPairs).setTtl(ttl).addTtls(ttl).setForCas(atomicForCAS).build();
        RegionErrorHandler<RawBatchPutResponse> handler = new RegionErrorHandler<RawBatchPutResponse>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
        RawBatchPutResponse resp = callWithRetry(backOffer, TikvGrpc.getRawBatchPutMethod(), factory, handler);
        handleRawBatchPut(resp);
    } finally {
        requestTimer.observeDuration();
    }
}
Also used : Histogram(io.prometheus.client.Histogram) RawBatchPutRequest(org.tikv.kvproto.Kvrpcpb.RawBatchPutRequest) RegionErrorHandler(org.tikv.common.operation.RegionErrorHandler) RawBatchPutResponse(org.tikv.kvproto.Kvrpcpb.RawBatchPutResponse)

Aggregations

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