use of org.apache.hive.service.rpc.thrift.TStatus in project hive by apache.
the class HiveSQLException method toTStatus.
/**
* 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;
}
use of org.apache.hive.service.rpc.thrift.TStatus in project hive by apache.
the class HiveSQLException method toTStatus.
/**
* 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;
}
use of org.apache.hive.service.rpc.thrift.TStatus in project hive by apache.
the class ThriftCLIService method unsecureTokenErrorStatus.
private TStatus unsecureTokenErrorStatus() {
TStatus errorStatus = new TStatus(TStatusCode.ERROR_STATUS);
errorStatus.setErrorMessage("Delegation token only supported over remote " + "client with kerberos authentication");
return errorStatus;
}
use of org.apache.hive.service.rpc.thrift.TStatus in project hive by apache.
the class ThriftCLIService method GetDelegationToken.
@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;
}
use of org.apache.hive.service.rpc.thrift.TStatus in project hive by apache.
the class TestHiveSQLException method testHiveSQLExceptionToTStatus.
/**
* Tests the conversion from a HiveSQLException exception to the TStatus object
*/
@Test
public void testHiveSQLExceptionToTStatus() {
String expectedMessage = "reason";
String expectedSqlState = "sqlState";
int expectedVendorCode = 10;
Exception ex1 = new HiveSQLException(expectedMessage, expectedSqlState, expectedVendorCode, createSimpleCause());
TStatus status = HiveSQLException.toTStatus(ex1);
Assert.assertEquals(TStatusCode.ERROR_STATUS, status.getStatusCode());
Assert.assertEquals(expectedSqlState, status.getSqlState());
Assert.assertEquals(expectedMessage, status.getErrorMessage());
Assert.assertEquals(HiveSQLException.toString(ex1), status.getInfoMessages());
}
Aggregations