use of io.trino.spi.QueryId in project trino by trinodb.
the class QueryStateInfoResource method getQueryStateInfo.
@ResourceSecurity(AUTHENTICATED_USER)
@GET
@Path("{queryId}")
@Produces(MediaType.APPLICATION_JSON)
public QueryStateInfo getQueryStateInfo(@PathParam("queryId") String queryId, @Context HttpServletRequest servletRequest, @Context HttpHeaders httpHeaders) throws WebApplicationException {
try {
BasicQueryInfo queryInfo = dispatchManager.getQueryInfo(new QueryId(queryId));
checkCanViewQueryOwnedBy(sessionContextFactory.extractAuthorizedIdentity(servletRequest, httpHeaders, alternateHeaderName), queryInfo.getSession().toIdentity(), accessControl);
return getQueryStateInfo(queryInfo);
} catch (AccessDeniedException e) {
throw new ForbiddenException();
} catch (NoSuchElementException e) {
throw new WebApplicationException(NOT_FOUND);
}
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class DynamicFilterService method getDynamicFilteringStats.
public DynamicFiltersStats getDynamicFilteringStats(QueryId queryId, Session session) {
DynamicFilterContext context = dynamicFilterContexts.get(queryId);
if (context == null) {
// query has been removed or dynamic filtering is not enabled
return DynamicFiltersStats.EMPTY;
}
int lazyFilters = context.getLazyDynamicFilters().size();
int replicatedFilters = context.getReplicatedDynamicFilters().size();
int totalDynamicFilters = context.getTotalDynamicFilters();
ConnectorSession connectorSession = session.toConnectorSession();
List<DynamicFilterDomainStats> dynamicFilterDomainStats = context.getDynamicFilterSummaries().entrySet().stream().map(entry -> {
DynamicFilterId dynamicFilterId = entry.getKey();
return new DynamicFilterDomainStats(dynamicFilterId, // use small limit for readability
entry.getValue().toString(connectorSession, 2), context.getDynamicFilterCollectionDuration(dynamicFilterId));
}).collect(toImmutableList());
return new DynamicFiltersStats(dynamicFilterDomainStats, lazyFilters, replicatedFilters, totalDynamicFilters, dynamicFilterDomainStats.size());
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class AbstractTestExchangeManager method testLargePages.
@Test
public void testLargePages() throws Exception {
Exchange exchange = exchangeManager.createExchange(new ExchangeContext(new QueryId("query"), createRandomExchangeId()), 3);
ExchangeSinkHandle sinkHandle0 = exchange.addSink(0);
ExchangeSinkHandle sinkHandle1 = exchange.addSink(1);
ExchangeSinkHandle sinkHandle2 = exchange.addSink(2);
exchange.noMoreSinks();
ExchangeSinkInstanceHandle sinkInstanceHandle = exchange.instantiateSink(sinkHandle0, 0);
writeData(sinkInstanceHandle, new ImmutableListMultimap.Builder<Integer, String>().putAll(0, ImmutableList.of(SMALL_PAGE)).putAll(1, ImmutableList.of(MAX_PAGE, MEDIUM_PAGE)).putAll(2, ImmutableList.of()).build(), true);
exchange.sinkFinished(sinkInstanceHandle);
sinkInstanceHandle = exchange.instantiateSink(sinkHandle1, 0);
writeData(sinkInstanceHandle, new ImmutableListMultimap.Builder<Integer, String>().putAll(0, ImmutableList.of(MEDIUM_PAGE)).putAll(1, ImmutableList.of(LARGE_PAGE)).putAll(2, ImmutableList.of(SMALL_PAGE)).build(), true);
exchange.sinkFinished(sinkInstanceHandle);
sinkInstanceHandle = exchange.instantiateSink(sinkHandle2, 0);
writeData(sinkInstanceHandle, new ImmutableListMultimap.Builder<Integer, String>().putAll(0, ImmutableList.of(LARGE_PAGE, MAX_PAGE)).putAll(1, ImmutableList.of(SMALL_PAGE)).putAll(2, ImmutableList.of(MAX_PAGE, LARGE_PAGE, MEDIUM_PAGE)).build(), true);
exchange.sinkFinished(sinkInstanceHandle);
List<ExchangeSourceHandle> partitionHandles = exchange.getSourceHandles().get();
assertThat(partitionHandles).hasSize(3);
Map<Integer, ExchangeSourceHandle> partitions = partitionHandles.stream().collect(toImmutableMap(ExchangeSourceHandle::getPartitionId, Function.identity()));
assertThat(readData(partitions.get(0))).containsExactlyInAnyOrder(SMALL_PAGE, MEDIUM_PAGE, LARGE_PAGE, MAX_PAGE);
assertThat(readData(partitions.get(1))).containsExactlyInAnyOrder(SMALL_PAGE, MEDIUM_PAGE, LARGE_PAGE, MAX_PAGE);
assertThat(readData(partitions.get(2))).containsExactlyInAnyOrder(SMALL_PAGE, MEDIUM_PAGE, LARGE_PAGE, MAX_PAGE);
exchange.close();
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class AbstractTestExchangeManager method testHappyPath.
@Test
public void testHappyPath() throws Exception {
Exchange exchange = exchangeManager.createExchange(new ExchangeContext(new QueryId("query"), createRandomExchangeId()), 2);
ExchangeSinkHandle sinkHandle0 = exchange.addSink(0);
ExchangeSinkHandle sinkHandle1 = exchange.addSink(1);
ExchangeSinkHandle sinkHandle2 = exchange.addSink(2);
exchange.noMoreSinks();
ExchangeSinkInstanceHandle sinkInstanceHandle = exchange.instantiateSink(sinkHandle0, 0);
writeData(sinkInstanceHandle, ImmutableListMultimap.of(0, "0-0-0", 1, "0-1-0", 0, "0-0-1", 1, "0-1-1"), true);
exchange.sinkFinished(sinkInstanceHandle);
sinkInstanceHandle = exchange.instantiateSink(sinkHandle0, 1);
writeData(sinkInstanceHandle, ImmutableListMultimap.of(0, "0-0-0", 1, "0-1-0", 0, "0-0-1", 1, "0-1-1"), true);
exchange.sinkFinished(sinkInstanceHandle);
sinkInstanceHandle = exchange.instantiateSink(sinkHandle0, 2);
writeData(sinkInstanceHandle, ImmutableListMultimap.of(0, "failed", 1, "another failed"), false);
exchange.sinkFinished(sinkInstanceHandle);
sinkInstanceHandle = exchange.instantiateSink(sinkHandle1, 0);
writeData(sinkInstanceHandle, ImmutableListMultimap.of(0, "1-0-0", 1, "1-1-0", 0, "1-0-1", 1, "1-1-1"), true);
exchange.sinkFinished(sinkInstanceHandle);
sinkInstanceHandle = exchange.instantiateSink(sinkHandle1, 1);
writeData(sinkInstanceHandle, ImmutableListMultimap.of(0, "1-0-0", 1, "1-1-0", 0, "1-0-1", 1, "1-1-1"), true);
exchange.sinkFinished(sinkInstanceHandle);
sinkInstanceHandle = exchange.instantiateSink(sinkHandle1, 2);
writeData(sinkInstanceHandle, ImmutableListMultimap.of(0, "more failed", 1, "another failed"), false);
exchange.sinkFinished(sinkInstanceHandle);
sinkInstanceHandle = exchange.instantiateSink(sinkHandle2, 2);
writeData(sinkInstanceHandle, ImmutableListMultimap.of(0, "2-0-0", 1, "2-1-0"), true);
exchange.sinkFinished(sinkInstanceHandle);
List<ExchangeSourceHandle> partitionHandles = exchange.getSourceHandles().get();
assertThat(partitionHandles).hasSize(2);
Map<Integer, ExchangeSourceHandle> partitions = partitionHandles.stream().collect(toImmutableMap(ExchangeSourceHandle::getPartitionId, Function.identity()));
assertThat(readData(partitions.get(0))).containsExactlyInAnyOrder("0-0-0", "0-0-1", "1-0-0", "1-0-1", "2-0-0");
assertThat(readData(partitions.get(1))).containsExactlyInAnyOrder("0-1-0", "0-1-1", "1-1-0", "1-1-1", "2-1-0");
exchange.close();
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class TestSqlTask method createInitialTask.
private SqlTask createInitialTask() {
TaskId taskId = new TaskId(new StageId("query", 0), nextTaskId.incrementAndGet(), 0);
URI location = URI.create("fake://task/" + taskId);
QueryContext queryContext = new QueryContext(new QueryId("query"), DataSize.of(1, MEGABYTE), new MemoryPool(DataSize.of(1, GIGABYTE)), new TestingGcMonitor(), taskNotificationExecutor, driverYieldExecutor, DataSize.of(1, MEGABYTE), new SpillSpaceTracker(DataSize.of(1, GIGABYTE)));
queryContext.addTaskContext(new TaskStateMachine(taskId, taskNotificationExecutor), testSessionBuilder().build(), () -> {
}, false, false);
return createSqlTask(taskId, location, "fake", queryContext, sqlTaskExecutionFactory, taskNotificationExecutor, sqlTask -> {
}, DataSize.of(32, MEGABYTE), DataSize.of(200, MEGABYTE), new ExchangeManagerRegistry(new ExchangeHandleResolver()), new CounterStat());
}
Aggregations