use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestQueues method testRunningQuery.
@Test(timeOut = 60_000)
public void testRunningQuery() throws Exception {
try (DistributedQueryRunner queryRunner = getSimpleQueryRunner()) {
queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
while (true) {
TimeUnit.SECONDS.sleep(2);
ResourceGroupInfo global = queryRunner.getCoordinator().getResourceGroupManager().get().getResourceGroupInfo(new ResourceGroupId(new ResourceGroupId("global"), "bi-user"));
if (global.getSoftMemoryLimit().toBytes() > 0) {
break;
}
}
}
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class InternalResourceGroupManager method submit.
@Override
public void submit(Statement statement, QueryExecution queryExecution, Executor executor) {
checkState(configurationManager.get() != null, "configurationManager not set");
ResourceGroupId group;
try {
group = selectGroup(queryExecution.getSession());
} catch (PrestoException e) {
queryExecution.fail(e);
return;
}
createGroupIfNecessary(group, queryExecution.getSession(), executor);
groups.get(group).run(queryExecution);
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestResourceManagerClusterStateProvider method assertResourceGroup.
private void assertResourceGroup(ResourceManagerClusterStateProvider provider, String excludingNode, String resourceGroupId, int queuedQueries, int runningQueries, DataSize userMemoryReservation) throws ResourceManagerInconsistentException {
ResourceGroupId currResourceGroupId = new ResourceGroupId(Arrays.asList(resourceGroupId.split("\\.")));
List<ResourceGroupRuntimeInfo> list = provider.getClusterResourceGroups(excludingNode);
Optional<ResourceGroupRuntimeInfo> resourceGroupRuntimeInfo = list.stream().filter(resourceGroupInfo -> currResourceGroupId.equals(resourceGroupInfo.getResourceGroupId())).findFirst();
assertTrue(resourceGroupRuntimeInfo.isPresent(), "Resource group " + resourceGroupId + " not found");
ResourceGroupRuntimeInfo info = resourceGroupRuntimeInfo.get();
ResourceGroupId rg = new ResourceGroupId(Arrays.asList(resourceGroupId.split("\\.")));
assertEquals(info.getQueuedQueries(), queuedQueries, format("Expected %s queued queries, found %s", queuedQueries, info.getQueuedQueries()));
assertEquals(info.getRunningQueries(), runningQueries, format("Expected %s running queries, found %s", runningQueries, info.getRunningQueries()));
assertEquals(info.getResourceGroupId(), rg, format("Expected resource group id %s, found %s", resourceGroupId, info.getResourceGroupId()));
assertEquals(info.getMemoryUsageBytes(), userMemoryReservation.toBytes(), format("Expected %s user memory reservation found %s", userMemoryReservation, DataSize.succinctBytes(info.getMemoryUsageBytes())));
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestResourceManagerClusterStateProvider method assertNonLeafResourceGroup.
private void assertNonLeafResourceGroup(ResourceManagerClusterStateProvider provider, String excludingNode, String resourceGroupId, int queuedQueries, int runningQueries, int descendantQueuedQueries, int descendantRunningQueries) throws ResourceManagerInconsistentException {
List<ResourceGroupRuntimeInfo> resourceGroupRuntimeInfos = provider.getClusterResourceGroups(excludingNode);
Optional<ResourceGroupRuntimeInfo> resourceGroupRuntimeInfo = provider.getClusterResourceGroups(excludingNode).stream().filter(resourceGroupInfo -> new ResourceGroupId(resourceGroupId).equals(resourceGroupInfo.getResourceGroupId())).findFirst();
assertTrue(resourceGroupRuntimeInfo.isPresent(), "Resource group " + resourceGroupId + " not found");
ResourceGroupRuntimeInfo info = resourceGroupRuntimeInfo.get();
assertEquals(info.getQueuedQueries(), queuedQueries, format("Expected %s queued queries, found %s", queuedQueries, info.getQueuedQueries()));
assertEquals(info.getRunningQueries(), runningQueries, format("Expected %s running queries, found %s", runningQueries, info.getRunningQueries()));
assertEquals(info.getDescendantQueuedQueries(), descendantQueuedQueries, format("Expected %s descendant queued queries, found %s", descendantQueuedQueries, info.getDescendantQueuedQueries()));
assertEquals(info.getDescendantRunningQueries(), descendantRunningQueries, format("Expected %s descendant running queries, found %s", descendantRunningQueries, info.getDescendantRunningQueries()));
assertEquals(info.getResourceGroupId(), new ResourceGroupId(resourceGroupId), format("Expected resource group id %s, found %s", resourceGroupId, info.getResourceGroupId()));
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestResourceManagerResourceGroupService method testGetResourceGroupInfo.
@Test
public void testGetResourceGroupInfo() throws Exception {
TestingResourceManagerClient resourceManagerClient = new TestingResourceManagerClient();
InMemoryNodeManager nodeManager = new InMemoryNodeManager();
ResourceManagerConfig resourceManagerConfig = new ResourceManagerConfig();
ResourceManagerResourceGroupService service = new ResourceManagerResourceGroupService((addressSelectionContext, headers) -> resourceManagerClient, resourceManagerConfig, nodeManager);
List<ResourceGroupRuntimeInfo> resourceGroupInfos = service.getResourceGroupInfo();
assertNotNull(resourceGroupInfos);
assertTrue(resourceGroupInfos.isEmpty());
assertEquals(resourceManagerClient.getResourceGroupInfoCalls("local"), 1);
resourceManagerClient.setResourceGroupRuntimeInfos(ImmutableList.of(new ResourceGroupRuntimeInfo(new ResourceGroupId("global"), 1, 2, 3, 0, 1)));
Thread.sleep(SECONDS.toMillis(2));
resourceGroupInfos = service.getResourceGroupInfo();
assertNotNull(resourceGroupInfos);
assertEquals(resourceGroupInfos.size(), 1);
assertEquals(resourceManagerClient.getResourceGroupInfoCalls("local"), 2);
}
Aggregations