use of com.facebook.presto.execution.QueryExecution in project presto by prestodb.
the class TestLocalDispatchQuery method testQueryQueuedExceptionBeforeDispatch.
@Test
public void testQueryQueuedExceptionBeforeDispatch() {
QueryStateMachine stateMachine = createStateMachine();
CountingEventListener eventListener = new CountingEventListener();
SettableFuture<QueryExecution> queryExecutionFuture = SettableFuture.create();
LocalDispatchQuery query = new LocalDispatchQuery(stateMachine, createQueryMonitor(eventListener), queryExecutionFuture, createClusterSizeMonitor(0), directExecutor(), dispatchQuery -> {
throw new QueryQueueFullException(new ResourceGroupId("global"));
}, execution -> {
}, false, QUERY_PREREQUISITES);
query.startWaitingForPrerequisites();
queryExecutionFuture.setException(new IllegalStateException("abc"));
assertEquals(query.getBasicQueryInfo().getState(), FAILED);
assertEquals(query.getBasicQueryInfo().getErrorCode(), QUERY_QUEUE_FULL.toErrorCode());
assertTrue(eventListener.getQueryCompletedEvent().isPresent());
assertTrue(eventListener.getQueryCompletedEvent().get().getFailureInfo().isPresent());
assertEquals(eventListener.getQueryCompletedEvent().get().getFailureInfo().get().getErrorCode(), QUERY_QUEUE_FULL.toErrorCode());
}
use of com.facebook.presto.execution.QueryExecution in project presto by prestodb.
the class ClusterMemoryManager method callOomKiller.
private synchronized void callOomKiller(Iterable<QueryExecution> runningQueries) {
List<QueryMemoryInfo> queryMemoryInfoList = Streams.stream(runningQueries).map(this::createQueryMemoryInfo).collect(toImmutableList());
List<MemoryInfo> nodeMemoryInfos = nodes.values().stream().map(RemoteNodeMemory::getInfo).filter(Optional::isPresent).map(Optional::get).collect(toImmutableList());
Optional<QueryId> chosenQueryId = lowMemoryKiller.chooseQueryToKill(queryMemoryInfoList, nodeMemoryInfos);
if (chosenQueryId.isPresent()) {
log.debug("Low memory killer chose %s", chosenQueryId.get());
Optional<QueryExecution> chosenQuery = Streams.stream(runningQueries).filter(query -> chosenQueryId.get().equals(query.getQueryId())).collect(toOptional());
if (chosenQuery.isPresent()) {
// See comments in isLastKilledQueryGone for why chosenQuery might be absent.
chosenQuery.get().fail(new PrestoException(CLUSTER_OUT_OF_MEMORY, "Query killed because the cluster is out of memory. Please try again in a few minutes."));
queriesKilledDueToOutOfMemory.incrementAndGet();
lastKilledQuery = chosenQueryId.get();
logQueryKill(chosenQueryId.get(), nodeMemoryInfos);
}
}
}
Aggregations