Search in sources :

Example 1 with TJobExecutionStatus

use of org.apache.hive.service.rpc.thrift.TJobExecutionStatus 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());
        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());
            resp.setErrorMessage(org.apache.hadoop.util.StringUtils.stringifyException(opException));
        } 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;
}
Also used : TJobExecutionStatus(org.apache.hive.service.rpc.thrift.TJobExecutionStatus) JobProgressUpdate(org.apache.hive.service.cli.JobProgressUpdate) TezProgressMonitorStatusMapper(org.apache.hive.service.cli.TezProgressMonitorStatusMapper) TGetOperationStatusResp(org.apache.hive.service.rpc.thrift.TGetOperationStatusResp) OperationStatus(org.apache.hive.service.cli.OperationStatus) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TezProgressMonitorStatusMapper(org.apache.hive.service.cli.TezProgressMonitorStatusMapper) ProgressMonitorStatusMapper(org.apache.hive.service.cli.ProgressMonitorStatusMapper) TProgressUpdateResp(org.apache.hive.service.rpc.thrift.TProgressUpdateResp) OperationHandle(org.apache.hive.service.cli.OperationHandle) LoginException(javax.security.auth.login.LoginException) ServiceException(org.apache.hive.service.ServiceException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 LoginException (javax.security.auth.login.LoginException)1 ServiceException (org.apache.hive.service.ServiceException)1 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)1 JobProgressUpdate (org.apache.hive.service.cli.JobProgressUpdate)1 OperationHandle (org.apache.hive.service.cli.OperationHandle)1 OperationStatus (org.apache.hive.service.cli.OperationStatus)1 ProgressMonitorStatusMapper (org.apache.hive.service.cli.ProgressMonitorStatusMapper)1 TezProgressMonitorStatusMapper (org.apache.hive.service.cli.TezProgressMonitorStatusMapper)1 TGetOperationStatusResp (org.apache.hive.service.rpc.thrift.TGetOperationStatusResp)1 TJobExecutionStatus (org.apache.hive.service.rpc.thrift.TJobExecutionStatus)1 TProgressUpdateResp (org.apache.hive.service.rpc.thrift.TProgressUpdateResp)1 TException (org.apache.thrift.TException)1