transportLock.unlock();
}
TGetOperationStatusReq statusReq = new TGetOperationStatusReq(stmtHandle);
boolean operationComplete = false;
TGetOperationStatusResp statusResp;
// Poll on the operation status, till the operation is complete
while (!operationComplete) {
try {
/**
* For an async SQLOperation, GetOperationStatus will use the long polling approach
* It will essentially return after the HIVE_SERVER2_LONG_POLLING_TIMEOUT (a server config) expires
*/
transportLock.lock();
try {
statusResp = client.GetOperationStatus(statusReq);
} finally {
transportLock.unlock();
}
Utils.verifySuccessWithInfo(statusResp.getStatus());
if (statusResp.isSetOperationState()) {
switch (statusResp.getOperationState()) {
case CLOSED_STATE:
case FINISHED_STATE:
operationComplete = true;
break;
case CANCELED_STATE:
// 01000 -> warning
throw new SQLException("Query was cancelled", "01000");
case ERROR_STATE:
// Get the error details from the underlying exception
throw new SQLException(statusResp.getErrorMessage(),
statusResp.getSqlState(), statusResp.getErrorCode());
case UKNOWN_STATE:
throw new SQLException("Unknown query", "HY000");
case INITIALIZED_STATE:
case PENDING_STATE:
case RUNNING_STATE: