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());
}
}
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());
}
}
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;
}
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));
}
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));
}
Aggregations