use of com.facebook.presto.execution.resourceGroups.ResourceGroupRuntimeInfo 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.execution.resourceGroups.ResourceGroupRuntimeInfo 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);
}
use of com.facebook.presto.execution.resourceGroups.ResourceGroupRuntimeInfo in project presto by prestodb.
the class TestDistributedClusterStatsResource method getGlobalQueryCountIfAvailable.
private Optional<Integer> getGlobalQueryCountIfAvailable(QueryState state, TestingPrestoServer coordinator) {
Map<ResourceGroupId, ResourceGroupRuntimeInfo> resourceGroupRuntimeInfoSnapshot = coordinator.getResourceGroupManager().get().getResourceGroupRuntimeInfosSnapshot();
ResourceGroupRuntimeInfo resourceGroupRuntimeInfo = resourceGroupRuntimeInfoSnapshot.get(new ResourceGroupId(RESOURCE_GROUP_GLOBAL));
if (resourceGroupRuntimeInfo == null) {
return Optional.empty();
}
int queryCount = 0;
switch(state) {
case RUNNING:
queryCount = resourceGroupRuntimeInfo.getDescendantRunningQueries();
break;
case QUEUED:
queryCount = resourceGroupRuntimeInfo.getDescendantQueuedQueries();
break;
default:
fail(format("Unexpected query state %s", state));
}
return Optional.of(queryCount);
}
use of com.facebook.presto.execution.resourceGroups.ResourceGroupRuntimeInfo in project presto by prestodb.
the class TestDistributedQueuesDb method testDistributedQueue_burstTraffic.
@Test(timeOut = 2_000)
public void testDistributedQueue_burstTraffic() throws Exception {
QueryId firstAdhocQuery = createQuery(queryRunner, 1, testSession(new Identity("user1", Optional.empty())), LONG_LASTING_QUERY);
QueryId secondAdhocQuery = createQuery(queryRunner, 0, testSession(new Identity("user2", Optional.empty())), LONG_LASTING_QUERY);
QueryId thirdAdhocQuery = createQuery(queryRunner, 1, testSession(new Identity("user3", Optional.empty())), LONG_LASTING_QUERY);
QueryId fourthAdhocQuery = createQuery(queryRunner, 0, testSession(new Identity("user4", Optional.empty())), LONG_LASTING_QUERY);
Map<ResourceGroupId, ResourceGroupRuntimeInfo> resourceGroupRuntimeInfoSnapshot;
int globalRunningQueries = 0;
int globalQueriedQueries = 0;
do {
MILLISECONDS.sleep(100);
globalRunningQueries = 0;
globalQueriedQueries = 0;
for (int coordinator = 0; coordinator < 2; coordinator++) {
resourceGroupRuntimeInfoSnapshot = queryRunner.getCoordinator(coordinator).getResourceGroupManager().get().getResourceGroupRuntimeInfosSnapshot();
ResourceGroupRuntimeInfo resourceGroupRuntimeInfo = resourceGroupRuntimeInfoSnapshot.get(new ResourceGroupId("global"));
if (resourceGroupRuntimeInfo != null) {
globalRunningQueries += resourceGroupRuntimeInfo.getDescendantRunningQueries();
globalQueriedQueries += resourceGroupRuntimeInfo.getDescendantQueuedQueries();
}
}
} while (globalRunningQueries != 3 && globalQueriedQueries != 1);
}
Aggregations