use of io.prestosql.server.BasicQueryInfo in project hetu-core by openlookeng.
the class QuerySystemTable method cursor.
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) {
Builder table = InMemoryRecordSet.builder(QUERY_TABLE);
List<QueryInfo> queryInfos = queryManager.getQueries().stream().map(BasicQueryInfo::getQueryId).map(queryId -> {
try {
return queryManager.getFullQueryInfo(queryId);
} catch (NoSuchElementException e) {
return null;
}
}).filter(Objects::nonNull).collect(toImmutableList());
for (QueryInfo queryInfo : queryInfos) {
QueryStats queryStats = queryInfo.getQueryStats();
table.addRow(queryInfo.getQueryId().toString(), queryInfo.getState().toString(), queryInfo.getSession().getUser(), queryInfo.getSession().getSource().orElse(null), queryInfo.getQuery(), queryInfo.getResourceGroupId().map(QuerySystemTable::resourceGroupIdToBlock).orElse(null), toMillis(queryStats.getQueuedTime()), toMillis(queryStats.getAnalysisTime()), toMillis(queryStats.getDistributedPlanningTime()), toTimeStamp(queryStats.getCreateTime()), toTimeStamp(queryStats.getExecutionStartTime()), toTimeStamp(queryStats.getLastHeartbeat()), toTimeStamp(queryStats.getEndTime()));
}
return table.build().cursor();
}
use of io.prestosql.server.BasicQueryInfo in project hetu-core by openlookeng.
the class TestMetadataManager method testMetadataIsClearedAfterQueryCanceled.
@Test
public void testMetadataIsClearedAfterQueryCanceled() throws Exception {
DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
QueryId queryId = dispatchManager.createQueryId();
dispatchManager.createQuery(queryId, "slug", new TestingSessionContext(TEST_SESSION), "SELECT * FROM lineitem").get();
// wait until query starts running
while (true) {
BasicQueryInfo queryInfo = dispatchManager.getQueryInfo(queryId);
if (queryInfo.getState().isDone()) {
assertEquals(queryInfo.getState(), FAILED);
throw dispatchManager.getDispatchInfo(queryId).get().getFailureInfo().get().toException();
}
if (queryInfo.getState() == RUNNING) {
break;
}
Thread.sleep(100);
}
// cancel query
dispatchManager.cancelQuery(queryId);
assertEquals(metadataManager.getActiveQueryIds().size(), 0);
}
use of io.prestosql.server.BasicQueryInfo in project hetu-core by openlookeng.
the class TestNodeStateChange method testWorkerShutdown.
@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS2)
public void testWorkerShutdown() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, properties)) {
List<ListenableFuture<?>> queryFutures = new ArrayList<>();
for (int i = 0; i < 5; i++) {
queryFutures.add(executor.submit(() -> queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk")));
}
TestingPrestoServer worker = queryRunner.getServers().stream().filter(server -> !server.isCoordinator()).findFirst().get();
TaskManager taskManager = worker.getTaskManager();
// wait until tasks show up on the worker
while (taskManager.getAllTaskInfo().isEmpty()) {
MILLISECONDS.sleep(500);
}
worker.getNodeStateChangeHandler().doStateTransition(NodeState.SHUTTING_DOWN);
Futures.allAsList(queryFutures).get();
List<BasicQueryInfo> queryInfos = queryRunner.getCoordinator().getQueryManager().getQueries();
for (BasicQueryInfo info : queryInfos) {
assertEquals(info.getState(), FINISHED);
}
TestingPrestoServer.TestShutdownAction shutdownAction = (TestingPrestoServer.TestShutdownAction) worker.getShutdownAction();
shutdownAction.waitForShutdownComplete(SHUTDOWN_TIMEOUT_MILLIS2);
assertTrue(shutdownAction.isShutdown());
}
}
use of io.prestosql.server.BasicQueryInfo in project hetu-core by openlookeng.
the class TestNodeStateChange method testCoordinatorIsolation.
@Test(timeOut = 30_000)
public void testCoordinatorIsolation() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, defaultProperties)) {
List<ListenableFuture<?>> queryFutures = new ArrayList<>();
for (int i = 0; i < 5; i++) {
queryFutures.add(executor.submit(() -> queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk")));
}
TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
QueryManager queryManager = coordinator.getQueryManager();
// wait until queries show up on the coordinator
while (queryManager.getQueries().isEmpty()) {
MILLISECONDS.sleep(500);
}
assertEquals(coordinator.getNodeStateChangeHandler().getState(), NodeState.ACTIVE);
coordinator.getNodeStateChangeHandler().doStateTransition(NodeState.ISOLATING);
Futures.allAsList(queryFutures).get();
List<BasicQueryInfo> queryInfos = queryRunner.getCoordinator().getQueryManager().getQueries();
for (BasicQueryInfo info : queryInfos) {
assertEquals(info.getState(), FINISHED);
}
while (!coordinator.getNodeStateChangeHandler().getState().equals(NodeState.ISOLATED)) {
Thread.sleep(1000);
}
}
}
use of io.prestosql.server.BasicQueryInfo in project hetu-core by openlookeng.
the class TestMemoryManager method waitForQueryToBeKilled.
private void waitForQueryToBeKilled(DistributedQueryRunner queryRunner) throws InterruptedException {
while (true) {
for (BasicQueryInfo info : queryRunner.getCoordinator().getQueryManager().getQueries()) {
if (info.getState().isDone()) {
assertNotNull(info.getErrorCode());
assertEquals(info.getErrorCode().getCode(), CLUSTER_OUT_OF_MEMORY.toErrorCode().getCode());
return;
}
}
MILLISECONDS.sleep(10);
}
}
Aggregations