public Object getFieldValue(_Fields field) { switch (field) { case STATUS_CODE: return getStatusCode(); case INFO_MESSAGES: return getInfoMessages(); case SQL_STATE: return getSqlState(); case ERROR_CODE: return getErrorCode(); case ERROR_MESSAGE: return getErrorMessage(); } throw new IllegalStateException(); }
case STATUS_CODE: if (value == null) { unsetStatusCode(); } else { setStatusCode((TStatusCode)value); unsetInfoMessages(); } else { setInfoMessages((List<String>)value); unsetSqlState(); } else { setSqlState((String)value); unsetErrorCode(); } else { setErrorCode((Integer)value); unsetErrorMessage(); } else { setErrorMessage((String)value);
private TStatus unsecureTokenErrorStatus() { TStatus errorStatus = new TStatus(TStatusCode.ERROR_STATUS); errorStatus.setErrorMessage("Delegation token only supported over remote " + "client with kerberos authentication"); return errorStatus; }
/** * Converts current object to a {@link TStatus} object * @return a {@link TStatus} object */ public TStatus toTStatus() { // TODO: convert sqlState, etc. TStatus tStatus = new TStatus(TStatusCode.ERROR_STATUS); tStatus.setSqlState(getSQLState()); tStatus.setErrorCode(getErrorCode()); tStatus.setErrorMessage(getMessage()); tStatus.setInfoMessages(toString(this)); return tStatus; }
/** * Tests the conversion from a regular exception to the TStatus object */ @Test public void testExceptionToTStatus() { Exception ex1 = createException(); ex1.initCause(createSimpleCause()); TStatus status = HiveSQLException.toTStatus(ex1); Assert.assertEquals(TStatusCode.ERROR_STATUS, status.getStatusCode()); Assert.assertEquals(ex1.getMessage(), status.getErrorMessage()); Assert.assertEquals(HiveSQLException.toString(ex1), status.getInfoMessages()); }
public TStatus deepCopy() { return new TStatus(this); }
/** * Converts the specified {@link Exception} object into a {@link TStatus} object * @param e a {@link Exception} object * @return a {@link TStatus} object */ public static TStatus toTStatus(Exception e) { if (e instanceof HiveSQLException) { return ((HiveSQLException)e).toTStatus(); } TStatus tStatus = new TStatus(TStatusCode.ERROR_STATUS); tStatus.setErrorMessage(e.getMessage()); tStatus.setInfoMessages(toString(e)); return tStatus; }
static void verifySuccess(TStatus status, boolean withInfo) throws SQLException { if (status.getStatusCode() == TStatusCode.SUCCESS_STATUS || (withInfo && status.getStatusCode() == TStatusCode.SUCCESS_WITH_INFO_STATUS)) { return; } throw new HiveSQLException(status); }
@Override public TGetDelegationTokenResp GetDelegationToken(TGetDelegationTokenReq req) throws TException { TGetDelegationTokenResp resp = new TGetDelegationTokenResp(); if (hiveAuthFactory == null || !hiveAuthFactory.isSASLKerberosUser()) { resp.setStatus(unsecureTokenErrorStatus()); } else { try { String token = cliService.getDelegationToken( new SessionHandle(req.getSessionHandle()), hiveAuthFactory, req.getOwner(), req.getRenewer()); resp.setDelegationToken(token); resp.setStatus(OK_STATUS); } catch (HiveSQLException e) { LOG.error("Error obtaining delegation token", e); TStatus tokenErrorStatus = HiveSQLException.toTStatus(e); tokenErrorStatus.setSqlState("42000"); resp.setStatus(tokenErrorStatus); } } return resp; }
/** * Converts current object to a {@link TStatus} object * @return a {@link TStatus} object */ public TStatus toTStatus() { // TODO: convert sqlState, etc. TStatus tStatus = new TStatus(TStatusCode.ERROR_STATUS); tStatus.setSqlState(getSQLState()); tStatus.setErrorCode(getErrorCode()); tStatus.setErrorMessage(getMessage()); tStatus.setInfoMessages(toString(this)); return tStatus; }
/** * Performs a deep copy on <i>other</i>. */ public TCloseSessionResp(TCloseSessionResp other) { if (other.isSetStatus()) { this.status = new TStatus(other.status); } }
/** * Converts the specified {@link Exception} object into a {@link TStatus} object * @param e a {@link Exception} object * @return a {@link TStatus} object */ public static TStatus toTStatus(Exception e) { if (e instanceof HiveSQLException) { return ((HiveSQLException)e).toTStatus(); } TStatus tStatus = new TStatus(TStatusCode.ERROR_STATUS); tStatus.setErrorMessage(e.getMessage()); tStatus.setInfoMessages(toString(e)); return tStatus; }
public void checkStatus(TStatus status) throws HiveSQLException { if (TStatusCode.ERROR_STATUS.equals(status.getStatusCode())) { throw new HiveSQLException(status); } }
private TStatus unsecureTokenErrorStatus() { TStatus errorStatus = new TStatus(TStatusCode.ERROR_STATUS); errorStatus.setErrorMessage("Delegation token only supported over remote " + "client with kerberos authentication"); return errorStatus; }
@Override public TGetDelegationTokenResp GetDelegationToken(TGetDelegationTokenReq req) throws TException { TGetDelegationTokenResp resp = new TGetDelegationTokenResp(); if (hiveAuthFactory == null || !hiveAuthFactory.isSASLKerberosUser()) { resp.setStatus(unsecureTokenErrorStatus()); } else { try { String token = cliService.getDelegationToken( new SessionHandle(req.getSessionHandle()), hiveAuthFactory, req.getOwner(), req.getRenewer()); resp.setDelegationToken(token); resp.setStatus(OK_STATUS); } catch (HiveSQLException e) { LOG.error("Error obtaining delegation token", e); TStatus tokenErrorStatus = HiveSQLException.toTStatus(e); tokenErrorStatus.setSqlState("42000"); resp.setStatus(tokenErrorStatus); } } return resp; }
public HiveSQLException(TStatus status) { // TODO: set correct vendorCode field super(status.getErrorMessage(), status.getSqlState(), status.getErrorCode()); if (status.getInfoMessages() != null) { initCause(toCause(status.getInfoMessages())); } }
/** * Performs a deep copy on <i>other</i>. */ public TSetClientInfoResp(TSetClientInfoResp other) { if (other.isSetStatus()) { this.status = new TStatus(other.status); } }
static void verifySuccess(TStatus status, boolean withInfo) throws SQLException { if (status.getStatusCode() == TStatusCode.SUCCESS_STATUS || (withInfo && status.getStatusCode() == TStatusCode.SUCCESS_WITH_INFO_STATUS)) { return; } throw new HiveSQLException(status); }