Search in sources :

Example 26 with InternalNode

use of com.facebook.presto.metadata.InternalNode 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 27 with InternalNode

use of com.facebook.presto.metadata.InternalNode in project presto by prestodb.

the class DistributedResourceGroupInfoResource method getResourceGroupInfos.

@GET
@Produces(MediaType.APPLICATION_JSON)
@Encoded
@Path("{resourceGroupId: .+}")
public void getResourceGroupInfos(@PathParam("resourceGroupId") String resourceGroupIdString, @Context UriInfo uriInfo, @Context HttpServletRequest servletRequest, @Suspended AsyncResponse asyncResponse) {
    if (isNullOrEmpty(resourceGroupIdString)) {
        asyncResponse.resume(Response.status(NOT_FOUND).build());
    }
    try {
        ImmutableList.Builder<ListenableFuture<ResourceGroupInfo>> resourceGroupInfoFutureBuilder = ImmutableList.builder();
        for (InternalNode coordinator : internalNodeManager.getCoordinators()) {
            resourceGroupInfoFutureBuilder.add(getResourceGroupInfoFromCoordinator(uriInfo, coordinator));
        }
        List<ListenableFuture<ResourceGroupInfo>> resourceGroupInfoFutureList = resourceGroupInfoFutureBuilder.build();
        Futures.whenAllComplete(resourceGroupInfoFutureList).call(() -> {
            try {
                ResourceGroupInfo aggregatedResourceGroupInfo = aggregateResourceGroupInfo(resourceGroupInfoFutureList);
                if (aggregatedResourceGroupInfo == null) {
                    return asyncResponse.resume(Response.status(NOT_FOUND).build());
                }
                return asyncResponse.resume(Response.ok(aggregatedResourceGroupInfo).build());
            } catch (Exception ex) {
                log.error(ex, "Error in getting resource group info from one of the coordinators");
                return asyncResponse.resume(Response.serverError().entity(ex.getMessage()).build());
            }
        }, executor);
    } catch (IOException ex) {
        log.error(ex, "Error in getting resource group info");
        asyncResponse.resume(Response.serverError().entity(ex.getMessage()).build());
    }
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InternalNode(com.facebook.presto.metadata.InternalNode) IOException(java.io.IOException) ResourceGroupInfo(com.facebook.presto.server.ResourceGroupInfo) UnexpectedResponseException(com.facebook.airlift.http.client.UnexpectedResponseException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Path(javax.ws.rs.Path) Encoded(javax.ws.rs.Encoded) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 28 with InternalNode

use of com.facebook.presto.metadata.InternalNode in project presto by prestodb.

the class BenchmarkNodeScheduler method benchmark.

@Benchmark
@OperationsPerInvocation(SPLITS)
public Object benchmark(BenchmarkData data) {
    List<RemoteTask> remoteTasks = ImmutableList.copyOf(data.getTaskMap().values());
    Iterator<MockRemoteTaskFactory.MockRemoteTask> finishingTask = Iterators.cycle(data.getTaskMap().values());
    Iterator<Split> splits = data.getSplits().iterator();
    Set<Split> batch = new HashSet<>();
    while (splits.hasNext() || !batch.isEmpty()) {
        Multimap<InternalNode, Split> assignments = data.getNodeSelector().computeAssignments(batch, remoteTasks).getAssignments();
        for (InternalNode node : assignments.keySet()) {
            MockRemoteTaskFactory.MockRemoteTask remoteTask = data.getTaskMap().get(node);
            remoteTask.addSplits(ImmutableMultimap.<PlanNodeId, Split>builder().putAll(new PlanNodeId("sourceId"), assignments.get(node)).build());
            remoteTask.startSplits(MAX_SPLITS_PER_NODE);
        }
        if (assignments.size() == batch.size()) {
            batch.clear();
        } else {
            batch.removeAll(assignments.values());
        }
        while (batch.size() < SPLIT_BATCH_SIZE && splits.hasNext()) {
            batch.add(splits.next());
        }
        finishingTask.next().finishSplits((int) Math.ceil(MAX_SPLITS_PER_NODE / 50.0));
    }
    return remoteTasks;
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) InternalNode(com.facebook.presto.metadata.InternalNode) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit) Split(com.facebook.presto.metadata.Split) HashSet(java.util.HashSet) Benchmark(org.openjdk.jmh.annotations.Benchmark) OperationsPerInvocation(org.openjdk.jmh.annotations.OperationsPerInvocation)

Example 29 with InternalNode

use of com.facebook.presto.metadata.InternalNode in project presto by prestodb.

the class TestClusterSizeMonitor method addCoordinator.

private void addCoordinator(InMemoryNodeManager nodeManager) {
    String identifier = "coordinator/" + numCoordinators.incrementAndGet();
    nodeManager.addNode(CONNECTOR_ID, new InternalNode(identifier, URI.create("localhost/" + identifier), new NodeVersion("1"), true));
}
Also used : NodeVersion(com.facebook.presto.client.NodeVersion) InternalNode(com.facebook.presto.metadata.InternalNode)

Example 30 with InternalNode

use of com.facebook.presto.metadata.InternalNode in project presto by prestodb.

the class TestClusterSizeMonitor method addResourceManager.

private void addResourceManager(InMemoryNodeManager nodeManager) {
    String identifier = "resource_manager/" + numResourceManagers.incrementAndGet();
    nodeManager.addNode(CONNECTOR_ID, new InternalNode(identifier, URI.create("localhost/" + identifier), new NodeVersion("1"), false, true));
}
Also used : NodeVersion(com.facebook.presto.client.NodeVersion) InternalNode(com.facebook.presto.metadata.InternalNode)

Aggregations

InternalNode (com.facebook.presto.metadata.InternalNode)74 Split (com.facebook.presto.metadata.Split)34 Test (org.testng.annotations.Test)34 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)25 HashSet (java.util.HashSet)24 ImmutableList (com.google.common.collect.ImmutableList)17 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)14 SplitPlacementResult (com.facebook.presto.execution.scheduler.SplitPlacementResult)13 NodeSelectionStats (com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats)12 NodeSelector (com.facebook.presto.execution.scheduler.nodeSelection.NodeSelector)12 ImmutableSet (com.google.common.collect.ImmutableSet)12 SimpleTtlNodeSelectorConfig (com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig)11 ConnectorId (com.facebook.presto.spi.ConnectorId)11 TestingTransactionHandle (com.facebook.presto.testing.TestingTransactionHandle)11 Duration (io.airlift.units.Duration)11 URI (java.net.URI)11 Map (java.util.Map)11 RemoteTask (com.facebook.presto.execution.RemoteTask)10 NodeScheduler (com.facebook.presto.execution.scheduler.NodeScheduler)10 NodeSchedulerConfig (com.facebook.presto.execution.scheduler.NodeSchedulerConfig)9