Search in sources :

Example 1 with BatchGetResponse

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

the class RegionStoreClient method batchGet.

public List<KvPair> batchGet(BackOffer backOffer, Iterable<ByteString> keys, long version) {
    boolean forWrite = false;
    Supplier<BatchGetRequest> request = () -> BatchGetRequest.newBuilder().setContext(makeContext(getResolvedLocks(version), this.storeType, backOffer.getSlowLog())).addAllKeys(keys).setVersion(version).build();
    KVErrorHandler<BatchGetResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> null, resolveLockResult -> addResolvedLocks(version, resolveLockResult.getResolvedLocks()), version, forWrite);
    BatchGetResponse resp = callWithRetry(backOffer, TikvGrpc.getKvBatchGetMethod(), request, handler);
    return handleBatchGetResponse(backOffer, resp, version);
}
Also used : RawBatchGetRequest(org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest) BatchGetRequest(org.tikv.kvproto.Kvrpcpb.BatchGetRequest) BatchGetResponse(org.tikv.kvproto.Kvrpcpb.BatchGetResponse) RawBatchGetResponse(org.tikv.kvproto.Kvrpcpb.RawBatchGetResponse) KVErrorHandler(org.tikv.common.operation.KVErrorHandler)

Example 2 with BatchGetResponse

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

the class RegionStoreClient method batchGet.

public List<KvPair> batchGet(BackOffer backOffer, List<ByteString> keys, long version) {
    boolean forWrite = false;
    Supplier<BatchGetRequest> request = () -> BatchGetRequest.newBuilder().setContext(region.getContext(getResolvedLocks(version))).addAllKeys(keys).setVersion(version).build();
    KVErrorHandler<BatchGetResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> null, resolveLockResult -> addResolvedLocks(version, resolveLockResult.getResolvedLocks()), version, forWrite);
    BatchGetResponse resp = callWithRetry(backOffer, TikvGrpc.getKvBatchGetMethod(), request, handler);
    try {
        return handleBatchGetResponse(backOffer, resp, version);
    } catch (TiKVException e) {
        if ("locks not resolved, retry".equals(e.getMessage())) {
            backOffer.doBackOff(BackOffFunction.BackOffFuncType.BoTxnLock, e);
            return batchGet(backOffer, keys, version);
        } else {
            throw e;
        }
    }
}
Also used : RawBatchGetRequest(org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest) BatchGetRequest(org.tikv.kvproto.Kvrpcpb.BatchGetRequest) RawBatchGetResponse(org.tikv.kvproto.Kvrpcpb.RawBatchGetResponse) BatchGetResponse(org.tikv.kvproto.Kvrpcpb.BatchGetResponse) TiKVException(com.pingcap.tikv.exception.TiKVException) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler)

Aggregations

BatchGetRequest (org.tikv.kvproto.Kvrpcpb.BatchGetRequest)2 BatchGetResponse (org.tikv.kvproto.Kvrpcpb.BatchGetResponse)2 RawBatchGetRequest (org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest)2 RawBatchGetResponse (org.tikv.kvproto.Kvrpcpb.RawBatchGetResponse)2 TiKVException (com.pingcap.tikv.exception.TiKVException)1 KVErrorHandler (com.pingcap.tikv.operation.KVErrorHandler)1 KVErrorHandler (org.tikv.common.operation.KVErrorHandler)1