Search in sources :

Example 1 with StreamingResponse

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);
}
Also used : StreamingResponse(com.pingcap.tikv.streaming.StreamingResponse) RawPutRequest(org.tikv.kvproto.Kvrpcpb.RawPutRequest) ScanRequest(org.tikv.kvproto.Kvrpcpb.ScanRequest) RawScanRequest(org.tikv.kvproto.Kvrpcpb.RawScanRequest) RawBatchGetRequest(org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest) RawGetKeyTTLRequest(org.tikv.kvproto.Kvrpcpb.RawGetKeyTTLRequest) RawDeleteRangeRequest(org.tikv.kvproto.Kvrpcpb.RawDeleteRangeRequest) RawDeleteRequest(org.tikv.kvproto.Kvrpcpb.RawDeleteRequest) GetRequest(org.tikv.kvproto.Kvrpcpb.GetRequest) RawBatchDeleteRequest(org.tikv.kvproto.Kvrpcpb.RawBatchDeleteRequest) TxnHeartBeatRequest(org.tikv.kvproto.Kvrpcpb.TxnHeartBeatRequest) RawGetRequest(org.tikv.kvproto.Kvrpcpb.RawGetRequest) RawCASRequest(org.tikv.kvproto.Kvrpcpb.RawCASRequest) PrewriteRequest(org.tikv.kvproto.Kvrpcpb.PrewriteRequest) CommitRequest(org.tikv.kvproto.Kvrpcpb.CommitRequest) BatchGetRequest(org.tikv.kvproto.Kvrpcpb.BatchGetRequest) DAGRequest(com.pingcap.tidb.tipb.DAGRequest) RawBatchPutRequest(org.tikv.kvproto.Kvrpcpb.RawBatchPutRequest) SplitRegionRequest(org.tikv.kvproto.Kvrpcpb.SplitRegionRequest) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler)

Example 2 with StreamingResponse

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;
}
Also used : StreamingResponse(com.pingcap.tikv.streaming.StreamingResponse) Builder(com.pingcap.tikv.policy.RetryMaxMs.Builder) RetryPolicy(com.pingcap.tikv.policy.RetryPolicy)

Aggregations

StreamingResponse (com.pingcap.tikv.streaming.StreamingResponse)2 DAGRequest (com.pingcap.tidb.tipb.DAGRequest)1 KVErrorHandler (com.pingcap.tikv.operation.KVErrorHandler)1 Builder (com.pingcap.tikv.policy.RetryMaxMs.Builder)1 RetryPolicy (com.pingcap.tikv.policy.RetryPolicy)1 BatchGetRequest (org.tikv.kvproto.Kvrpcpb.BatchGetRequest)1 CommitRequest (org.tikv.kvproto.Kvrpcpb.CommitRequest)1 GetRequest (org.tikv.kvproto.Kvrpcpb.GetRequest)1 PrewriteRequest (org.tikv.kvproto.Kvrpcpb.PrewriteRequest)1 RawBatchDeleteRequest (org.tikv.kvproto.Kvrpcpb.RawBatchDeleteRequest)1 RawBatchGetRequest (org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest)1 RawBatchPutRequest (org.tikv.kvproto.Kvrpcpb.RawBatchPutRequest)1 RawCASRequest (org.tikv.kvproto.Kvrpcpb.RawCASRequest)1 RawDeleteRangeRequest (org.tikv.kvproto.Kvrpcpb.RawDeleteRangeRequest)1 RawDeleteRequest (org.tikv.kvproto.Kvrpcpb.RawDeleteRequest)1 RawGetKeyTTLRequest (org.tikv.kvproto.Kvrpcpb.RawGetKeyTTLRequest)1 RawGetRequest (org.tikv.kvproto.Kvrpcpb.RawGetRequest)1 RawPutRequest (org.tikv.kvproto.Kvrpcpb.RawPutRequest)1 RawScanRequest (org.tikv.kvproto.Kvrpcpb.RawScanRequest)1 ScanRequest (org.tikv.kvproto.Kvrpcpb.ScanRequest)1