private static void validateClientVersion(int protocolVersion) throws SentryThriftAPIMismatchException { if (ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT != protocolVersion) { String msg = "Sentry thrift API protocol version mismatch: Client thrift version " + "is: " + protocolVersion + " , server thrift version " + "is " + ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT; throw new SentryThriftAPIMismatchException(msg); } } }
@VisibleForTesting static void validateClientVersion(int protocolVersion) throws SentryThriftAPIMismatchException { if (ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT != protocolVersion) { String msg = "Sentry thrift API protocol version mismatch: Client thrift version " + "is: " + protocolVersion + " , server thrift verion " + "is " + ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT; throw new SentryThriftAPIMismatchException(msg); } }
public static void throwIfNotOk(TSentryResponseStatus thriftStatus) throws SentryUserException { Status status = Status.fromCode(thriftStatus.getValue()); switch(status) { case OK: break; case ALREADY_EXISTS: throw new SentryAlreadyExistsException(serverErrorToString(thriftStatus), thriftStatus.getMessage()); case NO_SUCH_OBJECT: throw new SentryNoSuchObjectException(serverErrorToString(thriftStatus), thriftStatus.getMessage()); case RUNTIME_ERROR: throw new RuntimeException(serverErrorToString(thriftStatus)); case INVALID_INPUT: throw new SentryInvalidInputException(serverErrorToString(thriftStatus), thriftStatus.getMessage()); case ACCESS_DENIED: throw new SentryAccessDeniedException(serverErrorToString(thriftStatus), thriftStatus.getMessage()); case THRIFT_VERSION_MISMATCH: throw new SentryThriftAPIMismatchException(serverErrorToString(thriftStatus), thriftStatus.getMessage()); case UNKNOWN: throw new AssertionError(serverErrorToString(thriftStatus)); default: throw new AssertionError("Unknown status code: " + status + ". Msg: " + serverErrorToString(thriftStatus)); } }