Search in sources :

Example 1 with PDError

use of com.pingcap.tikv.pd.PDError in project tispark by pingcap.

the class PDErrorHandler method handleResponseError.

@Override
public boolean handleResponseError(BackOffer backOffer, RespT resp) {
    if (resp == null) {
        return false;
    }
    PDError error = getError.apply(resp);
    if (error != null) {
        switch(error.getErrorType()) {
            case PD_ERROR:
                backOffer.doBackOff(BackOffFunction.BackOffFuncType.BoPDRPC, new GrpcException(error.toString()));
                client.updateLeader();
                return true;
            case REGION_PEER_NOT_ELECTED:
                logger.debug(error.getMessage());
                backOffer.doBackOff(BackOffFunction.BackOffFuncType.BoPDRPC, new GrpcException(error.toString()));
                return true;
            default:
                throw new TiClientInternalException("Unknown error type encountered: " + error);
        }
    }
    return false;
}
Also used : TiClientInternalException(com.pingcap.tikv.exception.TiClientInternalException) GrpcException(com.pingcap.tikv.exception.GrpcException) PDError(com.pingcap.tikv.pd.PDError)

Aggregations

GrpcException (com.pingcap.tikv.exception.GrpcException)1 TiClientInternalException (com.pingcap.tikv.exception.TiClientInternalException)1 PDError (com.pingcap.tikv.pd.PDError)1