Search in sources :

Example 1 with QueryStateInfo

use of io.prestosql.server.QueryStateInfo in project hetu-core by openlookeng.

the class TestDistributedResourceGroup method testGetResourceGroupStateInfo.

@Test
public void testGetResourceGroupStateInfo() {
    synchronized (lock) {
        DistributedResourceGroup root = new DistributedResourceGroup(Optional.empty(), "root", (group, export) -> {
        }, directExecutor(), statestore);
        resourceGroupBasicSetUp(root, ONE_GIGABYTE, 20, 40);
        root.setSoftConcurrencyLimit(20);
        DistributedResourceGroup rootA = root.getOrCreateSubGroup("a");
        resourceGroupBasicSetUp(rootA, ONE_MEGABYTE, 10, 20);
        DistributedResourceGroup rootB = root.getOrCreateSubGroup("b");
        resourceGroupBasicSetUp(rootB, ONE_MEGABYTE, 10, 20);
        DistributedResourceGroup rootAX = rootA.getOrCreateSubGroup("x");
        resourceGroupBasicSetUp(rootAX, ONE_MEGABYTE, 10, 10);
        DistributedResourceGroup rootAY = rootA.getOrCreateSubGroup("y");
        resourceGroupBasicSetUp(rootAY, ONE_MEGABYTE, 10, 10);
        Set<MockManagedQueryExecution> queries = fillGroupTo(rootAX, ImmutableSet.of(), 5, false);
        queries.addAll(fillGroupTo(rootAY, ImmutableSet.of(), 5, false));
        queries.addAll(fillGroupTo(rootB, ImmutableSet.of(), 10, true));
        updateStateCacheStore(queries);
        root.processQueuedQueries();
        ResourceGroupInfo rootInfo = root.getFullInfo();
        assertEquals(rootInfo.getId(), root.getId());
        assertEquals(rootInfo.getState(), CAN_QUEUE);
        assertEquals(rootInfo.getSoftMemoryLimit(), root.getSoftMemoryLimit());
        assertEquals(rootInfo.getMemoryUsage(), new DataSize(0, BYTE));
        assertEquals(rootInfo.getSubGroups().size(), 2);
        assertGroupInfoEquals(rootInfo.getSubGroups().get(0), rootA.getInfo());
        assertEquals(rootInfo.getSubGroups().get(0).getId(), rootA.getId());
        assertEquals(rootInfo.getSubGroups().get(0).getState(), CAN_QUEUE);
        assertEquals(rootInfo.getSubGroups().get(0).getSoftMemoryLimit(), rootA.getSoftMemoryLimit());
        assertEquals(rootInfo.getSubGroups().get(0).getSoftReservedMemory(), rootA.getSoftReservedMemory());
        assertEquals(rootInfo.getSubGroups().get(0).getHardReservedConcurrency(), rootA.getHardReservedConcurrency());
        assertEquals(rootInfo.getSubGroups().get(0).getSchedulingWeight(), rootA.getSchedulingWeight());
        assertEquals(rootInfo.getSubGroups().get(0).getSchedulingPolicy(), rootA.getSchedulingPolicy());
        assertEquals(rootInfo.getSubGroups().get(0).getHardConcurrencyLimit(), rootA.getHardConcurrencyLimit());
        assertEquals(rootInfo.getSubGroups().get(0).getMaxQueuedQueries(), rootA.getMaxQueuedQueries());
        assertEquals(rootInfo.getSubGroups().get(0).getNumRunningQueries(), 10);
        assertEquals(rootInfo.getSubGroups().get(0).getNumQueuedQueries(), 0);
        assertGroupInfoEquals(rootInfo.getSubGroups().get(1), rootB.getInfo());
        assertEquals(rootInfo.getSubGroups().get(1).getId(), rootB.getId());
        assertEquals(rootInfo.getSubGroups().get(1).getState(), CAN_QUEUE);
        assertEquals(rootInfo.getSubGroups().get(1).getSoftMemoryLimit(), rootB.getSoftMemoryLimit());
        assertEquals(rootInfo.getSubGroups().get(1).getSoftReservedMemory(), rootA.getSoftReservedMemory());
        assertEquals(rootInfo.getSubGroups().get(1).getHardReservedConcurrency(), rootA.getHardReservedConcurrency());
        assertEquals(rootInfo.getSubGroups().get(1).getSchedulingWeight(), rootA.getSchedulingWeight());
        assertEquals(rootInfo.getSubGroups().get(1).getSchedulingPolicy(), rootA.getSchedulingPolicy());
        assertEquals(rootInfo.getSubGroups().get(1).getHardConcurrencyLimit(), rootB.getHardConcurrencyLimit());
        assertEquals(rootInfo.getSubGroups().get(1).getMaxQueuedQueries(), rootB.getMaxQueuedQueries());
        assertEquals(rootInfo.getSubGroups().get(1).getNumEligibleSubGroups(), 0);
        assertEquals(rootInfo.getSubGroups().get(1).getNumRunningQueries(), 10);
        assertEquals(rootInfo.getSubGroups().get(1).getNumQueuedQueries(), 0);
        assertEquals(rootInfo.getSoftConcurrencyLimit(), root.getSoftConcurrencyLimit());
        assertEquals(rootInfo.getHardConcurrencyLimit(), root.getHardConcurrencyLimit());
        assertEquals(rootInfo.getMaxQueuedQueries(), root.getMaxQueuedQueries());
        assertEquals(rootInfo.getNumQueuedQueries(), 0);
        assertEquals(rootInfo.getRunningQueries().size(), 20);
        QueryStateInfo queryInfo = rootInfo.getRunningQueries().get(0);
        assertEquals(queryInfo.getResourceGroupId(), Optional.of(rootAX.getId()));
        StateCacheStore.get().resetCachedStates();
    }
}
Also used : MockManagedQueryExecution(io.prestosql.execution.MockManagedQueryExecution) DataSize(io.airlift.units.DataSize) QueryStateInfo(io.prestosql.server.QueryStateInfo) ResourceGroupInfo(io.prestosql.server.ResourceGroupInfo) Test(org.testng.annotations.Test)

Example 2 with QueryStateInfo

use of io.prestosql.server.QueryStateInfo in project hetu-core by openlookeng.

the class TestResourceGroups method testGetResourceGroupStateInfo.

@Test
public void testGetResourceGroupStateInfo() {
    InternalResourceGroup root = new InternalResourceGroup(Optional.empty(), "root", (group, export) -> {
    }, directExecutor());
    root.setSoftMemoryLimit(new DataSize(1, GIGABYTE));
    root.setMaxQueuedQueries(40);
    root.setHardConcurrencyLimit(10);
    root.setSchedulingPolicy(WEIGHTED);
    InternalResourceGroup rootA = root.getOrCreateSubGroup("a");
    rootA.setSoftMemoryLimit(new DataSize(10, MEGABYTE));
    rootA.setMaxQueuedQueries(20);
    rootA.setHardConcurrencyLimit(0);
    InternalResourceGroup rootB = root.getOrCreateSubGroup("b");
    rootB.setSoftMemoryLimit(new DataSize(5, MEGABYTE));
    rootB.setMaxQueuedQueries(20);
    rootB.setHardConcurrencyLimit(1);
    rootB.setSchedulingWeight(2);
    rootB.setSchedulingPolicy(QUERY_PRIORITY);
    InternalResourceGroup rootAX = rootA.getOrCreateSubGroup("x");
    rootAX.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    rootAX.setMaxQueuedQueries(10);
    rootAX.setHardConcurrencyLimit(10);
    InternalResourceGroup rootAY = rootA.getOrCreateSubGroup("y");
    rootAY.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    rootAY.setMaxQueuedQueries(10);
    rootAY.setHardConcurrencyLimit(10);
    Set<MockManagedQueryExecution> queries = fillGroupTo(rootAX, ImmutableSet.of(), 5, false);
    queries.addAll(fillGroupTo(rootAY, ImmutableSet.of(), 5, false));
    queries.addAll(fillGroupTo(rootB, ImmutableSet.of(), 10, true));
    ResourceGroupInfo rootInfo = root.getFullInfo();
    assertEquals(rootInfo.getId(), root.getId());
    assertEquals(rootInfo.getState(), CAN_RUN);
    assertEquals(rootInfo.getSoftMemoryLimit(), root.getSoftMemoryLimit());
    assertEquals(rootInfo.getMemoryUsage(), new DataSize(0, BYTE));
    assertEquals(rootInfo.getSubGroups().size(), 2);
    assertGroupInfoEquals(rootInfo.getSubGroups().get(0), rootA.getInfo());
    assertEquals(rootInfo.getSubGroups().get(0).getId(), rootA.getId());
    assertEquals(rootInfo.getSubGroups().get(0).getState(), CAN_QUEUE);
    assertEquals(rootInfo.getSubGroups().get(0).getSoftMemoryLimit(), rootA.getSoftMemoryLimit());
    assertEquals(rootInfo.getSubGroups().get(0).getHardConcurrencyLimit(), rootA.getHardConcurrencyLimit());
    assertEquals(rootInfo.getSubGroups().get(0).getMaxQueuedQueries(), rootA.getMaxQueuedQueries());
    assertEquals(rootInfo.getSubGroups().get(0).getNumEligibleSubGroups(), 2);
    assertEquals(rootInfo.getSubGroups().get(0).getNumRunningQueries(), 0);
    assertEquals(rootInfo.getSubGroups().get(0).getNumQueuedQueries(), 10);
    assertGroupInfoEquals(rootInfo.getSubGroups().get(1), rootB.getInfo());
    assertEquals(rootInfo.getSubGroups().get(1).getId(), rootB.getId());
    assertEquals(rootInfo.getSubGroups().get(1).getState(), CAN_QUEUE);
    assertEquals(rootInfo.getSubGroups().get(1).getSoftMemoryLimit(), rootB.getSoftMemoryLimit());
    assertEquals(rootInfo.getSubGroups().get(1).getHardConcurrencyLimit(), rootB.getHardConcurrencyLimit());
    assertEquals(rootInfo.getSubGroups().get(1).getMaxQueuedQueries(), rootB.getMaxQueuedQueries());
    assertEquals(rootInfo.getSubGroups().get(1).getNumEligibleSubGroups(), 0);
    assertEquals(rootInfo.getSubGroups().get(1).getNumRunningQueries(), 1);
    assertEquals(rootInfo.getSubGroups().get(1).getNumQueuedQueries(), 9);
    assertEquals(rootInfo.getSoftConcurrencyLimit(), root.getSoftConcurrencyLimit());
    assertEquals(rootInfo.getHardConcurrencyLimit(), root.getHardConcurrencyLimit());
    assertEquals(rootInfo.getMaxQueuedQueries(), root.getMaxQueuedQueries());
    assertEquals(rootInfo.getNumQueuedQueries(), 19);
    assertEquals(rootInfo.getRunningQueries().size(), 1);
    QueryStateInfo queryInfo = rootInfo.getRunningQueries().get(0);
    assertEquals(queryInfo.getResourceGroupId(), Optional.of(rootB.getId()));
}
Also used : MockManagedQueryExecution(io.prestosql.execution.MockManagedQueryExecution) DataSize(io.airlift.units.DataSize) QueryStateInfo(io.prestosql.server.QueryStateInfo) ResourceGroupInfo(io.prestosql.server.ResourceGroupInfo) Test(org.testng.annotations.Test)

Aggregations

DataSize (io.airlift.units.DataSize)2 MockManagedQueryExecution (io.prestosql.execution.MockManagedQueryExecution)2 QueryStateInfo (io.prestosql.server.QueryStateInfo)2 ResourceGroupInfo (io.prestosql.server.ResourceGroupInfo)2 Test (org.testng.annotations.Test)2