use of com.pingcap.tikv.operation.KVErrorHandler in project tispark by pingcap.
the class RegionStoreClient method commit.
/**
* Commit batch keys
*
* @param backOffer backOffer
* @param keys keys to commit
* @param startTs start version
* @param commitTs commit version
*/
public void commit(BackOffer backOffer, Iterable<ByteString> keys, long startTs, long commitTs) throws KeyException {
boolean forWrite = true;
Supplier<CommitRequest> factory = () -> CommitRequest.newBuilder().setStartVersion(startTs).setCommitVersion(commitTs).addAllKeys(keys).setContext(region.getContext()).build();
KVErrorHandler<CommitResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> resp.hasError() ? resp.getError() : null, resolveLockResult -> null, startTs, forWrite);
CommitResponse resp = callWithRetry(backOffer, TikvGrpc.getKvCommitMethod(), factory, handler);
handleCommitResponse(resp);
}
use of com.pingcap.tikv.operation.KVErrorHandler in project tispark by pingcap.
the class RegionStoreClient method rawDelete.
public void rawDelete(BackOffer backOffer, ByteString key) {
Supplier<RawDeleteRequest> factory = () -> RawDeleteRequest.newBuilder().setContext(region.getContext()).setKey(key).build();
KVErrorHandler<RawDeleteResponse> handler = new KVErrorHandler<>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
RawDeleteResponse resp = callWithRetry(backOffer, TikvGrpc.getRawDeleteMethod(), factory, handler);
rawDeleteHelper(resp, region);
}
use of com.pingcap.tikv.operation.KVErrorHandler 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);
}
use of com.pingcap.tikv.operation.KVErrorHandler in project tispark by pingcap.
the class RegionStoreClient method coprocessStreaming.
// TODO: wait for future fix
// coprocessStreaming doesn't handle split error
// future work should handle it and do the resolve
// locks correspondingly
public Iterator<SelectResponse> coprocessStreaming(DAGRequest req, List<Coprocessor.KeyRange> ranges, long startTs) {
boolean forWrite = false;
Supplier<Coprocessor.Request> reqToSend = () -> Coprocessor.Request.newBuilder().setContext(region.getContext(getResolvedLocks(startTs))).setTp(REQ_TYPE_DAG.getValue()).setData(req.toByteString()).addAllRanges(ranges).build();
KVErrorHandler<StreamingResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, // TODO: handle all errors in streaming response
StreamingResponse::getFirstRegionError, resp -> null, resolveLockResult -> addResolvedLocks(startTs, resolveLockResult.getResolvedLocks()), startTs, forWrite);
StreamingResponse responseIterator = this.callServerStreamingWithRetry(ConcreteBackOffer.newCopNextMaxBackOff(), TikvGrpc.getCoprocessorStreamMethod(), reqToSend, handler);
return doCoprocessor(responseIterator);
}
use of com.pingcap.tikv.operation.KVErrorHandler in project tispark by pingcap.
the class RegionStoreClient method rawPutIfAbsent.
public ByteString rawPutIfAbsent(BackOffer backOffer, ByteString key, ByteString value, long ttl) {
Supplier<RawCASRequest> factory = () -> RawCASRequest.newBuilder().setContext(region.getContext()).setKey(key).setValue(value).setPreviousNotExist(true).setTtl(ttl).build();
KVErrorHandler<RawCASResponse> handler = new KVErrorHandler<>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
RawCASResponse resp = callWithRetry(backOffer, TikvGrpc.getRawCompareAndSwapMethod(), factory, handler);
return rawPutIfAbsentHelper(resp);
}
Aggregations