Search in sources :

Example 1 with TsoRequest

use of org.tikv.kvproto.Pdpb.TsoRequest in project client-java by tikv.

the class PDClient method getTimestamp.

@Override
public TiTimestamp getTimestamp(BackOffer backOffer) {
    Supplier<TsoRequest> request = () -> tsoReq;
    PDErrorHandler<TsoResponse> handler = new PDErrorHandler<>(r -> r.getHeader().hasError() ? buildFromPdpbError(r.getHeader().getError()) : null, this);
    TsoResponse resp = callWithRetry(backOffer, PDGrpc.getTsoMethod(), request, handler);
    Timestamp timestamp = resp.getTimestamp();
    return new TiTimestamp(timestamp.getPhysical(), timestamp.getLogical());
}
Also used : TiTimestamp(org.tikv.common.meta.TiTimestamp) PDErrorHandler(org.tikv.common.operation.PDErrorHandler) TsoResponse(org.tikv.kvproto.Pdpb.TsoResponse) TiTimestamp(org.tikv.common.meta.TiTimestamp) Timestamp(org.tikv.kvproto.Pdpb.Timestamp) TsoRequest(org.tikv.kvproto.Pdpb.TsoRequest)

Example 2 with TsoRequest

use of org.tikv.kvproto.Pdpb.TsoRequest in project tispark by pingcap.

the class PDClient method getTimestamp.

@Override
public TiTimestamp getTimestamp(BackOffer backOffer) {
    Supplier<TsoRequest> request = () -> tsoReq;
    PDErrorHandler<TsoResponse> handler = new PDErrorHandler<>(r -> r.getHeader().hasError() ? buildFromPdpbError(r.getHeader().getError()) : null, this);
    TsoResponse resp = callWithRetry(backOffer, PDGrpc.getTsoMethod(), request, handler);
    Timestamp timestamp = resp.getTimestamp();
    return new TiTimestamp(timestamp.getPhysical(), timestamp.getLogical());
}
Also used : TiTimestamp(com.pingcap.tikv.meta.TiTimestamp) PDErrorHandler(com.pingcap.tikv.operation.PDErrorHandler) TsoResponse(org.tikv.kvproto.Pdpb.TsoResponse) Timestamp(org.tikv.kvproto.Pdpb.Timestamp) TiTimestamp(com.pingcap.tikv.meta.TiTimestamp) TsoRequest(org.tikv.kvproto.Pdpb.TsoRequest)

Aggregations

Timestamp (org.tikv.kvproto.Pdpb.Timestamp)2 TsoRequest (org.tikv.kvproto.Pdpb.TsoRequest)2 TsoResponse (org.tikv.kvproto.Pdpb.TsoResponse)2 TiTimestamp (com.pingcap.tikv.meta.TiTimestamp)1 PDErrorHandler (com.pingcap.tikv.operation.PDErrorHandler)1 TiTimestamp (org.tikv.common.meta.TiTimestamp)1 PDErrorHandler (org.tikv.common.operation.PDErrorHandler)1