private OperationHandle executeStatementInternal(String statement, Map<String, String> confOverlay, boolean runAsync, long queryTimeout) throws HiveSQLException { acquire(true, true); LOG.info("executing " + statement); ExecuteStatementOperation operation = null; OperationHandle opHandle = null; try { operation = getOperationManager().newExecuteStatementOperation(getSession(), statement, confOverlay, runAsync, queryTimeout); opHandle = operation.getHandle(); addOpHandle(opHandle); operation.run(); return opHandle; } catch (HiveSQLException e) { // Refering to SQLOperation.java, there is no chance that a HiveSQLException throws and the // async background operation submits to thread pool successfully at the same time. So, Cleanup // opHandle directly when got HiveSQLException if (opHandle != null) { removeOpHandle(opHandle); getOperationManager().closeOperation(opHandle); } throw e; } finally { if (operation == null || operation.getBackgroundHandle() == null) { release(true, true); // Not async, or wasn't submitted for some reason (failure, etc.) } else { releaseBeforeOpLock(true); // Release, but keep the lock (if present). } } }
private OperationHandle executeStatementInternal(String statement, Map<String, String> confOverlay, boolean runAsync, long queryTimeout) throws HiveSQLException { acquire(true, true); ExecuteStatementOperation operation = null; OperationHandle opHandle = null; try { operation = getOperationManager().newExecuteStatementOperation(getSession(), statement, confOverlay, runAsync, queryTimeout); opHandle = operation.getHandle(); addOpHandle(opHandle); operation.run(); return opHandle; } catch (HiveSQLException e) { // Refering to SQLOperation.java, there is no chance that a HiveSQLException throws and the // async background operation submits to thread pool successfully at the same time. So, Cleanup // opHandle directly when got HiveSQLException if (opHandle != null) { removeOpHandle(opHandle); getOperationManager().closeOperation(opHandle); } throw e; } finally { if (operation == null || operation.getBackgroundHandle() == null) { release(true, true); // Not async, or wasn't submitted for some reason (failure, etc.) } else { releaseBeforeOpLock(true); // Release, but keep the lock (if present). } } }