Search in sources :

Example 6 with DbManagerSpecProvider

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

the class TestReloadingResourceGroupConfigurationManager method testRefreshInterval.

@Test
public void testRefreshInterval() {
    H2DaoProvider daoProvider = setup("selectors");
    H2ResourceGroupsDao dao = daoProvider.get();
    dao.createResourceGroupsTable();
    dao.createSelectorsTable();
    dao.insertResourceGroup(1, "global", "100%", 100, 100, 100, null, null, null, null, null, null, null, null, null, ENVIRONMENT);
    DbManagerSpecProvider dbManagerSpecProvider = new DbManagerSpecProvider(daoProvider.get(), ENVIRONMENT, new ReloadingResourceGroupConfig());
    ReloadingResourceGroupConfigurationManager manager = new ReloadingResourceGroupConfigurationManager((poolId, listener) -> {
    }, new ReloadingResourceGroupConfig().setMaxRefreshInterval(Duration.valueOf("1ms")), dbManagerSpecProvider);
    dao.dropSelectorsTable();
    manager.load();
    try {
        manager.getSelectors();
        fail("Expected unavailable configuration exception");
    } catch (Exception e) {
        assertTrue(e.getMessage().startsWith("Resource group configuration cannot be fetched from source."));
    }
    try {
        manager.getRootGroups();
        fail("Expected unavailable configuration exception");
    } catch (Exception e) {
        assertTrue(e.getMessage().startsWith("Resource group configuration cannot be fetched from source."));
    }
    manager.destroy();
}
Also used : H2DaoProvider(com.facebook.presto.resourceGroups.db.H2DaoProvider) H2ResourceGroupsDao(com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao) PrestoException(com.facebook.presto.spi.PrestoException) DbManagerSpecProvider(com.facebook.presto.resourceGroups.db.DbManagerSpecProvider) Test(org.testng.annotations.Test)

Aggregations

DbManagerSpecProvider (com.facebook.presto.resourceGroups.db.DbManagerSpecProvider)6 H2DaoProvider (com.facebook.presto.resourceGroups.db.H2DaoProvider)6 H2ResourceGroupsDao (com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao)6 Test (org.testng.annotations.Test)6 InternalResourceGroup (com.facebook.presto.execution.resourceGroups.InternalResourceGroup)4 VariableMap (com.facebook.presto.resourceGroups.VariableMap)4 ResourceGroupQueryLimits (com.facebook.presto.spi.resourceGroups.ResourceGroupQueryLimits)3 DataSize (io.airlift.units.DataSize)3 Duration (io.airlift.units.Duration)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 PrestoException (com.facebook.presto.spi.PrestoException)2 DEFAULT_WEIGHT (com.facebook.presto.execution.resourceGroups.InternalResourceGroup.DEFAULT_WEIGHT)1 DbResourceGroupConfig (com.facebook.presto.resourceGroups.db.DbResourceGroupConfig)1 DbSourceExactMatchSelector (com.facebook.presto.resourceGroups.db.DbSourceExactMatchSelector)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