use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestFileResourceGroupConfigurationManager method testMissing.
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "No matching configuration found for: missing")
public void testMissing() {
ResourceGroupConfigurationManager manager = parse("resource_groups_config.json");
ResourceGroup missing = new TestingResourceGroup(new ResourceGroupId("missing"));
manager.configure(missing, new SelectionContext(true, "user", Optional.empty(), 1));
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId 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);
}
}
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId 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;
}
}
}
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class InternalResourceGroupManager method submit.
@Override
public void submit(Statement statement, QueryExecution queryExecution, Executor executor) {
checkState(configurationManager.get() != null, "configurationManager not set");
ResourceGroupId group;
try {
group = selectGroup(queryExecution.getSession());
} catch (PrestoException e) {
queryExecution.fail(e);
return;
}
createGroupIfNecessary(group, queryExecution.getSession(), executor);
groups.get(group).run(queryExecution);
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestResourceGroupIdTemplate method testExpansion.
@Test
public void testExpansion() {
ResourceGroupIdTemplate template = new ResourceGroupIdTemplate("test.${USER}.${SOURCE}");
ResourceGroupId expected = new ResourceGroupId(new ResourceGroupId(new ResourceGroupId("test"), "u"), "s");
assertEquals(template.expandTemplate(new SelectionContext(true, "u", Optional.of("s"), 1)), expected);
template = new ResourceGroupIdTemplate("test.${USER}");
assertEquals(template.expandTemplate(new SelectionContext(true, "alice.smith", Optional.empty(), 1)), new ResourceGroupId(new ResourceGroupId("test"), "alice.smith"));
}
Aggregations