Search in sources :

Example 1 with RawGetRequest

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

the class RegionStoreClient method rawGet.

// APIs for Raw Scan/Put/Get/Delete
public Optional<ByteString> rawGet(BackOffer backOffer, ByteString key) {
    Long clusterId = pdClient.getClusterId();
    Histogram.Timer requestTimer = GRPC_RAW_REQUEST_LATENCY.labels("client_grpc_raw_get", clusterId.toString()).startTimer();
    try {
        Supplier<RawGetRequest> factory = () -> RawGetRequest.newBuilder().setContext(makeContext(storeType, backOffer.getSlowLog())).setKey(key).build();
        RegionErrorHandler<RawGetResponse> handler = new RegionErrorHandler<RawGetResponse>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
        RawGetResponse resp = callWithRetry(backOffer, TikvGrpc.getRawGetMethod(), factory, handler);
        return rawGetHelper(resp);
    } finally {
        requestTimer.observeDuration();
    }
}
Also used : RawGetResponse(org.tikv.kvproto.Kvrpcpb.RawGetResponse) Histogram(io.prometheus.client.Histogram) RawGetRequest(org.tikv.kvproto.Kvrpcpb.RawGetRequest) RegionErrorHandler(org.tikv.common.operation.RegionErrorHandler)

Example 2 with RawGetRequest

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

the class RegionStoreClient method rawGet.

// APIs for Raw Scan/Put/Get/Delete
public ByteString rawGet(BackOffer backOffer, ByteString key) {
    Supplier<RawGetRequest> factory = () -> RawGetRequest.newBuilder().setContext(region.getContext()).setKey(key).build();
    KVErrorHandler<RawGetResponse> handler = new KVErrorHandler<>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
    RawGetResponse resp = callWithRetry(backOffer, TikvGrpc.getRawGetMethod(), factory, handler);
    return rawGetHelper(resp);
}
Also used : RawGetResponse(org.tikv.kvproto.Kvrpcpb.RawGetResponse) RawGetRequest(org.tikv.kvproto.Kvrpcpb.RawGetRequest) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler)

Aggregations

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