Search in sources :

Example 1 with GetSequenceResponse

use of io.dingodb.store.row.cmd.store.GetSequenceResponse in project dingo by dingodb.

the class DefaultRegionKVService method handleGetSequence.

@Override
public void handleGetSequence(final GetSequenceRequest request, final RequestProcessClosure<BaseRequest, BaseResponse<?>> closure) {
    final GetSequenceResponse response = new GetSequenceResponse();
    response.setRegionId(getRegionId());
    response.setRegionEpoch(getRegionEpoch());
    try {
        KVParameterRequires.requireSameEpoch(request, getRegionEpoch());
        final byte[] seqKey = KVParameterRequires.requireNonNull(request.getSeqKey(), "sequence.seqKey");
        final int step = KVParameterRequires.requireNonNegative(request.getStep(), "sequence.step");
        this.rawKVStore.getSequence(seqKey, step, new BaseKVStoreClosure() {

            @Override
            public void run(final Status status) {
                if (status.isOk()) {
                    response.setValue((Sequence) getData());
                } else {
                    setFailure(request, response, status, getError());
                }
                closure.sendResponse(response);
            }
        });
    } catch (final Throwable t) {
        LOG.error("Failed to handle: {}, {}.", request, StackTraceUtil.stackTrace(t));
        response.setError(Errors.forException(t));
        closure.sendResponse(response);
    }
}
Also used : Status(io.dingodb.raft.Status) GetSequenceResponse(io.dingodb.store.row.cmd.store.GetSequenceResponse) BaseKVStoreClosure(io.dingodb.store.row.storage.BaseKVStoreClosure) Sequence(io.dingodb.store.row.storage.Sequence)

Aggregations

Status (io.dingodb.raft.Status)1 GetSequenceResponse (io.dingodb.store.row.cmd.store.GetSequenceResponse)1 BaseKVStoreClosure (io.dingodb.store.row.storage.BaseKVStoreClosure)1 Sequence (io.dingodb.store.row.storage.Sequence)1