Search in sources :

Example 1 with ResourceGroupInfo

use of com.facebook.presto.server.ResourceGroupInfo in project presto by prestodb.

the class TestResourceGroupIntegration method testPathToRoot.

@Test
public void testPathToRoot() throws Exception {
    try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder().build()) {
        queryRunner.installPlugin(new ResourceGroupManagerPlugin());
        InternalResourceGroupManager<?> manager = getResourceGroupManager(queryRunner);
        manager.setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
        queryRunner.execute(testSessionBuilder().setCatalog("tpch").setSchema("tiny").setSource("dashboard-foo").build(), "SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
        List<ResourceGroupInfo> path = manager.getPathToRoot(new ResourceGroupId(new ResourceGroupId(new ResourceGroupId("global"), "user-user"), "dashboard-user"));
        assertEquals(path.size(), 3);
        assertTrue(path.get(1).getSubGroups() != null);
        assertEquals(path.get(2).getId(), new ResourceGroupId("global"));
        assertEquals(path.get(2).getHardConcurrencyLimit(), 100);
        assertEquals(path.get(2).getRunningQueries(), null);
    }
}
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.server.ResourceGroupInfo) Test(org.testng.annotations.Test)

Example 2 with ResourceGroupInfo

use of com.facebook.presto.server.ResourceGroupInfo in project presto by prestodb.

the class TestQueuesDb method testRunningQuery.

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

Example 3 with ResourceGroupInfo

use of com.facebook.presto.server.ResourceGroupInfo in project presto by prestodb.

the class TestResourceGroups method testGetInfo.

@Test
public void testGetInfo() {
    RootInternalResourceGroup root = new RootInternalResourceGroup("root", (group, export) -> {
    }, directExecutor(), ignored -> Optional.empty(), rg -> false);
    root.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    root.setMaxQueuedQueries(40);
    // Start with zero capacity, so that nothing starts running until we've added all the queries
    root.setHardConcurrencyLimit(0);
    root.setSchedulingPolicy(WEIGHTED);
    InternalResourceGroup rootA = root.getOrCreateSubGroup("a", true);
    rootA.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    rootA.setMaxQueuedQueries(20);
    rootA.setHardConcurrencyLimit(2);
    InternalResourceGroup rootB = root.getOrCreateSubGroup("b", true);
    rootB.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    rootB.setMaxQueuedQueries(20);
    rootB.setHardConcurrencyLimit(2);
    rootB.setSchedulingWeight(2);
    rootB.setSchedulingPolicy(QUERY_PRIORITY);
    InternalResourceGroup rootAX = rootA.getOrCreateSubGroup("x", true);
    rootAX.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    rootAX.setMaxQueuedQueries(10);
    rootAX.setHardConcurrencyLimit(10);
    InternalResourceGroup rootAY = rootA.getOrCreateSubGroup("y", true);
    rootAY.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    rootAY.setMaxQueuedQueries(10);
    rootAY.setHardConcurrencyLimit(10);
    InternalResourceGroup rootBX = rootB.getOrCreateSubGroup("x", true);
    rootBX.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    rootBX.setMaxQueuedQueries(10);
    rootBX.setHardConcurrencyLimit(10);
    InternalResourceGroup rootBY = rootB.getOrCreateSubGroup("y", true);
    rootBY.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    rootBY.setMaxQueuedQueries(10);
    rootBY.setHardConcurrencyLimit(10);
    // Queue 40 queries (= maxQueuedQueries (40) + maxRunningQueries (0))
    Set<MockManagedQueryExecution> queries = fillGroupTo(rootAX, ImmutableSet.of(), 10, false);
    queries.addAll(fillGroupTo(rootAY, ImmutableSet.of(), 10, false));
    queries.addAll(fillGroupTo(rootBX, ImmutableSet.of(), 10, true));
    queries.addAll(fillGroupTo(rootBY, ImmutableSet.of(), 10, true));
    ResourceGroupInfo info = root.getInfo();
    assertEquals(info.getNumRunningQueries(), 0);
    assertEquals(info.getNumQueuedQueries(), 40);
    // root.maxRunningQueries = 4, root.a.maxRunningQueries = 2, root.b.maxRunningQueries = 2. Will have 4 queries running and 36 left queued.
    root.setHardConcurrencyLimit(4);
    root.processQueuedQueries();
    info = root.getInfo();
    assertEquals(info.getNumRunningQueries(), 4);
    assertEquals(info.getNumQueuedQueries(), 36);
    // Complete running queries
    Iterator<MockManagedQueryExecution> iterator = queries.iterator();
    while (iterator.hasNext()) {
        MockManagedQueryExecution query = iterator.next();
        if (query.getState() == RUNNING) {
            query.complete();
            iterator.remove();
        }
    }
    // 4 more queries start running, 32 left queued.
    root.processQueuedQueries();
    info = root.getInfo();
    assertEquals(info.getNumRunningQueries(), 4);
    assertEquals(info.getNumQueuedQueries(), 32);
    // root.maxRunningQueries = 10, root.a.maxRunningQueries = 2, root.b.maxRunningQueries = 2. Still only have 4 running queries and 32 left queued.
    root.setHardConcurrencyLimit(10);
    root.processQueuedQueries();
    info = root.getInfo();
    assertEquals(info.getNumRunningQueries(), 4);
    assertEquals(info.getNumQueuedQueries(), 32);
    // root.maxRunningQueries = 10, root.a.maxRunningQueries = 2, root.b.maxRunningQueries = 10. Will have 10 running queries and 26 left queued.
    rootB.setHardConcurrencyLimit(10);
    root.processQueuedQueries();
    info = root.getInfo();
    assertEquals(info.getNumRunningQueries(), 10);
    assertEquals(info.getNumQueuedQueries(), 26);
}
Also used : RootInternalResourceGroup(com.facebook.presto.execution.resourceGroups.InternalResourceGroup.RootInternalResourceGroup) RootInternalResourceGroup(com.facebook.presto.execution.resourceGroups.InternalResourceGroup.RootInternalResourceGroup) MockManagedQueryExecution(com.facebook.presto.execution.MockManagedQueryExecution) DataSize(io.airlift.units.DataSize) ResourceGroupInfo(com.facebook.presto.server.ResourceGroupInfo) Test(org.testng.annotations.Test)

Example 4 with ResourceGroupInfo

use of com.facebook.presto.server.ResourceGroupInfo in project presto by prestodb.

the class TestThriftResourceGroupInfo method testRoundTripSerializeTCompactProtocol.

@Test(dataProvider = "codecCombinations")
public void testRoundTripSerializeTCompactProtocol(ThriftCodec<ResourceGroupInfo> readCodec, ThriftCodec<ResourceGroupInfo> writeCodec) throws Exception {
    ResourceGroupInfo groupInfo = getRoundTripSerialize(readCodec, writeCodec, TCompactProtocol::new);
    assertSerde(groupInfo);
}
Also used : TCompactProtocol(com.facebook.drift.protocol.TCompactProtocol) ResourceGroupInfo(com.facebook.presto.server.ResourceGroupInfo) Test(org.testng.annotations.Test)

Example 5 with ResourceGroupInfo

use of com.facebook.presto.server.ResourceGroupInfo in project presto by prestodb.

the class TestThriftResourceGroupInfo method setUp.

@BeforeMethod
public void setUp() {
    setUpQueryProgressStats();
    setUpQueryStateInfoList();
    List<ResourceGroupInfo> subGroups = new ArrayList<>();
    ResourceGroupInfo subResourceGroupInfo1 = getResourceGroupInfo(FAKE_SUB_RESOURCE_GROUP_ID_1, null, null);
    ResourceGroupInfo subResourceGroupInfo2 = getResourceGroupInfo(FAKE_SUB_RESOURCE_GROUP_ID_2, null, null);
    ResourceGroupInfo subResourceGroupInfo3 = getResourceGroupInfo(FAKE_SUB_RESOURCE_GROUP_ID_3, null, null);
    subGroups.add(subResourceGroupInfo1);
    subGroups.add(subResourceGroupInfo2);
    subGroups.add(subResourceGroupInfo3);
    resourceGroupInfo = getResourceGroupInfo(FAKE_RESOURCE_GROUP_ID_PARENT, subGroups, queryStateInfoList);
}
Also used : ArrayList(java.util.ArrayList) ResourceGroupInfo(com.facebook.presto.server.ResourceGroupInfo) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

ResourceGroupInfo (com.facebook.presto.server.ResourceGroupInfo)12 Test (org.testng.annotations.Test)9 ResourceGroupId (com.facebook.presto.spi.resourceGroups.ResourceGroupId)4 RootInternalResourceGroup (com.facebook.presto.execution.resourceGroups.InternalResourceGroup.RootInternalResourceGroup)3 DataSize (io.airlift.units.DataSize)3 UnexpectedResponseException (com.facebook.airlift.http.client.UnexpectedResponseException)2 MockManagedQueryExecution (com.facebook.presto.execution.MockManagedQueryExecution)2 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)2 JettyHttpClient (com.facebook.airlift.http.client.jetty.JettyHttpClient)1 JsonCodec (com.facebook.airlift.json.JsonCodec)1 Closeables.closeQuietly (com.facebook.airlift.testing.Closeables.closeQuietly)1 TBinaryProtocol (com.facebook.drift.protocol.TBinaryProtocol)1 TCompactProtocol (com.facebook.drift.protocol.TCompactProtocol)1 TFacebookCompactProtocol (com.facebook.drift.protocol.TFacebookCompactProtocol)1 TestQueues.createResourceGroupId (com.facebook.presto.execution.TestQueues.createResourceGroupId)1 AllNodes (com.facebook.presto.metadata.AllNodes)1 InternalNode (com.facebook.presto.metadata.InternalNode)1 FileResourceGroupConfigurationManagerFactory (com.facebook.presto.resourceGroups.FileResourceGroupConfigurationManagerFactory)1 ResourceGroupManagerPlugin (com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin)1 QueryStateInfo (com.facebook.presto.server.QueryStateInfo)1