Search in sources :

Example 11 with QueryInfo

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());
    }
}
Also used : TaskManager(com.facebook.presto.execution.TaskManager) ArrayList(java.util.ArrayList) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) TestShutdownAction(com.facebook.presto.server.testing.TestingPrestoServer.TestShutdownAction) QueryInfo(com.facebook.presto.execution.QueryInfo) Test(org.testng.annotations.Test)

Aggregations

QueryInfo (com.facebook.presto.execution.QueryInfo)11 Test (org.testng.annotations.Test)5 TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)4 QueryId (com.facebook.presto.spi.QueryId)4 QueryStats (com.facebook.presto.execution.QueryStats)3 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)3 ArrayList (java.util.ArrayList)3 StageInfo (com.facebook.presto.execution.StageInfo)2 TaskInfo (com.facebook.presto.execution.TaskInfo)2 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 FailureInfo (com.facebook.presto.client.FailureInfo)1 NodeVersion (com.facebook.presto.client.NodeVersion)1 QueryResults (com.facebook.presto.client.QueryResults)1 ConnectorId (com.facebook.presto.connector.ConnectorId)1 EventListenerManager (com.facebook.presto.eventlistener.EventListenerManager)1 Column (com.facebook.presto.execution.Column)1 Input (com.facebook.presto.execution.Input)1 TaskId (com.facebook.presto.execution.TaskId)1 TaskManager (com.facebook.presto.execution.TaskManager)1