Search in sources :

Example 1 with DbSourceExactMatchSelector

use of com.facebook.presto.resourceGroups.db.DbSourceExactMatchSelector in project presto by prestodb.

the class TestReloadingResourceGroupConfigurationManager method testExactMatchSelector.

@Test
public void testExactMatchSelector() {
    H2DaoProvider daoProvider = setup("test_exact_match_selector");
    H2ResourceGroupsDao dao = daoProvider.get();
    dao.createResourceGroupsGlobalPropertiesTable();
    dao.createResourceGroupsTable();
    dao.createSelectorsTable();
    dao.createExactMatchSelectorsTable();
    dao.insertResourceGroup(1, "global", "1MB", 1000, 100, 100, "weighted", null, true, "1h", "1d", null, null, null, null, ENVIRONMENT);
    dao.insertResourceGroup(2, "sub", "2MB", 4, 3, 3, null, 5, null, null, null, null, null, null, 1L, ENVIRONMENT);
    dao.insertSelector(2, 1, null, null, null, null, null);
    dao.insertResourceGroupsGlobalProperties("cpu_quota_period", "1h");
    ReloadingResourceGroupConfig config = new ReloadingResourceGroupConfig();
    config.setExactMatchSelectorEnabled(true);
    DbManagerSpecProvider dbManagerSpecProvider = new DbManagerSpecProvider(daoProvider.get(), ENVIRONMENT, config);
    ReloadingResourceGroupConfigurationManager manager = new ReloadingResourceGroupConfigurationManager((poolId, listener) -> {
    }, config, dbManagerSpecProvider);
    manager.load();
    assertEquals(manager.getSelectors().size(), 2);
    assertTrue(manager.getSelectors().get(0) instanceof DbSourceExactMatchSelector);
    config.setExactMatchSelectorEnabled(false);
    manager = new ReloadingResourceGroupConfigurationManager((poolId, listener) -> {
    }, config, dbManagerSpecProvider);
    manager.load();
    assertEquals(manager.getSelectors().size(), 1);
    assertFalse(manager.getSelectors().get(0) instanceof DbSourceExactMatchSelector);
}
Also used : DbManagerSpecProvider(com.facebook.presto.resourceGroups.db.DbManagerSpecProvider) DEFAULT_WEIGHT(com.facebook.presto.execution.resourceGroups.InternalResourceGroup.DEFAULT_WEIGHT) MEGABYTE(io.airlift.units.DataSize.Unit.MEGABYTE) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) MINUTES(java.util.concurrent.TimeUnit.MINUTES) VariableMap(com.facebook.presto.resourceGroups.VariableMap) PrestoException(com.facebook.presto.spi.PrestoException) Duration(io.airlift.units.Duration) H2DaoProvider(com.facebook.presto.resourceGroups.db.H2DaoProvider) ResourceEstimates(com.facebook.presto.spi.session.ResourceEstimates) ResourceGroupQueryLimits(com.facebook.presto.spi.resourceGroups.ResourceGroupQueryLimits) SelectionContext(com.facebook.presto.spi.resourceGroups.SelectionContext) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) DAYS(java.util.concurrent.TimeUnit.DAYS) NO_LIMITS(com.facebook.presto.spi.resourceGroups.ResourceGroupQueryLimits.NO_LIMITS) InternalResourceGroup(com.facebook.presto.execution.resourceGroups.InternalResourceGroup) Assert.assertFalse(org.testng.Assert.assertFalse) ImmutableMap(com.google.common.collect.ImmutableMap) Assert.fail(org.testng.Assert.fail) SchedulingPolicy(com.facebook.presto.spi.resourceGroups.SchedulingPolicy) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) H2ResourceGroupsDao(com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) DataSize(io.airlift.units.DataSize) DbResourceGroupConfig(com.facebook.presto.resourceGroups.db.DbResourceGroupConfig) WEIGHTED(com.facebook.presto.spi.resourceGroups.SchedulingPolicy.WEIGHTED) DbSourceExactMatchSelector(com.facebook.presto.resourceGroups.db.DbSourceExactMatchSelector) Optional(java.util.Optional) FAIR(com.facebook.presto.spi.resourceGroups.SchedulingPolicy.FAIR) HOURS(java.util.concurrent.TimeUnit.HOURS) Assert.assertTrue(org.testng.Assert.assertTrue) H2DaoProvider(com.facebook.presto.resourceGroups.db.H2DaoProvider) H2ResourceGroupsDao(com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao) DbSourceExactMatchSelector(com.facebook.presto.resourceGroups.db.DbSourceExactMatchSelector) DbManagerSpecProvider(com.facebook.presto.resourceGroups.db.DbManagerSpecProvider) Test(org.testng.annotations.Test)

Aggregations

InternalResourceGroup (com.facebook.presto.execution.resourceGroups.InternalResourceGroup)1 DEFAULT_WEIGHT (com.facebook.presto.execution.resourceGroups.InternalResourceGroup.DEFAULT_WEIGHT)1 VariableMap (com.facebook.presto.resourceGroups.VariableMap)1 DbManagerSpecProvider (com.facebook.presto.resourceGroups.db.DbManagerSpecProvider)1 DbResourceGroupConfig (com.facebook.presto.resourceGroups.db.DbResourceGroupConfig)1 DbSourceExactMatchSelector (com.facebook.presto.resourceGroups.db.DbSourceExactMatchSelector)1 H2DaoProvider (com.facebook.presto.resourceGroups.db.H2DaoProvider)1 H2ResourceGroupsDao (com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao)1 PrestoException (com.facebook.presto.spi.PrestoException)1 ResourceGroupQueryLimits (com.facebook.presto.spi.resourceGroups.ResourceGroupQueryLimits)1 NO_LIMITS (com.facebook.presto.spi.resourceGroups.ResourceGroupQueryLimits.NO_LIMITS)1 SchedulingPolicy (com.facebook.presto.spi.resourceGroups.SchedulingPolicy)1 FAIR (com.facebook.presto.spi.resourceGroups.SchedulingPolicy.FAIR)1 WEIGHTED (com.facebook.presto.spi.resourceGroups.SchedulingPolicy.WEIGHTED)1 SelectionContext (com.facebook.presto.spi.resourceGroups.SelectionContext)1 ResourceEstimates (com.facebook.presto.spi.session.ResourceEstimates)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 MoreExecutors.directExecutor (com.google.common.util.concurrent.MoreExecutors.directExecutor)1 DataSize (io.airlift.units.DataSize)1 MEGABYTE (io.airlift.units.DataSize.Unit.MEGABYTE)1