use of org.apache.hadoop.hive.ql.scheduled.ScheduledQueryExecutionContext in project hive by apache.
the class TestScheduledQueryService method testScheduledQueryExecution.
@Test
public void testScheduledQueryExecution() throws ParseException, Exception {
IDriver driver = createDriver();
ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true).setNameFormat("SchQ %d").build());
HiveConf conf = env_setup.getTestCtx().hiveConf;
MockScheduledQueryService qService = new MockScheduledQueryService("insert into tu values(1),(2),(3),(4),(5)");
ScheduledQueryExecutionContext ctx = new ScheduledQueryExecutionContext(executor, conf, qService);
try (ScheduledQueryExecutionService sQ = ScheduledQueryExecutionService.startScheduledQueryExecutorService(ctx)) {
// Wait for the scheduled query to finish. Hopefully 30 seconds should be more than enough.
SessionState.getConsole().logInfo("Waiting for query execution to finish ...");
synchronized (qService.notifier) {
qService.notifier.wait(30000);
}
SessionState.getConsole().logInfo("Done waiting for query execution!");
}
assertThat(qService.lastProgressInfo.isSetExecutorQueryId(), is(true));
assertThat(qService.lastProgressInfo.getExecutorQueryId(), Matchers.containsString(ctx.executorHostName + "/"));
int nr = getNumRowsReturned(driver, "select 1 from tu");
assertThat(nr, Matchers.equalTo(5));
}
Aggregations