use of com.facebook.presto.server.BasicQueryInfo in project presto by prestodb.
the class TestBrutalShutdown method testRetryCircuitBreaker.
@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testRetryCircuitBreaker() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(ImmutableMap.of("global-query-retry-failure-limit", "2"))) {
queryRetryOnShutdown(TINY_SESSION, queryRunner, executor, 10);
int totalSuccessfulRetryQueries = 0;
List<BasicQueryInfo> queryInfos = queryRunner.getCoordinator().getQueryManager().getQueries();
for (BasicQueryInfo info : queryInfos) {
if (info.getQuery().contains("-- retry query")) {
assertEquals(info.getState(), FINISHED);
totalSuccessfulRetryQueries++;
}
}
assertLessThanOrEqual(totalSuccessfulRetryQueries, 2);
}
}
use of com.facebook.presto.server.BasicQueryInfo in project presto by prestodb.
the class AbstractTestDistributedQueries method testQueryLoggingCount.
@Test
public void testQueryLoggingCount() {
QueryManager queryManager = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getQueryManager();
executeExclusively(() -> {
assertUntilTimeout(() -> assertEquals(queryManager.getQueries().stream().map(BasicQueryInfo::getQueryId).map(queryManager::getFullQueryInfo).filter(info -> !info.isFinalQueryInfo()).collect(toList()), ImmutableList.of()), new Duration(1, MINUTES));
// We cannot simply get the number of completed queries as soon as all the queries are completed, because this counter may not be up-to-date at that point.
// The completed queries counter is updated in a final query info listener, which is called eventually.
// Therefore, here we wait until the value of this counter gets stable.
DispatchManager dispatchManager = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getDispatchManager();
long beforeCompletedQueriesCount = waitUntilStable(() -> dispatchManager.getStats().getCompletedQueries().getTotalCount(), new Duration(5, SECONDS));
long beforeSubmittedQueriesCount = dispatchManager.getStats().getSubmittedQueries().getTotalCount();
assertUpdate("CREATE TABLE test_query_logging_count AS SELECT 1 foo_1, 2 foo_2_4", 1);
assertQuery("SELECT foo_1, foo_2_4 FROM test_query_logging_count", "SELECT 1, 2");
assertUpdate("DROP TABLE test_query_logging_count");
assertQueryFails("SELECT * FROM test_query_logging_count", ".*Table .* does not exist");
// TODO: Figure out a better way of synchronization
assertUntilTimeout(() -> assertEquals(dispatchManager.getStats().getCompletedQueries().getTotalCount() - beforeCompletedQueriesCount, 4), new Duration(1, MINUTES));
assertEquals(dispatchManager.getStats().getSubmittedQueries().getTotalCount() - beforeSubmittedQueriesCount, 4);
});
}
use of com.facebook.presto.server.BasicQueryInfo in project presto by prestodb.
the class ClusterMemoryLeakDetector method isLeaked.
private static boolean isLeaked(Map<QueryId, BasicQueryInfo> queryIdToInfo, QueryId queryId) {
BasicQueryInfo queryInfo = queryIdToInfo.get(queryId);
if (queryInfo == null) {
return true;
}
DateTime queryEndTime = queryInfo.getQueryStats().getEndTime();
if (queryInfo.getState() == RUNNING || queryEndTime == null) {
return false;
}
return secondsBetween(queryEndTime, now()).getSeconds() >= DEFAULT_LEAK_CLAIM_DELTA_SEC;
}
use of com.facebook.presto.server.BasicQueryInfo in project presto by prestodb.
the class TestQueryInterceptor method testMultiplePostPreprocess.
@Test
public void testMultiplePostPreprocess() throws Exception {
String extra = "queryInterceptors=" + TestPostProcess1QueryInterceptor.class.getName() + ";" + TestPostProcess1QueryInterceptor.class.getName();
try (Connection connection = createConnection(extra)) {
try (Statement statement = connection.createStatement()) {
try (ResultSet ignored = statement.executeQuery("select * from tpch.sf1000.orders")) {
assertEquals(qm.getQueries().size(), 3);
}
}
}
// Add sleep because deletes are sent async
Thread.sleep(1000);
List<BasicQueryInfo> queries = qm.getQueries();
assertEquals(queries.stream().filter(query -> query.getState() == QueryState.FAILED).count(), 3);
}
use of com.facebook.presto.server.BasicQueryInfo in project presto by prestodb.
the class TestQueryInterceptor method testBasicPostPreprocess.
@Test
public void testBasicPostPreprocess() throws Exception {
String extra = "queryInterceptors=" + TestPostProcess1QueryInterceptor.class.getName();
try (Connection connection = createConnection(extra)) {
try (Statement statement = connection.createStatement()) {
try (ResultSet ignored = statement.executeQuery("select * from tpch.sf1000.orders")) {
assertEquals(qm.getQueries().size(), 2);
}
}
}
// Add sleep because deletes are sent async
Thread.sleep(1000);
List<BasicQueryInfo> queries = qm.getQueries();
assertEquals(queries.stream().filter(query -> query.getState() == QueryState.FAILED).count(), 2);
}
Aggregations