Search in sources :

Example 6 with ResourceGroupInfo

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

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

Aggregations

ResourceGroupInfo (com.facebook.presto.spi.resourceGroups.ResourceGroupInfo)7 ResourceGroupId (com.facebook.presto.spi.resourceGroups.ResourceGroupId)5 Test (org.testng.annotations.Test)5 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)3 DataSize (io.airlift.units.DataSize)3 MockQueryExecution (com.facebook.presto.execution.MockQueryExecution)1 RootInternalResourceGroup (com.facebook.presto.execution.resourceGroups.InternalResourceGroup.RootInternalResourceGroup)1 ResourceGroupManagerPlugin (com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin)1 QueryStateInfo.createQueryStateInfo (com.facebook.presto.server.QueryStateInfo.createQueryStateInfo)1 ResourceGroupState (com.facebook.presto.spi.resourceGroups.ResourceGroupState)1 ImmutableList (com.google.common.collect.ImmutableList)1