Search in sources :

Example 31 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class TestFinalQueryInfo method createQueryRunner.

public static DistributedQueryRunner createQueryRunner(Session session) throws Exception {
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setNodeCount(2).build();
    try {
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        return queryRunner;
    } catch (Exception e) {
        queryRunner.close();
        throw e;
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin)

Example 32 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class TestDistributedClusterStatsResource method setup.

@BeforeClass
public void setup() throws Exception {
    client = new JettyHttpClient();
    DistributedQueryRunner runner = createQueryRunner(ImmutableMap.of("resource-manager.query-expiration-timeout", "4m", "resource-manager.completed-query-expiration-timeout", "4m"), ImmutableMap.of("query.client.timeout", "20s", "resource-manager.query-heartbeat-interval", "100ms", "resource-group-runtimeinfo-refresh-interval", "100ms", "concurrency-threshold-to-enable-resource-group-refresh", "0.1"), ImmutableMap.of(), COORDINATOR_COUNT);
    coordinator1 = runner.getCoordinator(0);
    coordinator2 = runner.getCoordinator(1);
    Optional<TestingPrestoServer> resourceManager = runner.getResourceManager();
    checkState(resourceManager.isPresent(), "resource manager not present");
    this.resourceManager = resourceManager.get();
    runner.getCoordinators().stream().forEach(coordinator -> {
        coordinator.getResourceGroupManager().get().addConfigurationManagerFactory(new FileResourceGroupConfigurationManagerFactory());
        coordinator.getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath(RESOURCE_GROUPS_CONFIG_FILE)));
    });
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) JettyHttpClient(com.facebook.airlift.http.client.jetty.JettyHttpClient) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) FileResourceGroupConfigurationManagerFactory(com.facebook.presto.resourceGroups.FileResourceGroupConfigurationManagerFactory) BeforeClass(org.testng.annotations.BeforeClass)

Example 33 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class TestQueryResource method setup.

@BeforeClass
public void setup() throws Exception {
    client = new JettyHttpClient();
    DistributedQueryRunner runner = createQueryRunner(ImmutableMap.of("query.client.timeout", "10s"));
    server = runner.getCoordinator();
    server.getResourceGroupManager().get().addConfigurationManagerFactory(new FileResourceGroupConfigurationManagerFactory());
    server.getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_simple.json")));
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) JettyHttpClient(com.facebook.airlift.http.client.jetty.JettyHttpClient) FileResourceGroupConfigurationManagerFactory(com.facebook.presto.resourceGroups.FileResourceGroupConfigurationManagerFactory) BeforeClass(org.testng.annotations.BeforeClass)

Example 34 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class PrometheusQueryRunner method main.

public static void main(String[] args) throws Exception {
    Logging.initialize();
    DistributedQueryRunner queryRunner = createPrometheusQueryRunner(new PrometheusServer());
    Thread.sleep(10);
    Logger log = Logger.get(PrometheusQueryRunner.class);
    log.info("======== SERVER STARTED ========");
    log.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl());
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) Logger(com.facebook.airlift.log.Logger)

Example 35 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class AbstractDeltaDistributedQueryTestBase method createDeltaQueryRunner.

private static DistributedQueryRunner createDeltaQueryRunner(Map<String, String> extraProperties) throws Exception {
    Session session = testSessionBuilder().setCatalog(DELTA_CATALOG).setSchema(DELTA_SCHEMA.toLowerCase(US)).setTimeZoneKey(UTC_KEY).build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setExtraProperties(extraProperties).build();
    // Install the TPCH plugin for test data (not in Delta format)
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    Path dataDir = queryRunner.getCoordinator().getBaseDataDir().resolve("delta_metadata");
    Path catalogDir = dataDir.getParent().resolve("catalog");
    // Install a Delta connector catalog
    queryRunner.installPlugin(new DeltaPlugin());
    Map<String, String> deltaProperties = ImmutableMap.<String, String>builder().put("hive.metastore", "file").put("hive.metastore.catalog.dir", catalogDir.toFile().toURI().toString()).build();
    queryRunner.createCatalog(DELTA_CATALOG, "delta", deltaProperties);
    // Install a Hive connector catalog that uses the same metastore as Delta
    // This catalog will be used to create tables in metastore as the Delta connector doesn't
    // support creating tables yet.
    queryRunner.installPlugin(new HivePlugin("hive"));
    Map<String, String> hiveProperties = ImmutableMap.<String, String>builder().put("hive.metastore", "file").put("hive.metastore.catalog.dir", catalogDir.toFile().toURI().toString()).put("hive.allow-drop-table", "true").put("hive.security", "legacy").build();
    queryRunner.createCatalog(HIVE_CATALOG, "hive", hiveProperties);
    queryRunner.execute(format("CREATE SCHEMA %s.%s", HIVE_CATALOG, DELTA_SCHEMA));
    return queryRunner;
}
Also used : Path(java.nio.file.Path) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) HivePlugin(com.facebook.presto.hive.HivePlugin) Session(com.facebook.presto.Session)

Aggregations

DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)111 Test (org.testng.annotations.Test)36 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)33 Session (com.facebook.presto.Session)26 QueryId (com.facebook.presto.spi.QueryId)19 Logger (com.facebook.airlift.log.Logger)15 TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)14 MaterializedResult (com.facebook.presto.testing.MaterializedResult)13 QueryRunner (com.facebook.presto.testing.QueryRunner)13 ImmutableMap (com.google.common.collect.ImmutableMap)10 ResourceGroupManagerPlugin (com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin)9 ArrayList (java.util.ArrayList)8 File (java.io.File)7 BeforeClass (org.testng.annotations.BeforeClass)7 JettyHttpClient (com.facebook.airlift.http.client.jetty.JettyHttpClient)6 FileResourceGroupConfigurationManagerFactory (com.facebook.presto.resourceGroups.FileResourceGroupConfigurationManagerFactory)6 H2ResourceGroupsDao (com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao)6 Path (java.nio.file.Path)6 Future (java.util.concurrent.Future)6 MetastoreContext (com.facebook.presto.hive.metastore.MetastoreContext)5