Search in sources :

Example 1 with TxnHeartBeatResponse

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

the class RegionStoreClient method txnHeartBeat.

/**
 * TXN Heart Beat: update primary key ttl
 */
public void txnHeartBeat(BackOffer bo, ByteString primaryLock, long startTs, long ttl) {
    boolean forWrite = false;
    while (true) {
        Supplier<TxnHeartBeatRequest> factory = () -> TxnHeartBeatRequest.newBuilder().setContext(makeContext(storeType, bo.getSlowLog())).setStartVersion(startTs).setPrimaryLock(primaryLock).setAdviseLockTtl(ttl).build();
        KVErrorHandler<TxnHeartBeatResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> resp.hasError() ? resp.getError() : null, resolveLockResult -> null, startTs, forWrite);
        TxnHeartBeatResponse resp = callWithRetry(bo, TikvGrpc.getKvTxnHeartBeatMethod(), factory, handler);
        if (isTxnHeartBeatSuccess(resp)) {
            return;
        }
    }
}
Also used : TxnHeartBeatRequest(org.tikv.kvproto.Kvrpcpb.TxnHeartBeatRequest) TxnHeartBeatResponse(org.tikv.kvproto.Kvrpcpb.TxnHeartBeatResponse) KVErrorHandler(org.tikv.common.operation.KVErrorHandler)

Example 2 with TxnHeartBeatResponse

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

the class RegionStoreClient method txnHeartBeat.

/**
 * TXN Heart Beat: update primary key ttl
 */
public void txnHeartBeat(BackOffer bo, ByteString primaryLock, long startTs, long ttl) {
    boolean forWrite = false;
    while (true) {
        Supplier<TxnHeartBeatRequest> factory = () -> TxnHeartBeatRequest.newBuilder().setContext(region.getContext()).setStartVersion(startTs).setPrimaryLock(primaryLock).setAdviseLockTtl(ttl).build();
        KVErrorHandler<TxnHeartBeatResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> resp.hasError() ? resp.getError() : null, resolveLockResult -> null, startTs, forWrite);
        TxnHeartBeatResponse resp = callWithRetry(bo, TikvGrpc.getKvTxnHeartBeatMethod(), factory, handler);
        if (isTxnHeartBeatSuccess(resp)) {
            return;
        }
    }
}
Also used : TxnHeartBeatRequest(org.tikv.kvproto.Kvrpcpb.TxnHeartBeatRequest) TxnHeartBeatResponse(org.tikv.kvproto.Kvrpcpb.TxnHeartBeatResponse) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler)

Aggregations

TxnHeartBeatRequest (org.tikv.kvproto.Kvrpcpb.TxnHeartBeatRequest)2 TxnHeartBeatResponse (org.tikv.kvproto.Kvrpcpb.TxnHeartBeatResponse)2 KVErrorHandler (com.pingcap.tikv.operation.KVErrorHandler)1 KVErrorHandler (org.tikv.common.operation.KVErrorHandler)1