use of com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao in project presto by prestodb.
the class TestQueues method testTooManyQueries.
@Test(timeOut = 240_000)
public void testTooManyQueries() throws Exception {
String dbConfigUrl = getDbConfigUrl();
H2ResourceGroupsDao dao = getDao(dbConfigUrl);
try (DistributedQueryRunner queryRunner = createQueryRunner(dbConfigUrl, dao)) {
QueryId firstDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
QueryId secondDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
QueryId thirdDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, thirdDashboardQuery, FAILED);
// Allow one more query to run and resubmit third query
dao.updateResourceGroup(3, "user-${USER}", "1MB", 3, 4, null, null, null, null, null, 1L);
dao.updateResourceGroup(5, "dashboard-${USER}", "1MB", 1, 2, null, null, null, null, null, 3L);
waitForQueryState(queryRunner, secondDashboardQuery, RUNNING);
thirdDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, thirdDashboardQuery, QUEUED);
// Lower running queries in dashboard resource groups and wait until groups are reconfigured
dao.updateResourceGroup(5, "dashboard-${USER}", "1MB", 1, 1, null, null, null, null, null, 3L);
ResourceGroupManager manager = queryRunner.getCoordinator().getResourceGroupManager().get();
do {
MILLISECONDS.sleep(500);
} while (manager.getResourceGroupInfo(new ResourceGroupId(new ResourceGroupId(new ResourceGroupId("global"), "user-user"), "dashboard-user")).getMaxRunningQueries() != 1);
// Cancel query and verify that third query is still queued
cancelQuery(queryRunner, firstDashboardQuery);
waitForQueryState(queryRunner, firstDashboardQuery, FAILED);
MILLISECONDS.sleep(2000);
waitForQueryState(queryRunner, thirdDashboardQuery, QUEUED);
}
}
use of com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao in project presto by prestodb.
the class TestQueues method testRejection.
@Test(timeOut = 240_000)
public void testRejection() throws Exception {
String dbConfigUrl = getDbConfigUrl();
H2ResourceGroupsDao dao = getDao(dbConfigUrl);
try (DistributedQueryRunner queryRunner = createQueryRunner(dbConfigUrl, dao)) {
// Verify the query cannot be submitted
QueryId queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, FAILED);
QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
assertEquals(queryManager.getQueryInfo(queryId).getErrorCode(), QUERY_REJECTED.toErrorCode());
int selectorCount = getSelectors(queryRunner).size();
dao.insertSelector(4, "user.*", "(?i).*reject.*");
assertEquals(dao.getSelectors().size(), selectorCount + 1);
//MILLISECONDS.sleep(2000);
do {
MILLISECONDS.sleep(500);
} while (getSelectors(queryRunner).size() == selectorCount);
// Verify the query can be submitted
queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, RUNNING);
dao.deleteSelector(4, "user.*", "(?i).*reject.*");
do {
MILLISECONDS.sleep(500);
} while (getSelectors(queryRunner).size() != selectorCount);
// Verify the query cannot be submitted
queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, FAILED);
}
}
use of com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao in project presto by prestodb.
the class TestQueues method getSimpleQueryRunner.
static DistributedQueryRunner getSimpleQueryRunner() throws Exception {
String dbConfigUrl = getDbConfigUrl();
H2ResourceGroupsDao dao = getDao(dbConfigUrl);
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("experimental.resource-groups-enabled", "true");
Map<String, String> properties = builder.build();
DistributedQueryRunner queryRunner = TpchQueryRunner.createQueryRunner(properties);
Plugin h2ResourceGroupManagerPlugin = new H2ResourceGroupManagerPlugin();
queryRunner.installPlugin(h2ResourceGroupManagerPlugin);
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager(NAME, ImmutableMap.of("resource-groups.config-db-url", dbConfigUrl));
setup(queryRunner, dao);
return queryRunner;
}
use of com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao in project presto by prestodb.
the class TestQueues method testTwoQueriesAtSameTime.
@Test(timeOut = 240_000)
public void testTwoQueriesAtSameTime() throws Exception {
String dbConfigUrl = getDbConfigUrl();
H2ResourceGroupsDao dao = getDao(dbConfigUrl);
try (DistributedQueryRunner queryRunner = createQueryRunner(dbConfigUrl, dao)) {
QueryId firstDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
QueryId secondDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
ImmutableSet<QueryState> queuedOrRunning = ImmutableSet.of(QUEUED, RUNNING);
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
}
}
use of com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao in project presto by prestodb.
the class TestQueues method getDao.
private static H2ResourceGroupsDao getDao(String url) {
DbResourceGroupConfig dbResourceGroupConfig = new DbResourceGroupConfig().setConfigDbUrl(url);
H2ResourceGroupsDao dao = new H2DaoProvider(dbResourceGroupConfig).get();
dao.createResourceGroupsTable();
dao.createSelectorsTable();
dao.createResourceGroupsGlobalPropertiesTable();
return dao;
}
Aggregations