Search in sources :

Example 41 with ResourceGroupId

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

the class TestDistributedQueuesDb method testDistributedQueue_burstTraffic.

@Test(timeOut = 2_000)
public void testDistributedQueue_burstTraffic() throws Exception {
    QueryId firstAdhocQuery = createQuery(queryRunner, 1, testSession(new Identity("user1", Optional.empty())), LONG_LASTING_QUERY);
    QueryId secondAdhocQuery = createQuery(queryRunner, 0, testSession(new Identity("user2", Optional.empty())), LONG_LASTING_QUERY);
    QueryId thirdAdhocQuery = createQuery(queryRunner, 1, testSession(new Identity("user3", Optional.empty())), LONG_LASTING_QUERY);
    QueryId fourthAdhocQuery = createQuery(queryRunner, 0, testSession(new Identity("user4", Optional.empty())), LONG_LASTING_QUERY);
    Map<ResourceGroupId, ResourceGroupRuntimeInfo> resourceGroupRuntimeInfoSnapshot;
    int globalRunningQueries = 0;
    int globalQueriedQueries = 0;
    do {
        MILLISECONDS.sleep(100);
        globalRunningQueries = 0;
        globalQueriedQueries = 0;
        for (int coordinator = 0; coordinator < 2; coordinator++) {
            resourceGroupRuntimeInfoSnapshot = queryRunner.getCoordinator(coordinator).getResourceGroupManager().get().getResourceGroupRuntimeInfosSnapshot();
            ResourceGroupRuntimeInfo resourceGroupRuntimeInfo = resourceGroupRuntimeInfoSnapshot.get(new ResourceGroupId("global"));
            if (resourceGroupRuntimeInfo != null) {
                globalRunningQueries += resourceGroupRuntimeInfo.getDescendantRunningQueries();
                globalQueriedQueries += resourceGroupRuntimeInfo.getDescendantQueuedQueries();
            }
        }
    } while (globalRunningQueries != 3 && globalQueriedQueries != 1);
}
Also used : ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) QueryId(com.facebook.presto.spi.QueryId) ResourceGroupRuntimeInfo(com.facebook.presto.execution.resourceGroups.ResourceGroupRuntimeInfo) Identity(com.facebook.presto.spi.security.Identity) Test(org.testng.annotations.Test)

Aggregations

ResourceGroupId (com.facebook.presto.spi.resourceGroups.ResourceGroupId)41 Test (org.testng.annotations.Test)31 QueryId (com.facebook.presto.spi.QueryId)12 ResourceGroupRuntimeInfo (com.facebook.presto.execution.resourceGroups.ResourceGroupRuntimeInfo)9 ResourceGroupInfo (com.facebook.presto.server.ResourceGroupInfo)5 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 Duration (io.airlift.units.Duration)5 String.format (java.lang.String.format)5 Optional (java.util.Optional)5 TestQueues.createResourceGroupId (com.facebook.presto.execution.TestQueues.createResourceGroupId)4 BasicQueryInfo (com.facebook.presto.server.BasicQueryInfo)4 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)3 DataSize (io.airlift.units.DataSize)3 HashMap (java.util.HashMap)3 SECONDS (java.util.concurrent.TimeUnit.SECONDS)3 Assert.assertEquals (org.testng.Assert.assertEquals)3 Assert.assertTrue (org.testng.Assert.assertTrue)3 Session (com.facebook.presto.Session)2 TEST_SESSION (com.facebook.presto.SessionTestUtils.TEST_SESSION)2