@Override public Void call() throws Exception { if (syncThreadStart) { syncThreadStart(cdlIn, cdlOut); } SessionHandle sessionHandle = openSession(confOverlay); OperationHandle[] hs = new OperationHandle[queryCount]; for (int i = 0; i < hs.length; ++i) { String queryString = String.format(queryStringFormat, i); LOG.info("Submitting " + i); hs[i] = client.executeStatementAsync(sessionHandle, queryString, confOverlay); } for (int i = hs.length - 1; i >= 0; --i) { waitForAsyncQuery(hs[i], expectedOperationState, longPollingTimeout); } return null; } };
private OperationStatus runAsyncAndWait(SessionHandle sessionHandle, String queryString, Map<String, String> confOverlay, OperationState expectedState, long longPollingTimeout) throws HiveSQLException { // Timeout for the iteration in case of asynchronous execute confOverlay.put( HiveConf.ConfVars.HIVE_SERVER2_LONG_POLLING_TIMEOUT.varname, longPollingTimeout + "ms"); OperationHandle h = client.executeStatementAsync(sessionHandle, queryString, confOverlay); return waitForAsyncQuery(h, expectedState, longPollingTimeout); }
+ "(SELECT ID + ' ' `ID` FROM TEST_EXEC_ASYNC) b on a.ID=b.ID"; OperationHandle ophandle = client.executeStatementAsync(sessionHandle, select, confOverlay);
opHandle = client.executeStatementAsync(sessionHandle, queryString, confOverlay); System.out.println("Cancelling " + opHandle); client.cancelOperation(opHandle);
@Override public void executeAsync(QueryContext ctx) throws LensException { try { addPersistentPath(ctx); Configuration qdconf = ctx.getDriverConf(this); qdconf.set("mapred.job.name", ctx.getQueryHandle().toString()); decidePriority(ctx); SessionHandle sessionHandle = getSession(ctx); OperationHandle op = getClient().executeStatementAsync(sessionHandle, ctx.getSelectedDriverQuery(), qdconf.getValByRegex(".*")); ctx.setDriverOpHandle(op.toString()); log.info("QueryHandle: {} HiveHandle:{}", ctx.getQueryHandle(), op); hiveHandles.put(ctx.getQueryHandle(), op); opHandleToSession.put(op, sessionHandle); } catch (IOException e) { throw new LensException("Error adding persistent path", e); } catch (HiveSQLException e) { handleHiveServerError(ctx, e); handleHiveSQLException(e); } }
@Override public void executeAsync(QueryContext ctx) throws LensException { try { addPersistentPath(ctx); Configuration qdconf = ctx.getDriverConf(this); qdconf.set("mapred.job.name", ctx.getQueryHandle().toString()); decidePriority(ctx); SessionHandle sessionHandle = getSession(ctx); OperationHandle op = getClient().executeStatementAsync(sessionHandle, ctx.getSelectedDriverQuery(), qdconf.getValByRegex(".*")); ctx.setDriverOpHandle(op.toString()); log.info("QueryHandle: {} HiveHandle:{}", ctx.getQueryHandle(), op); hiveHandles.put(ctx.getQueryHandle(), op); opHandleToSession.put(op, sessionHandle); } catch (IOException e) { throw new LensException("Error adding persistent path", e); } catch (HiveSQLException e) { handleHiveServerError(ctx, e); handleHiveSQLException(e); } }