Search in sources :

Example 1 with CommitRequest

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

the class RegionStoreClient method commit.

/**
 * Commit batch keys
 *
 * @param backOffer backOffer
 * @param keys keys to commit
 * @param startTs start version
 * @param commitTs commit version
 */
public void commit(BackOffer backOffer, Iterable<ByteString> keys, long startTs, long commitTs) throws KeyException {
    boolean forWrite = true;
    Supplier<CommitRequest> factory = () -> CommitRequest.newBuilder().setStartVersion(startTs).setCommitVersion(commitTs).addAllKeys(keys).setContext(region.getContext()).build();
    KVErrorHandler<CommitResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> resp.hasError() ? resp.getError() : null, resolveLockResult -> null, startTs, forWrite);
    CommitResponse resp = callWithRetry(backOffer, TikvGrpc.getKvCommitMethod(), factory, handler);
    handleCommitResponse(resp);
}
Also used : CommitRequest(org.tikv.kvproto.Kvrpcpb.CommitRequest) CommitResponse(org.tikv.kvproto.Kvrpcpb.CommitResponse) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler)

Example 2 with CommitRequest

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

the class RegionStoreClient method commit.

/**
 * Commit batch keys
 *
 * @param backOffer backOffer
 * @param keys keys to commit
 * @param startTs start version
 * @param commitTs commit version
 */
public void commit(BackOffer backOffer, Iterable<ByteString> keys, long startTs, long commitTs) throws KeyException {
    boolean forWrite = true;
    Supplier<CommitRequest> factory = () -> CommitRequest.newBuilder().setStartVersion(startTs).setCommitVersion(commitTs).addAllKeys(keys).setContext(makeContext(storeType, backOffer.getSlowLog())).build();
    KVErrorHandler<CommitResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> resp.hasError() ? resp.getError() : null, resolveLockResult -> null, startTs, forWrite);
    CommitResponse resp = callWithRetry(backOffer, TikvGrpc.getKvCommitMethod(), factory, handler);
    handleCommitResponse(resp);
}
Also used : CommitRequest(org.tikv.kvproto.Kvrpcpb.CommitRequest) CommitResponse(org.tikv.kvproto.Kvrpcpb.CommitResponse) KVErrorHandler(org.tikv.common.operation.KVErrorHandler)

Aggregations

CommitRequest (org.tikv.kvproto.Kvrpcpb.CommitRequest)2 CommitResponse (org.tikv.kvproto.Kvrpcpb.CommitResponse)2 KVErrorHandler (com.pingcap.tikv.operation.KVErrorHandler)1 KVErrorHandler (org.tikv.common.operation.KVErrorHandler)1