use of com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin in project presto by prestodb.
the class TestQueues method testBasic.
private void testBasic(boolean resourceGroups) throws Exception {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
if (resourceGroups) {
builder.put("experimental.resource-groups-enabled", "true");
} else {
builder.put("query.queue-config-file", getResourceFilePath("queue_config_dashboard.json"));
}
Map<String, String> properties = builder.build();
try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
// submit first "dashboard" query
QueryId firstDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
// wait for the first "dashboard" query to start
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
// submit second "dashboard" query
QueryId secondDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
// wait for the second "dashboard" query to be queued ("dashboard.${USER}" queue strategy only allows one "dashboard" query to be accepted for execution)
waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
// submit first non "dashboard" query
QueryId firstNonDashboardQuery = createQuery(queryRunner, newSession(), LONG_LASTING_QUERY);
// wait for the first non "dashboard" query to start
waitForQueryState(queryRunner, firstNonDashboardQuery, RUNNING);
// submit second non "dashboard" query
QueryId secondNonDashboardQuery = createQuery(queryRunner, newSession(), LONG_LASTING_QUERY);
// wait for the second non "dashboard" query to start
waitForQueryState(queryRunner, secondNonDashboardQuery, RUNNING);
// cancel first "dashboard" query, second "dashboard" query and second non "dashboard" query should start running
cancelQuery(queryRunner, firstDashboardQuery);
waitForQueryState(queryRunner, firstDashboardQuery, FAILED);
waitForQueryState(queryRunner, secondDashboardQuery, RUNNING);
}
}
use of com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin in project presto by prestodb.
the class TestQueues method testRejection.
private void testRejection(boolean resourceGroups) throws Exception {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
if (resourceGroups) {
builder.put("experimental.resource-groups-enabled", "true");
} else {
builder.put("query.queue-config-file", getResourceFilePath("queue_config_dashboard.json"));
}
Map<String, String> properties = builder.build();
try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
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());
}
}
use of com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin in project presto by prestodb.
the class TestQueues method testTwoQueriesAtSameTime.
private void testTwoQueriesAtSameTime(boolean resourceGroups) throws Exception {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
if (resourceGroups) {
builder.put("experimental.resource-groups-enabled", "true");
} else {
builder.put("query.queue-config-file", getResourceFilePath("queue_config_dashboard.json"));
}
Map<String, String> properties = builder.build();
try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
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, queuedOrRunning);
waitForQueryState(queryRunner, secondDashboardQuery, queuedOrRunning);
}
}
use of com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin in project presto by prestodb.
the class TestQueues method testTooManyQueries.
private void testTooManyQueries(boolean resourceGroups) throws Exception {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
if (resourceGroups) {
builder.put("experimental.resource-groups-enabled", "true");
} else {
builder.put("query.queue-config-file", getResourceFilePath("queue_config_dashboard.json"));
}
Map<String, String> properties = builder.build();
try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
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);
}
}
use of com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin in project presto by prestodb.
the class TestResourceGroupIntegration method testMemoryFraction.
@Test
public void testMemoryFraction() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(ImmutableMap.of(), ImmutableMap.of("experimental.resource-groups-enabled", "true"))) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_memory_percentage.json")));
queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
long startTime = System.nanoTime();
while (true) {
SECONDS.sleep(1);
ResourceGroupInfo global = queryRunner.getCoordinator().getResourceGroupManager().get().getResourceGroupInfo(new ResourceGroupId("global"));
if (global.getSoftMemoryLimit().toBytes() > 0) {
break;
}
assertLessThan(nanosSince(startTime).roundTo(SECONDS), 60L);
}
}
}
Aggregations