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);
}
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations