Search in sources :

Example 1 with QueryStateInfo

use of com.facebook.presto.server.QueryStateInfo in project presto by prestodb.

the class TestThriftResourceGroupInfo method setUpQueryStateInfoList.

private void setUpQueryStateInfoList() {
    queryStateInfoList = new ArrayList<>();
    queryStateInfoList.add(new QueryStateInfo(FAKE_QUERY_ID_1, FAKE_QUERY_STATE, Optional.of(FAKE_QUERY_RESOURCE_GROUP_ID), FAKE_QUERY, FAKE_QUERY_TRUNCATED, FAKE_CREATE_TIME, FAKE_QUERY_REQUESTER, FAKE_AUTHENTICATED, Optional.of(FAKE_QUERY_SOURCE), Optional.of(FAKE_QUERY_CLIENT_INFO), Optional.of(FAKE_QUERY_CATALOG), Optional.of(FAKE_QUERY_SCHEMA), Optional.of(new ArrayList<>()), Optional.of(queryProgressStats.get(0)), FAKE_WARNING_CODES, Optional.of(FAKE_ERROR_CODE)));
    queryStateInfoList.add(new QueryStateInfo(FAKE_QUERY_ID_2, FAKE_QUERY_STATE, Optional.of(FAKE_QUERY_RESOURCE_GROUP_ID), FAKE_QUERY, FAKE_QUERY_TRUNCATED, FAKE_CREATE_TIME, FAKE_QUERY_REQUESTER, FAKE_AUTHENTICATED, Optional.of(FAKE_QUERY_SOURCE), Optional.of(FAKE_QUERY_CLIENT_INFO), Optional.of(FAKE_QUERY_CATALOG), Optional.of(FAKE_QUERY_SCHEMA), Optional.of(new ArrayList<>()), Optional.of(queryProgressStats.get(1)), ImmutableList.of(), Optional.empty()));
}
Also used : QueryStateInfo(com.facebook.presto.server.QueryStateInfo)

Example 2 with QueryStateInfo

use of com.facebook.presto.server.QueryStateInfo in project presto by prestodb.

the class DistributedQueryInfoResource method getAllQueryInfo.

@GET
public void getAllQueryInfo(@QueryParam("user") String user, @Context HttpServletRequest servletRequest, @Context UriInfo uriInfo, @Suspended AsyncResponse asyncResponse) {
    try {
        Set<InternalNode> coordinators = internalNodeManager.getCoordinators();
        ImmutableList.Builder<ListenableFuture<List<QueryStateInfo>>> queryStateInfoFutureBuilder = ImmutableList.builder();
        for (InternalNode coordinator : coordinators) {
            queryStateInfoFutureBuilder.add(getQueryStateFromCoordinator(uriInfo, coordinator));
        }
        List<ListenableFuture<List<QueryStateInfo>>> queryStateInfoFutureList = queryStateInfoFutureBuilder.build();
        Futures.whenAllComplete(queryStateInfoFutureList).call(() -> {
            try {
                List<QueryStateInfo> queryStateInfoList = new ArrayList<>();
                for (Future<List<QueryStateInfo>> queryStateInfoFuture : queryStateInfoFutureList) {
                    queryStateInfoList.addAll(queryStateInfoFuture.get());
                }
                return asyncResponse.resume(Response.ok(queryStateInfoList).build());
            } catch (Exception ex) {
                log.error(ex, "Error in getting query info from one of the coordinators");
                return asyncResponse.resume(Response.serverError().entity(ex.getMessage()).build());
            }
        }, executor);
    } catch (Exception ex) {
        log.error(ex, "Error in getting query info");
        asyncResponse.resume(Response.serverError().entity(ex.getMessage()).build());
    }
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) InternalNode(com.facebook.presto.metadata.InternalNode) QueryStateInfo(com.facebook.presto.server.QueryStateInfo) IOException(java.io.IOException) WebApplicationException(javax.ws.rs.WebApplicationException) GET(javax.ws.rs.GET)

Example 3 with QueryStateInfo

use of com.facebook.presto.server.QueryStateInfo in project presto by prestodb.

the class TestResourceGroups method testGetResourceGroupStateInfo.

@Test
public void testGetResourceGroupStateInfo() {
    RootInternalResourceGroup root = new RootInternalResourceGroup("root", (group, export) -> {
    }, directExecutor(), ignored -> Optional.empty(), rg -> false);
    root.setSoftMemoryLimit(new DataSize(1, GIGABYTE));
    root.setMaxQueuedQueries(40);
    root.setHardConcurrencyLimit(10);
    root.setSchedulingPolicy(WEIGHTED);
    InternalResourceGroup rootA = root.getOrCreateSubGroup("a", true);
    rootA.setSoftMemoryLimit(new DataSize(10, MEGABYTE));
    rootA.setMaxQueuedQueries(20);
    rootA.setHardConcurrencyLimit(0);
    InternalResourceGroup rootB = root.getOrCreateSubGroup("b", true);
    rootB.setSoftMemoryLimit(new DataSize(5, MEGABYTE));
    rootB.setMaxQueuedQueries(20);
    rootB.setHardConcurrencyLimit(1);
    rootB.setSchedulingWeight(2);
    rootB.setSchedulingPolicy(QUERY_PRIORITY);
    InternalResourceGroup rootAX = rootA.getOrCreateSubGroup("x", true);
    rootAX.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    rootAX.setMaxQueuedQueries(10);
    rootAX.setHardConcurrencyLimit(10);
    InternalResourceGroup rootAY = rootA.getOrCreateSubGroup("y", true);
    rootAY.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
    rootAY.setMaxQueuedQueries(10);
    rootAY.setHardConcurrencyLimit(10);
    Set<MockManagedQueryExecution> queries = fillGroupTo(rootAX, ImmutableSet.of(), 5, false);
    queries.addAll(fillGroupTo(rootAY, ImmutableSet.of(), 5, false));
    queries.addAll(fillGroupTo(rootB, ImmutableSet.of(), 10, true));
    ResourceGroupInfo rootInfo = root.getResourceGroupInfo(true, true, false);
    assertEquals(rootInfo.getId(), root.getId());
    assertEquals(rootInfo.getState(), CAN_RUN);
    assertEquals(rootInfo.getSoftMemoryLimit(), root.getSoftMemoryLimit());
    assertEquals(rootInfo.getMemoryUsage(), new DataSize(0, BYTE));
    assertEquals(rootInfo.getSubGroups().size(), 2);
    assertGroupInfoEquals(rootInfo.getSubGroups().get(0), rootA.getInfo());
    assertEquals(rootInfo.getSubGroups().get(0).getId(), rootA.getId());
    assertEquals(rootInfo.getSubGroups().get(0).getState(), CAN_QUEUE);
    assertEquals(rootInfo.getSubGroups().get(0).getSoftMemoryLimit(), rootA.getSoftMemoryLimit());
    assertEquals(rootInfo.getSubGroups().get(0).getHardConcurrencyLimit(), rootA.getHardConcurrencyLimit());
    assertEquals(rootInfo.getSubGroups().get(0).getMaxQueuedQueries(), rootA.getMaxQueuedQueries());
    assertEquals(rootInfo.getSubGroups().get(0).getNumEligibleSubGroups(), 2);
    assertEquals(rootInfo.getSubGroups().get(0).getNumRunningQueries(), 0);
    assertEquals(rootInfo.getSubGroups().get(0).getNumQueuedQueries(), 10);
    assertGroupInfoEquals(rootInfo.getSubGroups().get(1), rootB.getInfo());
    assertEquals(rootInfo.getSubGroups().get(1).getId(), rootB.getId());
    assertEquals(rootInfo.getSubGroups().get(1).getState(), CAN_QUEUE);
    assertEquals(rootInfo.getSubGroups().get(1).getSoftMemoryLimit(), rootB.getSoftMemoryLimit());
    assertEquals(rootInfo.getSubGroups().get(1).getHardConcurrencyLimit(), rootB.getHardConcurrencyLimit());
    assertEquals(rootInfo.getSubGroups().get(1).getMaxQueuedQueries(), rootB.getMaxQueuedQueries());
    assertEquals(rootInfo.getSubGroups().get(1).getNumEligibleSubGroups(), 0);
    assertEquals(rootInfo.getSubGroups().get(1).getNumRunningQueries(), 1);
    assertEquals(rootInfo.getSubGroups().get(1).getNumQueuedQueries(), 9);
    assertEquals(rootInfo.getSoftConcurrencyLimit(), root.getSoftConcurrencyLimit());
    assertEquals(rootInfo.getHardConcurrencyLimit(), root.getHardConcurrencyLimit());
    assertEquals(rootInfo.getMaxQueuedQueries(), root.getMaxQueuedQueries());
    assertEquals(rootInfo.getNumQueuedQueries(), 19);
    assertEquals(rootInfo.getRunningQueries().size(), 1);
    QueryStateInfo queryInfo = rootInfo.getRunningQueries().get(0);
    assertEquals(queryInfo.getResourceGroupId(), Optional.of(rootB.getId()));
}
Also used : RootInternalResourceGroup(com.facebook.presto.execution.resourceGroups.InternalResourceGroup.RootInternalResourceGroup) RootInternalResourceGroup(com.facebook.presto.execution.resourceGroups.InternalResourceGroup.RootInternalResourceGroup) MockManagedQueryExecution(com.facebook.presto.execution.MockManagedQueryExecution) DataSize(io.airlift.units.DataSize) QueryStateInfo(com.facebook.presto.server.QueryStateInfo) ResourceGroupInfo(com.facebook.presto.server.ResourceGroupInfo) Test(org.testng.annotations.Test)

Example 4 with QueryStateInfo

use of com.facebook.presto.server.QueryStateInfo in project presto by prestodb.

the class TestDistributedQueryInfoResource method testGetAllQueryInfo.

@Test(timeOut = 220_000, enabled = false)
public void testGetAllQueryInfo() throws Exception {
    runToCompletion(client, coordinator1, "SELECT 1");
    runToFirstResult(client, coordinator2, "SELECT * from tpch.sf100.orders");
    runToFirstResult(client, coordinator1, "SELECT * from tpch.sf101.orders");
    sleep(SECONDS.toMillis(5));
    // TODO the count of coordinator drops from 2 sometimes, we need to investigate the cause and remove this
    waitUntilCoordinatorsDiscoveredHealthyInRM(SECONDS.toMillis(15));
    List<QueryStateInfo> queryInfos = getQueryStateInfos(client, coordinator1, "/v1/queryState");
    assertEquals(queryInfos.size(), 2);
    for (QueryStateInfo inputQueryInfo : queryInfos) {
        QueryStateInfo queryInfoResult = getQueryStateInfo(client, coordinator1, "/v1/queryState/" + inputQueryInfo.getQueryId().getId());
        assertNotNull(queryInfoResult);
        assertEquals(queryInfoResult.getQueryId(), inputQueryInfo.getQueryId());
    }
}
Also used : QueryExecutionClientUtil.getQueryStateInfo(com.facebook.presto.utils.QueryExecutionClientUtil.getQueryStateInfo) QueryStateInfo(com.facebook.presto.server.QueryStateInfo) Test(org.testng.annotations.Test)

Aggregations

QueryStateInfo (com.facebook.presto.server.QueryStateInfo)4 Test (org.testng.annotations.Test)2 MockManagedQueryExecution (com.facebook.presto.execution.MockManagedQueryExecution)1 RootInternalResourceGroup (com.facebook.presto.execution.resourceGroups.InternalResourceGroup.RootInternalResourceGroup)1 InternalNode (com.facebook.presto.metadata.InternalNode)1 ResourceGroupInfo (com.facebook.presto.server.ResourceGroupInfo)1 QueryExecutionClientUtil.getQueryStateInfo (com.facebook.presto.utils.QueryExecutionClientUtil.getQueryStateInfo)1 ImmutableList (com.google.common.collect.ImmutableList)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 DataSize (io.airlift.units.DataSize)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 GET (javax.ws.rs.GET)1 WebApplicationException (javax.ws.rs.WebApplicationException)1