use of com.facebook.presto.execution.QueryInfo in project presto by prestodb.
the class TestGracefulShutdown method testShutdown.
@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testShutdown() throws Exception {
Map<String, String> properties = ImmutableMap.<String, String>builder().put("node-scheduler.include-coordinator", "false").put("shutdown.grace-period", "10s").build();
try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, properties)) {
List<ListenableFuture<?>> queryFutures = new ArrayList<>();
for (int i = 0; i < 5; i++) {
queryFutures.add(executor.submit(() -> queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk")));
}
TestingPrestoServer worker = queryRunner.getServers().stream().filter(server -> !server.isCoordinator()).findFirst().get();
TaskManager taskManager = worker.getTaskManager();
// wait until tasks show up on the worker
while (taskManager.getAllTaskInfo().isEmpty()) {
MILLISECONDS.sleep(500);
}
worker.getGracefulShutdownHandler().requestShutdown();
Futures.allAsList(queryFutures).get();
List<QueryInfo> queryInfos = queryRunner.getCoordinator().getQueryManager().getAllQueryInfo();
for (QueryInfo info : queryInfos) {
assertEquals(info.getState(), FINISHED);
}
TestShutdownAction shutdownAction = (TestShutdownAction) worker.getShutdownAction();
shutdownAction.waitForShutdownComplete(SHUTDOWN_TIMEOUT_MILLIS);
assertTrue(shutdownAction.isWorkerShutdown());
}
}
Aggregations