Search in sources :

Example 6 with DispatchManager

use of io.prestosql.dispatcher.DispatchManager in project hetu-core by openlookeng.

the class TestOracleDistributedQueries method testQueryLoggingCount.

/**
 * testQueryLoggingCount
 */
@Override
public void testQueryLoggingCount() {
    QueryManager queryManager = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getQueryManager();
    executeExclusively(() -> {
        assertUntilTimeout(() -> assertEquals(queryManager.getQueries().stream().map(BasicQueryInfo::getQueryId).map(queryManager::getFullQueryInfo).filter(info -> !info.isFinalQueryInfo()).collect(toList()), ImmutableList.of()), new Duration(1, MINUTES));
        DispatchManager dispatchManager = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getDispatchManager();
        long beforeCompletedQueriesCount = waitUntilStable(() -> dispatchManager.getStats().getCompletedQueries().getTotalCount(), new Duration(NUMBER_5, SECONDS));
        long beforeSubmittedQueriesCount = dispatchManager.getStats().getSubmittedQueries().getTotalCount();
        assertUpdate("CREATE TABLE test_query_logging_count AS SELECT 1 foo_1, 2 foo_2_4", 1);
        assertQuery("SELECT foo_1, foo_2_4 FROM test_query_logging_count", "SELECT 1, 2");
        assertUpdate("DROP TABLE test_query_logging_count");
        assertQueryFails("SELECT * FROM test_query_logging_count", ".*Table .* does not exist");
        assertUntilTimeout(() -> assertEquals(dispatchManager.getStats().getCompletedQueries().getTotalCount() - beforeCompletedQueriesCount, NUMBER_4), new Duration(1, MINUTES));
        assertEquals(dispatchManager.getStats().getSubmittedQueries().getTotalCount() - beforeSubmittedQueriesCount, NUMBER_4);
    });
}
Also used : IntStream.range(java.util.stream.IntStream.range) SystemSessionProperties(io.prestosql.SystemSessionProperties) QueryInfo(io.prestosql.execution.QueryInfo) Test(org.testng.annotations.Test) Thread.currentThread(java.lang.Thread.currentThread) INFORMATION_SCHEMA(io.prestosql.connector.informationschema.InformationSchemaMetadata.INFORMATION_SCHEMA) MaterializedResult(io.prestosql.testing.MaterializedResult) Duration(io.airlift.units.Duration) ADD_COLUMN(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.ADD_COLUMN) RENAME_TABLE(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.RENAME_TABLE) SET_SESSION(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.SET_SESSION) Assertions(io.airlift.testing.Assertions) QueryManager(io.prestosql.execution.QueryManager) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) Duration.nanosSince(io.airlift.units.Duration.nanosSince) Assert.assertFalse(org.testng.Assert.assertFalse) CREATE_TABLE(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.CREATE_TABLE) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractTestDistributedQueries(io.prestosql.tests.AbstractTestDistributedQueries) OracleQueryRunner.createOracleQueryRunner(io.hetu.core.plugin.oracle.OracleQueryRunner.createOracleQueryRunner) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Uninterruptibles.sleepUninterruptibly(com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly) DROP_COLUMN(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.DROP_COLUMN) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) TpchTable(io.airlift.tpch.TpchTable) CREATE_VIEW(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.CREATE_VIEW) SET_USER(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.SET_USER) Assert.assertNull(org.testng.Assert.assertNull) QueryAssertions.assertContains(io.prestosql.tests.QueryAssertions.assertContains) TESTING_CATALOG(io.prestosql.testing.TestingSession.TESTING_CATALOG) Assert.assertEquals(org.testng.Assert.assertEquals) MINUTES(java.util.concurrent.TimeUnit.MINUTES) Supplier(java.util.function.Supplier) TestingAccessControlManager.privilege(io.prestosql.testing.TestingAccessControlManager.privilege) ImmutableList(com.google.common.collect.ImmutableList) BasicQueryInfo(io.prestosql.server.BasicQueryInfo) Session(io.prestosql.Session) UncheckedTimeoutException(com.google.common.util.concurrent.UncheckedTimeoutException) DispatchManager(io.prestosql.dispatcher.DispatchManager) AfterClass(org.testng.annotations.AfterClass) ResultWithQueryId(io.prestosql.tests.ResultWithQueryId) Language(org.intellij.lang.annotations.Language) QUERY_MAX_MEMORY(io.prestosql.SystemSessionProperties.QUERY_MAX_MEMORY) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) Collectors.toList(java.util.stream.Collectors.toList) DROP_TABLE(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.DROP_TABLE) Assert.assertTrue(org.testng.Assert.assertTrue) RENAME_COLUMN(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.RENAME_COLUMN) SECONDS(java.util.concurrent.TimeUnit.SECONDS) DispatchManager(io.prestosql.dispatcher.DispatchManager) QueryManager(io.prestosql.execution.QueryManager) Duration(io.airlift.units.Duration)

Example 7 with DispatchManager

use of io.prestosql.dispatcher.DispatchManager in project hetu-core by openlookeng.

the class TestMetadataManager method testMetadataIsClearedAfterQueryCanceled.

@Test
public void testMetadataIsClearedAfterQueryCanceled() throws Exception {
    DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
    QueryId queryId = dispatchManager.createQueryId();
    dispatchManager.createQuery(queryId, "slug", new TestingSessionContext(TEST_SESSION), "SELECT * FROM lineitem").get();
    // wait until query starts running
    while (true) {
        BasicQueryInfo queryInfo = dispatchManager.getQueryInfo(queryId);
        if (queryInfo.getState().isDone()) {
            assertEquals(queryInfo.getState(), FAILED);
            throw dispatchManager.getDispatchInfo(queryId).get().getFailureInfo().get().toException();
        }
        if (queryInfo.getState() == RUNNING) {
            break;
        }
        Thread.sleep(100);
    }
    // cancel query
    dispatchManager.cancelQuery(queryId);
    assertEquals(metadataManager.getActiveQueryIds().size(), 0);
}
Also used : DispatchManager(io.prestosql.dispatcher.DispatchManager) TestingSessionContext(io.prestosql.execution.TestingSessionContext) QueryId(io.prestosql.spi.QueryId) BasicQueryInfo(io.prestosql.server.BasicQueryInfo) Test(org.testng.annotations.Test)

Example 8 with DispatchManager

use of io.prestosql.dispatcher.DispatchManager in project hetu-core by openlookeng.

the class TestQueryRunnerUtil method createQuery.

public static QueryId createQuery(DistributedQueryRunner queryRunner, Session session, String sql) {
    DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
    getFutureValue(dispatchManager.createQuery(session.getQueryId(), "slug", new TestingSessionContext(session), sql));
    return session.getQueryId();
}
Also used : DispatchManager(io.prestosql.dispatcher.DispatchManager)

Example 9 with DispatchManager

use of io.prestosql.dispatcher.DispatchManager in project hetu-core by openlookeng.

the class TestQueues method testRejection.

private void testRejection() throws Exception {
    try (DistributedQueryRunner queryRunner = createQueryRunner()) {
        queryRunner.installPlugin(new ResourceGroupManagerPlugin());
        queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
        QueryId queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
        waitForQueryState(queryRunner, queryId, FAILED);
        DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
        assertEquals(dispatchManager.getQueryInfo(queryId).getErrorCode(), QUERY_REJECTED.toErrorCode());
    }
}
Also used : DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) DispatchManager(io.prestosql.dispatcher.DispatchManager) QueryId(io.prestosql.spi.QueryId) ResourceGroupManagerPlugin(io.prestosql.plugin.resourcegroups.ResourceGroupManagerPlugin)

Aggregations

DispatchManager (io.prestosql.dispatcher.DispatchManager)9 Test (org.testng.annotations.Test)7 QueryId (io.prestosql.spi.QueryId)6 QueryManager (io.prestosql.execution.QueryManager)5 BasicQueryInfo (io.prestosql.server.BasicQueryInfo)5 QueryInfo (io.prestosql.execution.QueryInfo)3 DbResourceGroupConfigurationManager (io.prestosql.plugin.resourcegroups.db.DbResourceGroupConfigurationManager)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)2 UncheckedTimeoutException (com.google.common.util.concurrent.UncheckedTimeoutException)2 Uninterruptibles.sleepUninterruptibly (com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly)2 Assertions (io.airlift.testing.Assertions)2 Duration (io.airlift.units.Duration)2 Duration.nanosSince (io.airlift.units.Duration.nanosSince)2 Session (io.prestosql.Session)2 SystemSessionProperties (io.prestosql.SystemSessionProperties)2 QUERY_MAX_MEMORY (io.prestosql.SystemSessionProperties.QUERY_MAX_MEMORY)2 INFORMATION_SCHEMA (io.prestosql.connector.informationschema.InformationSchemaMetadata.INFORMATION_SCHEMA)2