Search in sources :

Example 6 with ResourceGroupId

use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.

the class TestFileResourceGroupConfigurationManager method testMissing.

@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "No matching configuration found for: missing")
public void testMissing() {
    ResourceGroupConfigurationManager manager = parse("resource_groups_config.json");
    ResourceGroup missing = new TestingResourceGroup(new ResourceGroupId("missing"));
    manager.configure(missing, new SelectionContext(true, "user", Optional.empty(), 1));
}
Also used : ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) ResourceGroupConfigurationManager(com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager) SelectionContext(com.facebook.presto.spi.resourceGroups.SelectionContext) ResourceGroup(com.facebook.presto.spi.resourceGroups.ResourceGroup) Test(org.testng.annotations.Test)

Example 7 with ResourceGroupId

use of com.facebook.presto.spi.resourceGroups.ResourceGroupId 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)

Example 8 with ResourceGroupId

use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.

the class TestQueues method testRunningQuery.

@Test(timeOut = 60_000)
public void testRunningQuery() throws Exception {
    try (DistributedQueryRunner queryRunner = getSimpleQueryRunner()) {
        queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
        while (true) {
            TimeUnit.SECONDS.sleep(2);
            ResourceGroupInfo global = queryRunner.getCoordinator().getResourceGroupManager().get().getResourceGroupInfo(new ResourceGroupId(new ResourceGroupId("global"), "bi-user"));
            if (global.getSoftMemoryLimit().toBytes() > 0) {
                break;
            }
        }
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) ResourceGroupInfo(com.facebook.presto.spi.resourceGroups.ResourceGroupInfo) Test(org.testng.annotations.Test)

Example 9 with ResourceGroupId

use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.

the class InternalResourceGroupManager method submit.

@Override
public void submit(Statement statement, QueryExecution queryExecution, Executor executor) {
    checkState(configurationManager.get() != null, "configurationManager not set");
    ResourceGroupId group;
    try {
        group = selectGroup(queryExecution.getSession());
    } catch (PrestoException e) {
        queryExecution.fail(e);
        return;
    }
    createGroupIfNecessary(group, queryExecution.getSession(), executor);
    groups.get(group).run(queryExecution);
}
Also used : ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) PrestoException(com.facebook.presto.spi.PrestoException)

Example 10 with ResourceGroupId

use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.

the class TestResourceGroupIdTemplate method testExpansion.

@Test
public void testExpansion() {
    ResourceGroupIdTemplate template = new ResourceGroupIdTemplate("test.${USER}.${SOURCE}");
    ResourceGroupId expected = new ResourceGroupId(new ResourceGroupId(new ResourceGroupId("test"), "u"), "s");
    assertEquals(template.expandTemplate(new SelectionContext(true, "u", Optional.of("s"), 1)), expected);
    template = new ResourceGroupIdTemplate("test.${USER}");
    assertEquals(template.expandTemplate(new SelectionContext(true, "alice.smith", Optional.empty(), 1)), new ResourceGroupId(new ResourceGroupId("test"), "alice.smith"));
}
Also used : ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) SelectionContext(com.facebook.presto.spi.resourceGroups.SelectionContext) Test(org.testng.annotations.Test)

Aggregations

ResourceGroupId (com.facebook.presto.spi.resourceGroups.ResourceGroupId)10 Test (org.testng.annotations.Test)8 ResourceGroupInfo (com.facebook.presto.spi.resourceGroups.ResourceGroupInfo)5 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)4 SelectionContext (com.facebook.presto.spi.resourceGroups.SelectionContext)3 ResourceGroup (com.facebook.presto.spi.resourceGroups.ResourceGroup)2 ResourceGroupConfigurationManager (com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager)2 DataSize (io.airlift.units.DataSize)2 ResourceGroupManager (com.facebook.presto.execution.resourceGroups.ResourceGroupManager)1 ResourceGroupManagerPlugin (com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin)1 H2ResourceGroupsDao (com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao)1 QueryStateInfo.createQueryStateInfo (com.facebook.presto.server.QueryStateInfo.createQueryStateInfo)1 PrestoException (com.facebook.presto.spi.PrestoException)1 QueryId (com.facebook.presto.spi.QueryId)1 ImmutableList (com.google.common.collect.ImmutableList)1 Duration (io.airlift.units.Duration)1