use of io.prestosql.execution.MockManagedQueryExecution in project hetu-core by openlookeng.
the class TestResourceGroups method fillGroupTo.
private static Set<MockManagedQueryExecution> fillGroupTo(InternalResourceGroup group, Set<MockManagedQueryExecution> existingQueries, int count, boolean queryPriority) {
int existingCount = existingQueries.size();
Set<MockManagedQueryExecution> queries = new HashSet<>(existingQueries);
for (int i = 0; i < count - existingCount; i++) {
MockManagedQueryExecution query = new MockManagedQueryExecution(0, group.getId().toString().replace(".", "") + Integer.toString(i), queryPriority ? i + 1 : 1);
queries.add(query);
group.run(query);
}
return queries;
}
use of io.prestosql.execution.MockManagedQueryExecution in project hetu-core by openlookeng.
the class TestResourceGroups method testSoftReservedMemory.
// new test case for softReservedMemory
@Test
public void testSoftReservedMemory() {
InternalResourceGroup root = new InternalResourceGroup(Optional.empty(), "root", (group, export) -> {
}, directExecutor());
root.setSoftMemoryLimit(new DataSize(10, BYTE));
root.setMaxQueuedQueries(10);
root.setHardConcurrencyLimit(10);
// three subgroup with setSoftReservedMemory = 1 byte
InternalResourceGroup group1 = root.getOrCreateSubGroup("group1");
group1.setSoftMemoryLimit(new DataSize(5, BYTE));
group1.setMaxQueuedQueries(4);
group1.setHardConcurrencyLimit(3);
group1.setSoftReservedMemory(new DataSize(1, BYTE));
InternalResourceGroup group2 = root.getOrCreateSubGroup("group2");
group2.setSoftMemoryLimit(new DataSize(5, BYTE));
group2.setMaxQueuedQueries(4);
group2.setHardConcurrencyLimit(3);
group2.setSoftReservedMemory(new DataSize(1, BYTE));
InternalResourceGroup group3 = root.getOrCreateSubGroup("group3");
group3.setSoftMemoryLimit(new DataSize(5, BYTE));
group3.setMaxQueuedQueries(4);
group3.setHardConcurrencyLimit(3);
group3.setSoftReservedMemory(new DataSize(1, BYTE));
MockManagedQueryExecution query1 = new MockManagedQueryExecution(5);
MockManagedQueryExecution query2 = new MockManagedQueryExecution(4);
group1.run(query1);
group2.run(query2);
// group1 memory usage = 5M, group2 memory usage = 4M, group3 memory usage = 0
assertEquals(query1.getState(), RUNNING);
assertEquals(query2.getState(), RUNNING);
root.processQueuedQueries();
MockManagedQueryExecution extraQuery = new MockManagedQueryExecution(1);
group2.run(extraQuery);
assertEquals(extraQuery.getState(), QUEUED);
}
use of io.prestosql.execution.MockManagedQueryExecution in project hetu-core by openlookeng.
the class TestResourceGroups method testQueryKill.
@Test(timeOut = 10_000)
public void testQueryKill() {
InternalResourceGroup root = new InternalResourceGroup(Optional.empty(), "root", (group, export) -> {
}, directExecutor());
root.setSoftMemoryLimit(new DataSize(1, BYTE));
root.setMaxQueuedQueries(4);
root.setHardConcurrencyLimit(3);
root.setKillPolicy(KillPolicy.RECENT_QUERIES);
MockManagedQueryExecution query1 = new MockManagedQueryExecution(2);
root.run(query1);
// Process the group to refresh stats
root.processQueuedQueries();
assertEquals(query1.getState(), FAILED);
}
use of io.prestosql.execution.MockManagedQueryExecution in project hetu-core by openlookeng.
the class TestResourceGroups method testQueryKillRecent.
@Test(timeOut = 10_000)
public void testQueryKillRecent() throws InterruptedException {
InternalResourceGroup root = new InternalResourceGroup(Optional.empty(), "root", (group, export) -> {
}, directExecutor());
root.setSoftMemoryLimit(new DataSize(2, BYTE));
root.setMaxQueuedQueries(4);
root.setHardConcurrencyLimit(3);
root.setKillPolicy(KillPolicy.RECENT_QUERIES);
MockManagedQueryExecution query1 = new MockManagedQueryExecution(2);
MILLISECONDS.sleep(1);
root.run(query1);
MockManagedQueryExecution query2 = new MockManagedQueryExecution(2);
MILLISECONDS.sleep(1);
root.run(query2);
MockManagedQueryExecution query3 = new MockManagedQueryExecution(2);
root.run(query3);
// Process the group to refresh stats
root.processQueuedQueries();
assertEquals(query1.getState(), RUNNING);
assertEquals(query2.getState(), FAILED);
assertEquals(query3.getState(), FAILED);
}
use of io.prestosql.execution.MockManagedQueryExecution in project hetu-core by openlookeng.
the class TestResourceGroups method testHardCpuLimit.
@Test(timeOut = 10_000)
public void testHardCpuLimit() {
InternalResourceGroup root = new InternalResourceGroup(Optional.empty(), "root", (group, export) -> {
}, directExecutor());
root.setSoftMemoryLimit(new DataSize(1, BYTE));
root.setHardCpuLimit(new Duration(1, SECONDS));
root.setCpuQuotaGenerationMillisPerSecond(2000);
root.setMaxQueuedQueries(1);
root.setHardConcurrencyLimit(1);
MockManagedQueryExecution query1 = new MockManagedQueryExecution(1, "query_id", 1, new Duration(2, SECONDS));
root.run(query1);
assertEquals(query1.getState(), RUNNING);
MockManagedQueryExecution query2 = new MockManagedQueryExecution(0);
root.run(query2);
assertEquals(query2.getState(), QUEUED);
query1.complete();
root.processQueuedQueries();
assertEquals(query2.getState(), QUEUED);
root.generateCpuQuota(2);
root.processQueuedQueries();
assertEquals(query2.getState(), RUNNING);
}
Aggregations