@Test(dataProvider = "waitBeforeCancel") public void testCancelQuery(boolean waitBeforeCancel) throws Exception { setupCancelQuery(); final String query = "SELECT positive(5) FROM cancel_query_test"; QueryContext context = createQueryContext(query); System.out.println("@@@ test_cancel:" + context.getQueryHandle()); executeAsync(context); QueryHandle handle = context.getQueryHandle(); if (waitBeforeCancel) { Thread.sleep(1000); } boolean isCancelled = driver.cancelQuery(handle); driver.updateStatus(context); assertTrue(isCancelled); assertEquals(context.getDriverStatus().getState(), DriverQueryState.CANCELED); assertTrue(context.getDriverStatus().getDriverStartTime() > 0); assertTrue(context.getDriverStatus().getDriverFinishTime() > 0); driver.closeQuery(handle); }
@Override public boolean cancelQuery(QueryHandle handle) throws LensException { checkConfigured(); JdbcQueryContext context = getQueryContext(handle); log.info("{} cancel request on query {}", getFullyQualifiedName(), handle); boolean cancelResult = context.cancel(); if (cancelResult) { context.getLensContext().setDriverStatus(DriverQueryState.CANCELED); context.closeResult(); log.info("{} Canceled query : {}", getFullyQualifiedName(), handle); } return cancelResult; }
JDBCDriver extends AbstractLensDriver { @Override public boolean cancelQuery(QueryHandle handle) throws LensException { checkConfigured(); JdbcQueryContext context = getQueryContext(handle); log.info("{} cancel request on query {}", getFullyQualifiedName(), handle); boolean cancelResult = context.cancel(); if (cancelResult) { context.getLensContext().setDriverStatus(DriverQueryState.CANCELED); context.closeResult(); log.info("{} Canceled query : {}", getFullyQualifiedName(), handle); } return cancelResult; } }
JDBCDriver extends AbstractLensDriver { @Override public boolean cancelQuery(QueryHandle handle) throws LensException { checkConfigured(); JdbcQueryContext context = getQueryContext(handle); log.info("{} cancel request on query {}", getFullyQualifiedName(), handle); boolean cancelResult = context.cancel(); if (cancelResult) { context.getLensContext().setDriverStatus(DriverQueryState.CANCELED); context.closeResult(); log.info("{} Canceled query : {}", getFullyQualifiedName(), handle); } return cancelResult; }  }
JDBCDriver extends AbstractLensDriver { @Override public boolean cancelQuery(QueryHandle handle) throws LensException { checkConfigured(); JdbcQueryContext context = getQueryContext(handle); log.info("{} cancel request on query {}", getFullyQualifiedName(), handle); boolean cancelResult = context.cancel(); if (cancelResult) { context.getLensContext().setDriverStatus(DriverQueryState.CANCELED); context.closeResult(); log.info("{} Canceled query : {}", getFullyQualifiedName(), handle); } return cancelResult; }  @Override void configure(Configuration conf, String driverType, String driverName); void init(); QueryCost calculateQueryCost(AbstractQueryContext qctx); @Override QueryCost estimate(AbstractQueryContext qctx); @Override DriverQueryPlan explain(AbstractQueryContext explainCtx); void validate(AbstractQueryContext pContext); @Override void prepare(PreparedQueryContext pContext); @Override DriverQueryPlan explainAndPrepare(PreparedQueryContext pContext); @Override void closePreparedQuery(QueryPrepareHandle handle); @Override LensResultSet execute(QueryContext context); @Override void executeAsync(QueryContext context); @Override void updateStatus(QueryContext context); @Override void closeResultSet(QueryHandle handle); @Override boolean cancelQuery(QueryHandle handle); @Override void closeQuery(QueryHandle handle); @Override void close(); @Override void registerDriverEventListener(LensEventListener<DriverEvent> driverEventListener); @Override void readExternal(ObjectInput arg0); @Override void writeExternal(ObjectOutput arg0); @Override StatusUpdateMethod getStatusUpdateMethod(); }
JDBCDriver extends AbstractLensDriver { @Override public boolean cancelQuery(QueryHandle handle) throws LensException { checkConfigured(); JdbcQueryContext context = getQueryContext(handle); log.info("{} cancel request on query {}", getFullyQualifiedName(), handle); boolean cancelResult = context.cancel(); if (cancelResult) { context.getLensContext().setDriverStatus(DriverQueryState.CANCELED); context.closeResult(); log.info("{} Canceled query : {}", getFullyQualifiedName(), handle); } return cancelResult; }  @Override void configure(Configuration conf, String driverType, String driverName); void init(); QueryCost calculateQueryCost(AbstractQueryContext qctx); @Override QueryCost estimate(AbstractQueryContext qctx); @Override DriverQueryPlan explain(AbstractQueryContext explainCtx); void validate(AbstractQueryContext pContext); @Override void prepare(PreparedQueryContext pContext); @Override DriverQueryPlan explainAndPrepare(PreparedQueryContext pContext); @Override void closePreparedQuery(QueryPrepareHandle handle); @Override LensResultSet execute(QueryContext context); @Override void executeAsync(QueryContext context); @Override void updateStatus(QueryContext context); @Override void closeResultSet(QueryHandle handle); @Override boolean cancelQuery(QueryHandle handle); @Override void closeQuery(QueryHandle handle); @Override void close(); @Override void registerDriverEventListener(LensEventListener<DriverEvent> driverEventListener); @Override void readExternal(ObjectInput arg0); @Override void writeExternal(ObjectOutput arg0); @Override StatusUpdateMethod getStatusUpdateMethod(); static final AtomicInteger THID; }