use of org.tikv.kvproto.Kvrpcpb.PrewriteResponse in project tispark by pingcap.
the class RegionStoreClient method prewrite.
/**
* Prewrite batch keys
*
* @param skipConstraintCheck whether to skip constraint check
*/
public void prewrite(BackOffer bo, ByteString primaryLock, Iterable<Mutation> mutations, long startTs, long ttl, boolean skipConstraintCheck, boolean useAsyncCommit, Iterable<ByteString> secondaries) throws TiClientInternalException, KeyException, RegionException {
boolean forWrite = true;
while (true) {
Supplier<PrewriteRequest> factory = () -> {
PrewriteRequest.Builder builder = PrewriteRequest.newBuilder().setContext(region.getContext()).setStartVersion(startTs).setPrimaryLock(primaryLock).addAllMutations(mutations).setLockTtl(ttl).setSkipConstraintCheck(skipConstraintCheck).setTxnSize(16);
if (getIsV4()) {
builder.setMinCommitTs(startTs);
}
if (useAsyncCommit) {
builder.setUseAsyncCommit(true);
if (secondaries != null) {
builder.addAllSecondaries(secondaries);
}
}
return builder.build();
};
KVErrorHandler<PrewriteResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> null, resolveLockResult -> null, startTs, forWrite);
PrewriteResponse resp = callWithRetry(bo, TikvGrpc.getKvPrewriteMethod(), factory, handler);
if (isPrewriteSuccess(bo, resp, startTs)) {
return;
}
}
}
use of org.tikv.kvproto.Kvrpcpb.PrewriteResponse in project client-java by tikv.
the class RegionStoreClient method prewrite.
/**
* Prewrite batch keys
*
* @param skipConstraintCheck whether to skip constraint check
*/
public void prewrite(BackOffer bo, ByteString primaryLock, Iterable<Mutation> mutations, long startTs, long ttl, boolean skipConstraintCheck) throws TiClientInternalException, KeyException, RegionException {
boolean forWrite = true;
while (true) {
Supplier<PrewriteRequest> factory = () -> getIsV4() ? PrewriteRequest.newBuilder().setContext(makeContext(storeType, bo.getSlowLog())).setStartVersion(startTs).setPrimaryLock(primaryLock).addAllMutations(mutations).setLockTtl(ttl).setSkipConstraintCheck(skipConstraintCheck).setMinCommitTs(startTs).setTxnSize(16).build() : PrewriteRequest.newBuilder().setContext(makeContext(storeType, bo.getSlowLog())).setStartVersion(startTs).setPrimaryLock(primaryLock).addAllMutations(mutations).setLockTtl(ttl).setSkipConstraintCheck(skipConstraintCheck).setTxnSize(16).build();
KVErrorHandler<PrewriteResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> null, resolveLockResult -> null, startTs, forWrite);
PrewriteResponse resp = callWithRetry(bo, TikvGrpc.getKvPrewriteMethod(), factory, handler);
if (isPrewriteSuccess(bo, resp, startTs)) {
return;
}
}
}
Aggregations