Search in sources :

Example 6 with SelectionContext

use of com.facebook.presto.spi.resourceGroups.SelectionContext 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"));
}
Also used : ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) SelectionContext(com.facebook.presto.spi.resourceGroups.SelectionContext) Test(org.testng.annotations.Test)

Example 7 with SelectionContext

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

the class TestDbResourceGroupConfigurationManager method testMissing.

@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "No matching configuration found for: missing")
public void testMissing() {
    H2DaoProvider daoProvider = setup("test_missing");
    H2ResourceGroupsDao dao = daoProvider.get();
    dao.createResourceGroupsGlobalPropertiesTable();
    dao.createResourceGroupsTable();
    dao.createSelectorsTable();
    dao.insertResourceGroup(1, "global", "1MB", 1000, 100, "weighted", null, true, "1h", "1d", null);
    dao.insertResourceGroup(2, "sub", "2MB", 4, 3, null, 5, null, null, null, 1L);
    dao.insertResourceGroupsGlobalProperties("cpu_quota_period", "1h");
    dao.insertSelector(2, null, null);
    DbResourceGroupConfigurationManager manager = new DbResourceGroupConfigurationManager((poolId, listener) -> {
    }, daoProvider.get());
    InternalResourceGroup missing = new InternalResourceGroup.RootInternalResourceGroup("missing", (group, export) -> {
    }, directExecutor());
    manager.configure(missing, new SelectionContext(true, "user", Optional.empty(), 1));
}
Also used : InternalResourceGroup(com.facebook.presto.execution.resourceGroups.InternalResourceGroup) SelectionContext(com.facebook.presto.spi.resourceGroups.SelectionContext) Test(org.testng.annotations.Test)

Aggregations

SelectionContext (com.facebook.presto.spi.resourceGroups.SelectionContext)7 Test (org.testng.annotations.Test)6 InternalResourceGroup (com.facebook.presto.execution.resourceGroups.InternalResourceGroup)3 ResourceGroupId (com.facebook.presto.spi.resourceGroups.ResourceGroupId)3 Duration (io.airlift.units.Duration)3 ResourceGroup (com.facebook.presto.spi.resourceGroups.ResourceGroup)2 ResourceGroupConfigurationManager (com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 RootInternalResourceGroup (com.facebook.presto.execution.resourceGroups.InternalResourceGroup.RootInternalResourceGroup)1 DataSize (io.airlift.units.DataSize)1