use of com.facebook.presto.execution.resourceGroups.InternalResourceGroup in project presto by prestodb.
the class TestDbResourceGroupConfigurationManager method testConfiguration.
@Test
public void testConfiguration() {
H2DaoProvider daoProvider = setup("test_configuration");
H2ResourceGroupsDao dao = daoProvider.get();
dao.createResourceGroupsGlobalPropertiesTable();
dao.createResourceGroupsTable();
dao.createSelectorsTable();
dao.insertResourceGroupsGlobalProperties("cpu_quota_period", "1h");
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.insertSelector(2, null, null);
DbResourceGroupConfigurationManager manager = new DbResourceGroupConfigurationManager((poolId, listener) -> {
}, daoProvider.get());
AtomicBoolean exported = new AtomicBoolean();
InternalResourceGroup global = new InternalResourceGroup.RootInternalResourceGroup("global", (group, export) -> exported.set(export), directExecutor());
manager.configure(global, new SelectionContext(true, "user", Optional.empty(), 1));
assertEqualsResourceGroup(global, "1MB", 1000, 100, WEIGHTED, DEFAULT_WEIGHT, true, new Duration(1, HOURS), new Duration(1, DAYS));
exported.set(false);
InternalResourceGroup sub = global.getOrCreateSubGroup("sub");
manager.configure(sub, new SelectionContext(true, "user", Optional.empty(), 1));
assertEqualsResourceGroup(sub, "2MB", 4, 3, FAIR, 5, false, new Duration(Long.MAX_VALUE, MILLISECONDS), new Duration(Long.MAX_VALUE, MILLISECONDS));
}
use of com.facebook.presto.execution.resourceGroups.InternalResourceGroup in project presto by prestodb.
the class TestDbResourceGroupConfigurationManager method testReconfig.
@Test(timeOut = 60_000)
public void testReconfig() throws Exception {
H2DaoProvider daoProvider = setup("test_reconfig");
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.insertSelector(2, null, null);
dao.insertResourceGroupsGlobalProperties("cpu_quota_period", "1h");
DbResourceGroupConfigurationManager manager = new DbResourceGroupConfigurationManager((poolId, listener) -> {
}, daoProvider.get());
manager.start();
AtomicBoolean exported = new AtomicBoolean();
InternalResourceGroup global = new InternalResourceGroup.RootInternalResourceGroup("global", (group, export) -> exported.set(export), directExecutor());
manager.configure(global, new SelectionContext(true, "user", Optional.empty(), 1));
InternalResourceGroup globalSub = global.getOrCreateSubGroup("sub");
manager.configure(globalSub, new SelectionContext(true, "user", Optional.empty(), 1));
// Verify record exists
assertEqualsResourceGroup(globalSub, "2MB", 4, 3, FAIR, 5, false, new Duration(Long.MAX_VALUE, MILLISECONDS), new Duration(Long.MAX_VALUE, MILLISECONDS));
dao.updateResourceGroup(2, "sub", "3MB", 2, 1, "weighted", 6, true, "1h", "1d", 1L);
do {
MILLISECONDS.sleep(500);
} while (globalSub.getJmxExport() == false);
// Verify update
assertEqualsResourceGroup(globalSub, "3MB", 2, 1, WEIGHTED, 6, true, new Duration(1, HOURS), new Duration(1, DAYS));
// Verify delete
dao.deleteSelectors(2);
dao.deleteResourceGroup(2);
do {
MILLISECONDS.sleep(500);
} while (globalSub.getMaxQueuedQueries() != 0 || globalSub.getMaxRunningQueries() != 0);
}
use of com.facebook.presto.execution.resourceGroups.InternalResourceGroup in project presto by prestodb.
the class TestReloadingResourceGroupConfigurationManager 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, 100, "weighted", null, true, "1h", "1d", "1h", "1MB", "1h", null, ENVIRONMENT);
dao.insertResourceGroup(2, "sub", "2MB", 4, 3, 3, null, 5, null, null, null, null, null, null, 1L, ENVIRONMENT);
dao.insertResourceGroupsGlobalProperties("cpu_quota_period", "1h");
dao.insertSelector(2, 1, null, null, null, null, null);
DbManagerSpecProvider dbManagerSpecProvider = new DbManagerSpecProvider(daoProvider.get(), ENVIRONMENT, new ReloadingResourceGroupConfig());
ReloadingResourceGroupConfigurationManager manager = new ReloadingResourceGroupConfigurationManager((poolId, listener) -> {
}, new ReloadingResourceGroupConfig(), dbManagerSpecProvider);
InternalResourceGroup missing = new InternalResourceGroup.RootInternalResourceGroup("missing", (group, export) -> {
}, directExecutor(), ignored -> Optional.empty(), rg -> false);
manager.configure(missing, new SelectionContext<>(missing.getId(), new VariableMap(ImmutableMap.of("USER", "user"))));
}
use of com.facebook.presto.execution.resourceGroups.InternalResourceGroup in project presto by prestodb.
the class TestQueryStateInfo method testQueryStateInfo.
@Test
public void testQueryStateInfo() {
InternalResourceGroup.RootInternalResourceGroup root = new InternalResourceGroup.RootInternalResourceGroup("root", (group, export) -> {
}, directExecutor(), ignored -> Optional.empty(), rg -> false);
root.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
root.setMaxQueuedQueries(40);
root.setHardConcurrencyLimit(0);
root.setSchedulingPolicy(WEIGHTED);
InternalResourceGroup rootA = root.getOrCreateSubGroup("a", true);
rootA.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
rootA.setMaxQueuedQueries(20);
rootA.setHardConcurrencyLimit(0);
InternalResourceGroup rootAX = rootA.getOrCreateSubGroup("x", true);
rootAX.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
rootAX.setMaxQueuedQueries(10);
rootAX.setHardConcurrencyLimit(0);
// Verify QueryStateInfo for query queued on resource group root.a.y
QueryStateInfo query = createQueryStateInfo(new BasicQueryInfo(createQueryInfo("query_root_a_x", rootAX.getId(), QUEUED, "SELECT 1")), Optional.of(ImmutableList.of(rootAX.getInfo(), rootA.getInfo(), root.getInfo())), false, OptionalInt.empty());
assertEquals(query.getQuery(), "SELECT 1");
assertEquals(query.getQueryId().toString(), "query_root_a_x");
assertEquals(query.getQueryState(), QUEUED);
assertEquals(query.getProgress(), Optional.empty());
List<ResourceGroupInfo> chainInfo = query.getPathToRoot().get();
assertEquals(chainInfo.size(), 3);
ResourceGroupInfo rootAInfo = chainInfo.get(1);
ResourceGroupInfo expectedRootAInfo = rootA.getInfo();
assertEquals(rootAInfo.getId(), expectedRootAInfo.getId());
assertEquals(rootAInfo.getState(), expectedRootAInfo.getState());
assertEquals(rootAInfo.getNumRunningQueries(), expectedRootAInfo.getNumRunningQueries());
assertEquals(rootAInfo.getNumQueuedQueries(), expectedRootAInfo.getNumQueuedQueries());
ResourceGroupInfo actualRootInfo = chainInfo.get(2);
ResourceGroupInfo expectedRootInfo = root.getInfo();
assertEquals(actualRootInfo.getId(), expectedRootInfo.getId());
assertEquals(actualRootInfo.getState(), expectedRootInfo.getState());
assertEquals(actualRootInfo.getNumRunningQueries(), expectedRootInfo.getNumRunningQueries());
assertEquals(actualRootInfo.getNumQueuedQueries(), expectedRootInfo.getNumQueuedQueries());
}
use of com.facebook.presto.execution.resourceGroups.InternalResourceGroup 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));
}
Aggregations