use of org.apache.hive.service.cli.ProgressMonitorStatusMapper in project hive by apache.
the class ThriftCLIService method GetOperationStatus.
@Override
public TGetOperationStatusResp GetOperationStatus(TGetOperationStatusReq req) throws TException {
TGetOperationStatusResp resp = new TGetOperationStatusResp();
OperationHandle operationHandle = new OperationHandle(req.getOperationHandle());
try {
OperationStatus operationStatus = cliService.getOperationStatus(operationHandle, req.isGetProgressUpdate());
resp.setOperationState(operationStatus.getState().toTOperationState());
resp.setErrorMessage(operationStatus.getState().getErrorMessage());
HiveSQLException opException = operationStatus.getOperationException();
resp.setTaskStatus(operationStatus.getTaskStatus());
resp.setOperationStarted(operationStatus.getOperationStarted());
resp.setOperationCompleted(operationStatus.getOperationCompleted());
resp.setHasResultSet(operationStatus.getHasResultSet());
JobProgressUpdate progressUpdate = operationStatus.jobProgressUpdate();
ProgressMonitorStatusMapper mapper = ProgressMonitorStatusMapper.DEFAULT;
if ("tez".equals(hiveConf.getVar(ConfVars.HIVE_EXECUTION_ENGINE))) {
mapper = new TezProgressMonitorStatusMapper();
}
TJobExecutionStatus executionStatus = mapper.forStatus(progressUpdate.status);
resp.setProgressUpdateResponse(new TProgressUpdateResp(progressUpdate.headers(), progressUpdate.rows(), progressUpdate.progressedPercentage, executionStatus, progressUpdate.footerSummary, progressUpdate.startTimeMillis));
if (opException != null) {
resp.setSqlState(opException.getSQLState());
resp.setErrorCode(opException.getErrorCode());
if (opException.getErrorCode() == 29999)
resp.setErrorMessage(org.apache.hadoop.util.StringUtils.stringifyException(opException));
else
resp.setErrorMessage(opException.getMessage());
} else if (executionStatus == TJobExecutionStatus.NOT_AVAILABLE && OperationType.EXECUTE_STATEMENT.equals(operationHandle.getOperationType())) {
resp.getProgressUpdateResponse().setProgressedPercentage(getProgressedPercentage(operationHandle));
}
resp.setStatus(OK_STATUS);
} catch (Exception e) {
LOG.warn("Error getting operation status: ", e);
resp.setStatus(HiveSQLException.toTStatus(e));
}
return resp;
}
Aggregations