use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestLocalDispatchQuery method testQueryQueuedExceptionBeforeDispatch.
@Test
public void testQueryQueuedExceptionBeforeDispatch() {
QueryStateMachine stateMachine = createStateMachine();
CountingEventListener eventListener = new CountingEventListener();
SettableFuture<QueryExecution> queryExecutionFuture = SettableFuture.create();
LocalDispatchQuery query = new LocalDispatchQuery(stateMachine, createQueryMonitor(eventListener), queryExecutionFuture, createClusterSizeMonitor(0), directExecutor(), dispatchQuery -> {
throw new QueryQueueFullException(new ResourceGroupId("global"));
}, execution -> {
}, false, QUERY_PREREQUISITES);
query.startWaitingForPrerequisites();
queryExecutionFuture.setException(new IllegalStateException("abc"));
assertEquals(query.getBasicQueryInfo().getState(), FAILED);
assertEquals(query.getBasicQueryInfo().getErrorCode(), QUERY_QUEUE_FULL.toErrorCode());
assertTrue(eventListener.getQueryCompletedEvent().isPresent());
assertTrue(eventListener.getQueryCompletedEvent().get().getFailureInfo().isPresent());
assertEquals(eventListener.getQueryCompletedEvent().get().getFailureInfo().get().getErrorCode(), QUERY_QUEUE_FULL.toErrorCode());
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestCreateMaterializedViewTask method testCreateMaterializedViewNotExistsTrue.
@Test
public void testCreateMaterializedViewNotExistsTrue() {
SqlParser parser = new SqlParser();
String sql = String.format("CREATE MATERIALIZED VIEW IF NOT EXISTS %s AS SELECT 2021 AS col_0 FROM %s", MATERIALIZED_VIEW_A, TABLE_A);
CreateMaterializedView statement = (CreateMaterializedView) parser.createStatement(sql, ParsingOptions.builder().build());
QueryStateMachine stateMachine = QueryStateMachine.begin(sql, Optional.empty(), testSession, URI.create("fake://uri"), new ResourceGroupId("test"), Optional.empty(), false, transactionManager, accessControl, executorService, metadata, WarningCollector.NOOP);
WarningCollector warningCollector = stateMachine.getWarningCollector();
CreateMaterializedViewTask createMaterializedViewTask = new CreateMaterializedViewTask(parser);
getFutureValue(createMaterializedViewTask.execute(statement, transactionManager, metadata, accessControl, testSession, emptyList(), warningCollector));
assertEquals(metadata.getCreateMaterializedViewCallCount(), 1);
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestCreateMaterializedViewTask method testCreateMaterializedViewExistsFalse.
@Test
public void testCreateMaterializedViewExistsFalse() {
SqlParser parser = new SqlParser();
String sql = String.format("CREATE MATERIALIZED VIEW %s AS SELECT 2021 AS col_0 FROM %s", MATERIALIZED_VIEW_B, TABLE_A);
CreateMaterializedView statement = (CreateMaterializedView) parser.createStatement(sql, ParsingOptions.builder().build());
QueryStateMachine stateMachine = QueryStateMachine.begin(sql, Optional.empty(), testSession, URI.create("fake://uri"), new ResourceGroupId("test"), Optional.empty(), false, transactionManager, accessControl, executorService, metadata, WarningCollector.NOOP);
WarningCollector warningCollector = stateMachine.getWarningCollector();
try {
getFutureValue(new CreateMaterializedViewTask(parser).execute(statement, transactionManager, metadata, accessControl, testSession, emptyList(), warningCollector));
fail("expected exception");
} catch (RuntimeException e) {
// Expected
assertTrue(e instanceof PrestoException);
PrestoException prestoException = (PrestoException) e;
assertEquals(prestoException.getErrorCode(), ALREADY_EXISTS.toErrorCode());
}
assertEquals(metadata.getCreateMaterializedViewCallCount(), 0);
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestResourceGroupIntegration method testMemoryFraction.
@Test(timeOut = 60_000)
public void testMemoryFraction() throws Exception {
try (DistributedQueryRunner queryRunner = getSimpleQueryRunner()) {
queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
while (true) {
TimeUnit.SECONDS.sleep(1);
ResourceGroupInfo global = queryRunner.getCoordinator().getResourceGroupManager().get().getResourceGroupInfo(new ResourceGroupId("global"));
if (global.getSoftMemoryLimit().toBytes() > 0) {
break;
}
}
}
}
use of com.facebook.presto.spi.resourceGroups.ResourceGroupId in project presto by prestodb.
the class TestFileResourceGroupConfigurationManager method testMissing.
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "No matching configuration found for: missing")
public void testMissing() {
ResourceGroupConfigurationManager manager = parse("resource_groups_config.json");
ResourceGroup missing = new TestingResourceGroup(new ResourceGroupId("missing"));
manager.configure(missing, new SelectionContext(true, "user", Optional.empty(), 1));
}
Aggregations