Search in sources :

Example 1 with ResourceGroupManagerPlugin

use of com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin in project presto by prestodb.

the class TestQueues method testBasic.

private void testBasic(boolean resourceGroups) throws Exception {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    if (resourceGroups) {
        builder.put("experimental.resource-groups-enabled", "true");
    } else {
        builder.put("query.queue-config-file", getResourceFilePath("queue_config_dashboard.json"));
    }
    Map<String, String> properties = builder.build();
    try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
        queryRunner.installPlugin(new ResourceGroupManagerPlugin());
        queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
        QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
        // submit first "dashboard" query
        QueryId firstDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
        // wait for the first "dashboard" query to start
        waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
        // submit second "dashboard" query
        QueryId secondDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
        // wait for the second "dashboard" query to be queued ("dashboard.${USER}" queue strategy only allows one "dashboard" query to be accepted for execution)
        waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
        // submit first non "dashboard" query
        QueryId firstNonDashboardQuery = createQuery(queryRunner, newSession(), LONG_LASTING_QUERY);
        // wait for the first non "dashboard" query to start
        waitForQueryState(queryRunner, firstNonDashboardQuery, RUNNING);
        // submit second non "dashboard" query
        QueryId secondNonDashboardQuery = createQuery(queryRunner, newSession(), LONG_LASTING_QUERY);
        // wait for the second non "dashboard" query to start
        waitForQueryState(queryRunner, secondNonDashboardQuery, RUNNING);
        // cancel first "dashboard" query, second "dashboard" query and second non "dashboard" query should start running
        cancelQuery(queryRunner, firstDashboardQuery);
        waitForQueryState(queryRunner, firstDashboardQuery, FAILED);
        waitForQueryState(queryRunner, secondDashboardQuery, RUNNING);
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) QueryId(com.facebook.presto.spi.QueryId) ResourceGroupManagerPlugin(com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with ResourceGroupManagerPlugin

use of com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin in project presto by prestodb.

the class TestQueues method testRejection.

private void testRejection(boolean resourceGroups) throws Exception {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    if (resourceGroups) {
        builder.put("experimental.resource-groups-enabled", "true");
    } else {
        builder.put("query.queue-config-file", getResourceFilePath("queue_config_dashboard.json"));
    }
    Map<String, String> properties = builder.build();
    try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
        queryRunner.installPlugin(new ResourceGroupManagerPlugin());
        queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
        QueryId queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
        waitForQueryState(queryRunner, queryId, FAILED);
        QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
        assertEquals(queryManager.getQueryInfo(queryId).getErrorCode(), QUERY_REJECTED.toErrorCode());
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) QueryId(com.facebook.presto.spi.QueryId) ResourceGroupManagerPlugin(com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 3 with ResourceGroupManagerPlugin

use of com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin in project presto by prestodb.

the class TestQueues method testTwoQueriesAtSameTime.

private void testTwoQueriesAtSameTime(boolean resourceGroups) throws Exception {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    if (resourceGroups) {
        builder.put("experimental.resource-groups-enabled", "true");
    } else {
        builder.put("query.queue-config-file", getResourceFilePath("queue_config_dashboard.json"));
    }
    Map<String, String> properties = builder.build();
    try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
        queryRunner.installPlugin(new ResourceGroupManagerPlugin());
        queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
        QueryId firstDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
        QueryId secondDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
        ImmutableSet<QueryState> queuedOrRunning = ImmutableSet.of(QUEUED, RUNNING);
        waitForQueryState(queryRunner, firstDashboardQuery, queuedOrRunning);
        waitForQueryState(queryRunner, secondDashboardQuery, queuedOrRunning);
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) QueryId(com.facebook.presto.spi.QueryId) ResourceGroupManagerPlugin(com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 4 with ResourceGroupManagerPlugin

use of com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin in project presto by prestodb.

the class TestQueues method testTooManyQueries.

private void testTooManyQueries(boolean resourceGroups) throws Exception {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    if (resourceGroups) {
        builder.put("experimental.resource-groups-enabled", "true");
    } else {
        builder.put("query.queue-config-file", getResourceFilePath("queue_config_dashboard.json"));
    }
    Map<String, String> properties = builder.build();
    try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
        queryRunner.installPlugin(new ResourceGroupManagerPlugin());
        queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
        QueryId firstDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
        waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
        QueryId secondDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
        waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
        QueryId thirdDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
        waitForQueryState(queryRunner, thirdDashboardQuery, FAILED);
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) QueryId(com.facebook.presto.spi.QueryId) ResourceGroupManagerPlugin(com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 5 with ResourceGroupManagerPlugin

use of com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin in project presto by prestodb.

the class TestResourceGroupIntegration method testMemoryFraction.

@Test
public void testMemoryFraction() throws Exception {
    try (DistributedQueryRunner queryRunner = createQueryRunner(ImmutableMap.of(), ImmutableMap.of("experimental.resource-groups-enabled", "true"))) {
        queryRunner.installPlugin(new ResourceGroupManagerPlugin());
        queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_memory_percentage.json")));
        queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
        long startTime = System.nanoTime();
        while (true) {
            SECONDS.sleep(1);
            ResourceGroupInfo global = queryRunner.getCoordinator().getResourceGroupManager().get().getResourceGroupInfo(new ResourceGroupId("global"));
            if (global.getSoftMemoryLimit().toBytes() > 0) {
                break;
            }
            assertLessThan(nanosSince(startTime).roundTo(SECONDS), 60L);
        }
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) ResourceGroupManagerPlugin(com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin) ResourceGroupInfo(com.facebook.presto.spi.resourceGroups.ResourceGroupInfo) Test(org.testng.annotations.Test)

Aggregations

ResourceGroupManagerPlugin (com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin)5 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)5 QueryId (com.facebook.presto.spi.QueryId)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 ResourceGroupId (com.facebook.presto.spi.resourceGroups.ResourceGroupId)1 ResourceGroupInfo (com.facebook.presto.spi.resourceGroups.ResourceGroupInfo)1 Test (org.testng.annotations.Test)1