state = opStatus.getState(); System.out.println("Current state: " + state); break; state = opStatus.getState(); System.out.println("Current state: " + state); if (state == OperationState.CANCELED || OperationState.ERROR, state); assertEquals(opStatus.getOperationException().getSQLState(), "08S01"); assertEquals(opStatus.getOperationException().getErrorCode(), 1);
public OperationStatus getStatus() { String taskStatus = null; try { taskStatus = getTaskStatus(); } catch (HiveSQLException sqlException) { LOG.error("Error getting task status for " + opHandle.toString(), sqlException); } return new OperationStatus(state, taskStatus, operationStart, operationComplete, hasResultSet, operationException); }
cliService.getOperationStatus(operationHandle, req.isGetProgressUpdate()); if (operationStatus.getState().equals(OperationState.FINISHED)) { long numModifiedRows = operationStatus.getNumModifiedRows(); resp.setNumModifiedRows(numModifiedRows); 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()); if (operationStatus.isHasResultSetIsSet()) { resp.setHasResultSet(operationStatus.getHasResultSet()); JobProgressUpdate progressUpdate = operationStatus.jobProgressUpdate(); ProgressMonitorStatusMapper mapper = ProgressMonitorStatusMapper.DEFAULT; if ("tez".equals(hiveConf.getVar(ConfVars.HIVE_EXECUTION_ENGINE))) {
private void checkOperationTimes(OperationHandle operationHandle, OperationStatus status) { OperationState state = status.getState(); assertFalse(status.getOperationStarted() == 0); if (OperationState.CANCELED == state || state == OperationState.CLOSED || state == OperationState.FINISHED || state == OperationState.ERROR) { System.out.println("##OP " + operationHandle.getHandleIdentifier() + " STATE:" + status.getState() +" START:" + status.getOperationStarted() + " END:" + status.getOperationCompleted()); assertFalse(status.getOperationCompleted() == 0); assertTrue(status.getOperationCompleted() - status.getOperationStarted() >= 0); } } }
status = client.getOperationStatus(ophandle, false); checkOperationTimes(ophandle, status); OperationState state = status.getState(); System.out.println("Polling: " + ophandle + " count=" + (++count) + " state=" + state); String jsonTaskStatus = status.getTaskStatus(); assertNotNull(jsonTaskStatus); ObjectMapper mapper = new ObjectMapper();
private void runQuery() throws HiveSQLException { try { OperationState opState = getStatus().getState(); if ((getStatus().getState() == OperationState.CANCELED) || (getStatus().getState() == OperationState.TIMEDOUT) || (getStatus().getState() == OperationState.CLOSED) || (getStatus().getState() == OperationState.FINISHED)) { LOG.warn("Ignore exception in terminal state", e); return;
log.debug("GetStatus on hiveHandle: {} returned state:", handle, opStatus.getState().name()); switch (opStatus.getState()) { case CANCELED: status.setState(DriverQueryState.CANCELED); status.setStatusMessage("Query execution failed!"); status.setErrorMessage( "Query failed with errorCode:" + opStatus.getOperationException().getErrorCode() + " with errorMessage: " + opStatus.getOperationException().getMessage()); break; case FINISHED: String jsonTaskStatus = opStatus.getTaskStatus(); String errorMsg = null; if (StringUtils.isNotBlank(jsonTaskStatus)) { status.setProgressMessage(jsonTaskStatus); status.setProgress(progress); status.setDriverStartTime(opStatus.getOperationStarted()); status.setDriverFinishTime(opStatus.getOperationCompleted()); return status;
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))) {
/** * Cancel the running operation unless it is already in a terminal state * @param opHandle operation handle * @param errMsg error message * @throws HiveSQLException */ public void cancelOperation(OperationHandle opHandle, String errMsg) throws HiveSQLException { Operation operation = getOperation(opHandle); OperationState opState = operation.getStatus().getState(); if (opState.isTerminal()) { // Cancel should be a no-op in either cases LOG.debug(opHandle + ": Operation is already aborted in state - " + opState); } else { LOG.debug(opHandle + ": Attempting to cancel from state - " + opState); OperationState operationState = OperationState.CANCELED; operationState.setErrorMessage(errMsg); operation.cancel(operationState); if (operation instanceof SQLOperation) { removeSafeQueryInfo(opHandle); } } }
log.debug("GetStatus on hiveHandle: {} returned state:", handle, opStatus.getState().name()); switch (opStatus.getState()) { case CANCELED: status.setState(DriverQueryState.CANCELED); status.setStatusMessage("Query execution failed!"); status.setErrorMessage( "Query failed with errorCode:" + opStatus.getOperationException().getErrorCode() + " with errorMessage: " + opStatus.getOperationException().getMessage()); break; case FINISHED: String jsonTaskStatus = opStatus.getTaskStatus(); String errorMsg = null; if (StringUtils.isNotBlank(jsonTaskStatus)) { status.setProgressMessage(jsonTaskStatus); status.setProgress(progress); status.setDriverStartTime(opStatus.getOperationStarted()); status.setDriverFinishTime(opStatus.getOperationCompleted()); return status;
opStatus = runAsyncAndWait(sessionHandle, queryString, confOverlay, OperationState.ERROR, longPollingTimeout); assertEquals(opStatus.getOperationException().getSQLState(), "08S01"); assertEquals(opStatus.getOperationException().getErrorCode(), 1); checkOperationTimes(opHandle, operationStatus); state = client.getOperationStatus(opHandle, false).getState(); System.out.println(opHandle + " after cancelling, state= " + state); assertEquals("Query should be cancelled", OperationState.CANCELED, state);
System.out.println("Long polling starts at: " + longPollingStart); opStatus = client.getOperationStatus(opHandle, false); state = opStatus.getState(); longPollingEnd = System.currentTimeMillis(); System.out.println("Long polling ends at: " + longPollingEnd); assertEquals(expectedState, client.getOperationStatus(opHandle, false).getState()); client.closeOperation(opHandle); return opStatus;
@Override public OperationStatus getOperationStatus(OperationHandle opHandle, boolean getProgressUpdate) throws HiveSQLException { try { TGetOperationStatusReq req = new TGetOperationStatusReq(opHandle.toTOperationHandle()); req.setGetProgressUpdate(getProgressUpdate); TGetOperationStatusResp resp = cliService.GetOperationStatus(req); // Checks the status of the RPC call, throws an exception in case of error checkStatus(resp.getStatus()); OperationState opState = OperationState.getOperationState(resp.getOperationState()); HiveSQLException opException = null; if (opState == OperationState.ERROR) { opException = new HiveSQLException(resp.getErrorMessage(), resp.getSqlState(), resp.getErrorCode()); } return new OperationStatus(opState, resp.getTaskStatus(), resp.getOperationStarted(), resp.getOperationCompleted(), resp.isSetHasResultSet() ? resp.isHasResultSet() : null, opException); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override protected QueryStatus doFetchStatus(OperationHandle operationHandle) throws HiveSQLException, ExploreException, HandleNotFoundException { OperationStatus operationStatus; CLIService cliService = getCliService(); // Call the getOperationStatus method based on the number of arguments it expects. try { if (getOperationStatus.getParameterTypes().length == 2) { operationStatus = (OperationStatus) getOperationStatus.invoke(cliService, operationHandle, true); } else { operationStatus = (OperationStatus) getOperationStatus.invoke(cliService, operationHandle); } } catch (IndexOutOfBoundsException | IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Failed to get the status of the operation.", e); } @SuppressWarnings("ThrowableResultOfMethodCallIgnored") HiveSQLException hiveExn = operationStatus.getOperationException(); if (hiveExn != null) { return new QueryStatus(hiveExn.getMessage(), hiveExn.getSQLState()); } return new QueryStatus(QueryStatus.OpStatus.valueOf(operationStatus.getState().toString()), operationHandle.hasResultSet()); }
public OperationStatus getStatus() { return new OperationStatus(state, operationException); }
@Override protected QueryStatus doFetchStatus(OperationHandle operationHandle) throws HiveSQLException, ExploreException, HandleNotFoundException { OperationStatus operationStatus; CLIService cliService = getCliService(); // Call the getOperationStatus method based on the number of arguments it expects. try { if (getOperationStatus.getParameterTypes().length == 2) { operationStatus = (OperationStatus) getOperationStatus.invoke(cliService, operationHandle, true); } else { operationStatus = (OperationStatus) getOperationStatus.invoke(cliService, operationHandle); } } catch (IndexOutOfBoundsException | IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Failed to get the status of the operation.", e); } @SuppressWarnings("ThrowableResultOfMethodCallIgnored") HiveSQLException hiveExn = operationStatus.getOperationException(); if (hiveExn != null) { return new QueryStatus(hiveExn.getMessage(), hiveExn.getSQLState()); } return new QueryStatus(QueryStatus.OpStatus.valueOf(operationStatus.getState().toString()), operationHandle.hasResultSet()); }
assertNotNull(opStatus); OperationState state = opStatus.getState();
public OperationStatus getStatus() { return new OperationStatus(state, operationException); }
@Override protected QueryStatus doFetchStatus(OperationHandle operationHandle) throws HiveSQLException, ExploreException, HandleNotFoundException { OperationStatus operationStatus = getCliService().getOperationStatus(operationHandle); @SuppressWarnings("ThrowableResultOfMethodCallIgnored") HiveSQLException hiveExn = operationStatus.getOperationException(); if (hiveExn != null) { return new QueryStatus(hiveExn.getMessage(), hiveExn.getSQLState()); } return new QueryStatus(QueryStatus.OpStatus.valueOf(operationStatus.getState().toString()), operationHandle.hasResultSet()); }