use of com.facebook.presto.execution.MockManagedQueryExecution in project presto by prestodb.
the class TestResourceGroups method testMemoryLimit.
@Test(timeOut = 10_000)
public void testMemoryLimit() {
RootInternalResourceGroup root = new RootInternalResourceGroup("root", (group, export) -> {
}, directExecutor(), ignored -> Optional.empty(), rg -> false);
root.setSoftMemoryLimit(new DataSize(1, BYTE));
root.setMaxQueuedQueries(4);
root.setHardConcurrencyLimit(3);
MockManagedQueryExecution query1 = new MockManagedQueryExecution(2);
query1.startWaitingForPrerequisites();
root.run(query1);
// Process the group to refresh stats
root.processQueuedQueries();
assertEquals(query1.getState(), RUNNING);
MockManagedQueryExecution query2 = new MockManagedQueryExecution(0);
query2.startWaitingForPrerequisites();
root.run(query2);
assertEquals(query2.getState(), QUEUED);
MockManagedQueryExecution query3 = new MockManagedQueryExecution(0);
query3.startWaitingForPrerequisites();
root.run(query3);
assertEquals(query3.getState(), QUEUED);
query1.complete();
root.processQueuedQueries();
assertEquals(query2.getState(), RUNNING);
assertEquals(query3.getState(), RUNNING);
}
use of com.facebook.presto.execution.MockManagedQueryExecution in project presto by prestodb.
the class TestResourceGroups method testSetSchedulingPolicy.
@Test
public void testSetSchedulingPolicy() {
RootInternalResourceGroup root = new RootInternalResourceGroup("root", (group, export) -> {
}, directExecutor(), ignored -> Optional.empty(), rg -> false);
root.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
root.setMaxQueuedQueries(4);
root.setHardConcurrencyLimit(1);
InternalResourceGroup group1 = root.getOrCreateSubGroup("1", true);
group1.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
group1.setMaxQueuedQueries(4);
group1.setHardConcurrencyLimit(2);
InternalResourceGroup group2 = root.getOrCreateSubGroup("2", true);
group2.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
group2.setMaxQueuedQueries(4);
group2.setHardConcurrencyLimit(2);
MockManagedQueryExecution query1a = new MockManagedQueryExecution(0);
query1a.startWaitingForPrerequisites();
group1.run(query1a);
assertEquals(query1a.getState(), RUNNING);
MockManagedQueryExecution query1b = new MockManagedQueryExecution(0);
query1b.startWaitingForPrerequisites();
group1.run(query1b);
assertEquals(query1b.getState(), QUEUED);
MockManagedQueryExecution query1c = new MockManagedQueryExecution(0);
query1c.startWaitingForPrerequisites();
group1.run(query1c);
assertEquals(query1c.getState(), QUEUED);
MockManagedQueryExecution query2a = new MockManagedQueryExecution(0);
query2a.startWaitingForPrerequisites();
group2.run(query2a);
assertEquals(query2a.getState(), QUEUED);
assertEquals(root.getInfo().getNumEligibleSubGroups(), 2);
assertEquals(root.getOrCreateSubGroup("1", true).getQueuedQueries(), 2);
assertEquals(root.getOrCreateSubGroup("2", true).getQueuedQueries(), 1);
assertEquals(root.getSchedulingPolicy(), FAIR);
root.setSchedulingPolicy(QUERY_PRIORITY);
assertEquals(root.getInfo().getNumEligibleSubGroups(), 2);
assertEquals(root.getOrCreateSubGroup("1", true).getQueuedQueries(), 2);
assertEquals(root.getOrCreateSubGroup("2", true).getQueuedQueries(), 1);
assertEquals(root.getSchedulingPolicy(), QUERY_PRIORITY);
assertEquals(root.getOrCreateSubGroup("1", true).getSchedulingPolicy(), QUERY_PRIORITY);
assertEquals(root.getOrCreateSubGroup("2", true).getSchedulingPolicy(), QUERY_PRIORITY);
}
use of com.facebook.presto.execution.MockManagedQueryExecution in project presto by prestodb.
the class TestResourceGroups method testQueueFull.
@Test(timeOut = 10_000)
public void testQueueFull() {
RootInternalResourceGroup root = new RootInternalResourceGroup("root", (group, export) -> {
}, directExecutor(), ignored -> Optional.empty(), rg -> false);
root.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
root.setMaxQueuedQueries(1);
root.setHardConcurrencyLimit(1);
MockManagedQueryExecution query1 = new MockManagedQueryExecution(0);
query1.startWaitingForPrerequisites();
root.run(query1);
assertEquals(query1.getState(), RUNNING);
MockManagedQueryExecution query2 = new MockManagedQueryExecution(0);
query2.startWaitingForPrerequisites();
root.run(query2);
assertEquals(query2.getState(), QUEUED);
MockManagedQueryExecution query3 = new MockManagedQueryExecution(0);
query3.startWaitingForPrerequisites();
root.run(query3);
assertEquals(query3.getState(), FAILED);
assertEquals(query3.getThrowable().getMessage(), "Too many queued queries for \"root\"");
}
use of com.facebook.presto.execution.MockManagedQueryExecution in project presto by prestodb.
the class TestResourceGroups method testGetBlockedQueuedQueries.
@Test
public void testGetBlockedQueuedQueries() {
RootInternalResourceGroup root = new RootInternalResourceGroup("root", (group, export) -> {
}, directExecutor(), ignored -> Optional.empty(), rg -> false);
root.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
root.setMaxQueuedQueries(40);
// Start with zero capacity, so that nothing starts running until we've added all the queries
root.setHardConcurrencyLimit(0);
InternalResourceGroup rootA = root.getOrCreateSubGroup("a", true);
rootA.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
rootA.setMaxQueuedQueries(20);
rootA.setHardConcurrencyLimit(8);
InternalResourceGroup rootAX = rootA.getOrCreateSubGroup("x", true);
rootAX.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
rootAX.setMaxQueuedQueries(10);
rootAX.setHardConcurrencyLimit(8);
InternalResourceGroup rootAY = rootA.getOrCreateSubGroup("y", true);
rootAY.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
rootAY.setMaxQueuedQueries(10);
rootAY.setHardConcurrencyLimit(5);
InternalResourceGroup rootB = root.getOrCreateSubGroup("b", true);
rootB.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
rootB.setMaxQueuedQueries(20);
rootB.setHardConcurrencyLimit(8);
InternalResourceGroup rootBX = rootB.getOrCreateSubGroup("x", true);
rootBX.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
rootBX.setMaxQueuedQueries(10);
rootBX.setHardConcurrencyLimit(8);
InternalResourceGroup rootBY = rootB.getOrCreateSubGroup("y", true);
rootBY.setSoftMemoryLimit(new DataSize(1, MEGABYTE));
rootBY.setMaxQueuedQueries(10);
rootBY.setHardConcurrencyLimit(5);
// Queue 40 queries (= maxQueuedQueries (40) + maxRunningQueries (0))
Set<MockManagedQueryExecution> queries = fillGroupTo(rootAX, ImmutableSet.of(), 10, false);
queries.addAll(fillGroupTo(rootAY, ImmutableSet.of(), 10, false));
queries.addAll(fillGroupTo(rootBX, ImmutableSet.of(), 10, true));
queries.addAll(fillGroupTo(rootBY, ImmutableSet.of(), 10, true));
assertEquals(root.getWaitingQueuedQueries(), 16);
assertEquals(rootA.getWaitingQueuedQueries(), 13);
assertEquals(rootAX.getWaitingQueuedQueries(), 10);
assertEquals(rootAY.getWaitingQueuedQueries(), 10);
assertEquals(rootB.getWaitingQueuedQueries(), 13);
assertEquals(rootBX.getWaitingQueuedQueries(), 10);
assertEquals(rootBY.getWaitingQueuedQueries(), 10);
root.setHardConcurrencyLimit(20);
root.processQueuedQueries();
assertEquals(root.getWaitingQueuedQueries(), 0);
assertEquals(rootA.getWaitingQueuedQueries(), 5);
assertEquals(rootAX.getWaitingQueuedQueries(), 6);
assertEquals(rootAY.getWaitingQueuedQueries(), 6);
assertEquals(rootB.getWaitingQueuedQueries(), 5);
assertEquals(rootBX.getWaitingQueuedQueries(), 6);
assertEquals(rootBY.getWaitingQueuedQueries(), 6);
}
Aggregations