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