@Override public String toString() { return "OperationHandle [opType=" + opType + ", getHandleIdentifier()=" + getHandleIdentifier() + "]"; } }
@Override public String getQueryId(TOperationHandle opHandle) throws HiveSQLException { Operation operation = sessionManager.getOperationManager().getOperation( new OperationHandle(opHandle)); final String queryId = operation.getQueryId(); LOG.debug(opHandle + ": getQueryId() " + queryId); return queryId; }
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); }
@Override public RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation, long maxRows, FetchType fetchType) throws HiveSQLException { try { TFetchResultsReq req = new TFetchResultsReq(); req.setOperationHandle(opHandle.toTOperationHandle()); req.setOrientation(orientation.toTFetchOrientation()); req.setMaxRows(maxRows); req.setFetchType(fetchType.toTFetchType()); TFetchResultsResp resp = cliService.FetchResults(req); checkStatus(resp.getStatus()); return RowSetFactory.create(resp.getResults(), opHandle.getProtocolVersion()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
protected void createOperationLog() { if (parentSession.isOperationLogEnabled()) { File operationLogFile = new File(parentSession.getOperationLogSessionDir(), opHandle.getHandleIdentifier().toString()); isOperationLogEnabled = true; operationLog = new OperationLog(opHandle.toString(), operationLogFile, parentSession.getHiveConf()); } catch (FileNotFoundException e) { LOG.warn("Unable to instantiate OperationLog object for operation: " +
@Override public void cancelOperation(OperationHandle opHandle) throws HiveSQLException { try { TCancelOperationReq req = new TCancelOperationReq(opHandle.toTOperationHandle()); TCancelOperationResp resp = cliService.CancelOperation(req); checkStatus(resp.getStatus()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public TGetOperationStatusResp GetOperationStatus(TGetOperationStatusReq req) throws TException { TGetOperationStatusResp resp = new TGetOperationStatusResp(); OperationHandle operationHandle = new OperationHandle(req.getOperationHandle()); try { OperationStatus operationStatus = resp.setErrorMessage(opException.getMessage()); } else if (executionStatus == TJobExecutionStatus.NOT_AVAILABLE && OperationType.EXECUTE_STATEMENT.equals(operationHandle.getOperationType())) { resp.getProgressUpdateResponse().setProgressedPercentage( getProgressedPercentage(operationHandle));
@Override protected QueryStatus doFetchStatus(OperationHandle operationHandle) throws HiveSQLException, ExploreException, HandleNotFoundException { try { // In Hive 12, CLIService.getOperationStatus returns OperationState. // In Hive 13, CLIService.getOperationStatus returns OperationStatus. // Since we use Hive 13 for dev, we need the following workaround to get Hive 12 working. Class<? extends CLIService> cliServiceClass = getCliService().getClass(); Method m = cliServiceClass.getMethod("getOperationStatus", OperationHandle.class); OperationState operationState = (OperationState) m.invoke(getCliService(), operationHandle); return new QueryStatus(QueryStatus.OpStatus.valueOf(operationState.toString()), operationHandle.hasResultSet()); } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { throw Throwables.propagate(e); } }
public OperationType getType() { return opHandle.getOperationType(); }
protected void setHasResultSet(boolean hasResultSet) { this.hasResultSet = hasResultSet; opHandle.setHasResultSet(hasResultSet); }
public TProtocolVersion getProtocolVersion() { return opHandle.getProtocolVersion(); }
@Override public RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation, long maxRows, FetchType fetchType) throws HiveSQLException { try { TFetchResultsReq req = new TFetchResultsReq(); req.setOperationHandle(opHandle.toTOperationHandle()); req.setOrientation(orientation.toTFetchOrientation()); req.setMaxRows(maxRows); req.setFetchType(fetchType.toTFetchType()); TFetchResultsResp resp = cliService.FetchResults(req); checkStatus(resp.getStatus()); return RowSetFactory.create(resp.getResults(), opHandle.getProtocolVersion()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
protected void createOperationLog() { if (parentSession.isOperationLogEnabled()) { File operationLogFile = new File(parentSession.getOperationLogSessionDir(), opHandle.getHandleIdentifier().toString()); isOperationLogEnabled = true; operationLog = new OperationLog(opHandle.toString(), operationLogFile, parentSession.getHiveConf()); } catch (FileNotFoundException e) { LOG.warn("Unable to instantiate OperationLog object for operation: " +
@Override public void closeOperation(OperationHandle opHandle) throws HiveSQLException { try { TCloseOperationReq req = new TCloseOperationReq(opHandle.toTOperationHandle()); TCloseOperationResp resp = cliService.CloseOperation(req); checkStatus(resp.getStatus()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public TGetOperationStatusResp GetOperationStatus(TGetOperationStatusReq req) throws TException { TGetOperationStatusResp resp = new TGetOperationStatusResp(); OperationHandle operationHandle = new OperationHandle(req.getOperationHandle()); try { OperationStatus operationStatus = resp.setErrorMessage(opException.getMessage()); } else if (executionStatus == TJobExecutionStatus.NOT_AVAILABLE && OperationType.EXECUTE_STATEMENT.equals(operationHandle.getOperationType())) { resp.getProgressUpdateResponse().setProgressedPercentage( getProgressedPercentage(operationHandle));
@Override protected QueryStatus doFetchStatus(OperationHandle operationHandle) throws HiveSQLException, ExploreException, HandleNotFoundException { try { // In Hive 12, CLIService.getOperationStatus returns OperationState. // In Hive 13, CLIService.getOperationStatus returns OperationStatus. // Since we use Hive 13 for dev, we need the following workaround to get Hive 12 working. Class<? extends CLIService> cliServiceClass = getCliService().getClass(); Method m = cliServiceClass.getMethod("getOperationStatus", OperationHandle.class); OperationState operationState = (OperationState) m.invoke(getCliService(), operationHandle); return new QueryStatus(QueryStatus.OpStatus.valueOf(operationState.toString()), operationHandle.hasResultSet()); } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { throw Throwables.propagate(e); } }
private double getProgressedPercentage(OperationHandle opHandle) throws HiveSQLException { checkArgument(OperationType.EXECUTE_STATEMENT.equals(opHandle.getOperationType())); Operation operation = cliService.getSessionManager().getOperationManager().getOperation(opHandle); SessionState state = operation.getParentSession().getSessionState(); ProgressMonitor monitor = state.getProgressMonitor(); return monitor == null ? 0.0 : monitor.progressedPercentage(); }
protected void setHasResultSet(boolean hasResultSet) { this.hasResultSet = hasResultSet; opHandle.setHasResultSet(hasResultSet); }
public TProtocolVersion getProtocolVersion() { return opHandle.getProtocolVersion(); }
private void removeSafeQueryInfo(OperationHandle operationHandle) { synchronized (webuiLock) { String opKey = operationHandle.getHandleIdentifier().toString(); // remove from list of live operations QueryInfo display = liveQueryInfos.remove(opKey); if (display == null) { LOG.debug("Unexpected display object value of null for operation {}", opKey); } else if (historicalQueryInfos != null) { // add to list of saved historic operations historicalQueryInfos.put(opKey, display); } } }