use of org.tikv.kvproto.Kvrpcpb.BatchGetRequest 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);
}
use of org.tikv.kvproto.Kvrpcpb.BatchGetRequest 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;
}
}
}
Aggregations