use of com.pingcap.tikv.streaming.StreamingResponse 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.streaming.StreamingResponse in project tispark by pingcap.
the class AbstractGRPCClient method callServerStreamingWithRetry.
public <ReqT, RespT> StreamingResponse callServerStreamingWithRetry(BackOffer backOffer, MethodDescriptor<ReqT, RespT> method, Supplier<ReqT> requestFactory, ErrorHandler<StreamingResponse> handler) {
logger.debug(String.format("Calling %s...", method.getFullMethodName()));
RetryPolicy.Builder<StreamingResponse> builder = new Builder<>(backOffer);
StreamingResponse response = builder.create(handler).callWithRetry(() -> {
BlockingStubT stub = getBlockingStub();
return new StreamingResponse(blockingServerStreamingCall(stub.getChannel(), method, stub.getCallOptions(), requestFactory.get()));
}, method.getFullMethodName());
logger.debug(String.format("leaving %s...", method.getFullMethodName()));
return response;
}
Aggregations