use of com.facebook.presto.dispatcher.DispatchManager in project presto by prestodb.
the class TestResourceGroupPerQueryLimitEnforcement method cancelAllQueriesAfterTest.
@AfterMethod
public void cancelAllQueriesAfterTest() {
DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
ImmutableList.copyOf(dispatchManager.getQueries()).forEach(queryInfo -> dispatchManager.cancelQuery(queryInfo.getQueryId()));
}
use of com.facebook.presto.dispatcher.DispatchManager in project presto by prestodb.
the class TestQueuesDb method testRejection.
@Test(timeOut = 60_000)
public void testRejection() throws Exception {
InternalResourceGroupManager manager = queryRunner.getCoordinator().getResourceGroupManager().get();
ReloadingResourceGroupConfigurationManager reloadingConfigurationManager = (ReloadingResourceGroupConfigurationManager) manager.getConfigurationManager();
// Verify the query cannot be submitted
QueryId queryId = createQuery(queryRunner, rejectingSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, FAILED);
DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
assertEquals(dispatchManager.getQueryInfo(queryId).getErrorCode(), QUERY_REJECTED.toErrorCode());
int selectorCount = getSelectors(queryRunner).size();
dao.insertSelector(4, 100_000, "user.*", "(?i).*reject.*", null, null, null);
reloadingConfigurationManager.load();
assertEquals(getSelectors(queryRunner).size(), selectorCount + 1);
// Verify the query can be submitted
queryId = createQuery(queryRunner, rejectingSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, RUNNING);
dao.deleteSelector(4, "user.*", "(?i).*reject.*", null);
reloadingConfigurationManager.load();
// Verify the query cannot be submitted
queryId = createQuery(queryRunner, rejectingSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, FAILED);
}
use of com.facebook.presto.dispatcher.DispatchManager in project presto by prestodb.
the class TestQueuesDb method testSelectorPriority.
@Test(timeOut = 60_000)
public void testSelectorPriority() throws Exception {
InternalResourceGroupManager manager = queryRunner.getCoordinator().getResourceGroupManager().get();
QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
ReloadingResourceGroupConfigurationManager reloadingConfigurationManager = (ReloadingResourceGroupConfigurationManager) manager.getConfigurationManager();
QueryId firstQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, firstQuery, RUNNING);
Optional<ResourceGroupId> resourceGroup = queryManager.getFullQueryInfo(firstQuery).getResourceGroupId();
assertTrue(resourceGroup.isPresent());
assertEquals(resourceGroup.get().toString(), "global.user-user.dashboard-user");
// create a new resource group that rejects all queries submitted to it
dao.insertResourceGroup(10, "reject-all-queries", "1MB", 0, 0, 0, null, null, null, null, null, null, null, null, 3L, TEST_ENVIRONMENT);
// add a new selector that has a higher priority than the existing dashboard selector and that routes queries to the "reject-all-queries" resource group
dao.insertSelector(10, 200, "user.*", "(?i).*dashboard.*", null, null, null);
// reload the configuration
reloadingConfigurationManager.load();
QueryId secondQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, secondQuery, FAILED);
DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
BasicQueryInfo basicQueryInfo = dispatchManager.getQueryInfo(secondQuery);
assertEquals(basicQueryInfo.getErrorCode(), QUERY_QUEUE_FULL.toErrorCode());
}
use of com.facebook.presto.dispatcher.DispatchManager in project presto by prestodb.
the class TestQueryManager method testFailQuery.
@Test(timeOut = 60_000L)
public void testFailQuery() throws Exception {
DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
QueryId queryId = dispatchManager.createQueryId();
dispatchManager.createQuery(queryId, "slug", 0, new TestingSessionContext(TEST_SESSION), "SELECT * FROM lineitem").get();
// wait until query starts running
while (true) {
QueryState state = dispatchManager.getQueryInfo(queryId).getState();
if (state.isDone()) {
fail("unexpected query state: " + state);
}
if (state == RUNNING) {
break;
}
Thread.sleep(100);
}
// cancel query
QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
queryManager.failQuery(queryId, new PrestoException(GENERIC_INTERNAL_ERROR, "mock exception"));
QueryInfo queryInfo = queryManager.getFullQueryInfo(queryId);
assertEquals(queryInfo.getState(), FAILED);
assertEquals(queryInfo.getErrorCode(), GENERIC_INTERNAL_ERROR.toErrorCode());
assertNotNull(queryInfo.getFailureInfo());
assertEquals(queryInfo.getFailureInfo().getMessage(), "mock exception");
assertEquals(queryManager.getStats().getQueuedQueries(), 0);
}
use of com.facebook.presto.dispatcher.DispatchManager in project presto by prestodb.
the class TestQueryManager method cancelAllQueriesAfterTest.
@AfterMethod
public void cancelAllQueriesAfterTest() {
DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
ImmutableList.copyOf(dispatchManager.getQueries()).forEach(queryInfo -> dispatchManager.cancelQuery(queryInfo.getQueryId()));
}
Aggregations