Search in sources :

Example 1 with DriftServer

use of com.facebook.drift.server.DriftServer in project presto by prestodb.

the class ThriftQueryRunner method createThriftQueryRunner.

public static QueryRunner createThriftQueryRunner(int thriftServers, int nodeCount, boolean enableIndexJoin, Map<String, String> properties) throws Exception {
    List<DriftServer> servers = null;
    DistributedQueryRunner runner = null;
    try {
        servers = startThriftServers(thriftServers, enableIndexJoin);
        runner = createThriftQueryRunnerInternal(servers, nodeCount, properties);
        return new ThriftQueryRunnerWithServers(runner, servers);
    } catch (Throwable t) {
        closeQuietly(runner);
        // runner might be null, so closing servers explicitly
        if (servers != null) {
            for (DriftServer server : servers) {
                server.shutdown();
            }
        }
        throw t;
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) DriftServer(com.facebook.drift.server.DriftServer)

Example 2 with DriftServer

use of com.facebook.drift.server.DriftServer in project presto by prestodb.

the class ThriftQueryRunner method startThriftServers.

private static List<DriftServer> startThriftServers(int thriftServers, boolean enableIndexJoin) {
    List<DriftServer> servers = new ArrayList<>(thriftServers);
    for (int i = 0; i < thriftServers; i++) {
        ThriftTpchService service = enableIndexJoin ? new ThriftIndexedTpchService() : new ThriftTpchService();
        DriftServer server = new DriftServer(new DriftNettyServerTransportFactory(new DriftNettyServerConfig()), CODEC_MANAGER, new NullMethodInvocationStatsFactory(), ImmutableSet.of(new DriftService(service)), ImmutableSet.of());
        server.start();
        servers.add(server);
    }
    return servers;
}
Also used : ThriftTpchService(com.facebook.presto.connector.thrift.server.ThriftTpchService) DriftNettyServerConfig(com.facebook.drift.transport.netty.server.DriftNettyServerConfig) DriftService(com.facebook.drift.server.DriftService) ThriftIndexedTpchService(com.facebook.presto.connector.thrift.server.ThriftIndexedTpchService) ArrayList(java.util.ArrayList) NullMethodInvocationStatsFactory(com.facebook.drift.server.stats.NullMethodInvocationStatsFactory) DriftServer(com.facebook.drift.server.DriftServer) DriftNettyServerTransportFactory(com.facebook.drift.transport.netty.server.DriftNettyServerTransportFactory)

Example 3 with DriftServer

use of com.facebook.drift.server.DriftServer in project presto by prestodb.

the class ThriftQueryRunner method createThriftQueryRunnerInternal.

private static DistributedQueryRunner createThriftQueryRunnerInternal(List<DriftServer> servers, int nodeCount, Map<String, String> properties) throws Exception {
    String addresses = servers.stream().map(server -> "localhost:" + driftServerPort(server)).collect(joining(","));
    Session defaultSession = testSessionBuilder().setCatalog("thrift").setSchema("tiny").build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(defaultSession).setNodeCount(nodeCount).setExtraProperties(properties).build();
    queryRunner.installPlugin(new ThriftPlugin());
    Map<String, String> connectorProperties = ImmutableMap.<String, String>builder().put("presto.thrift.client.addresses", addresses).put("presto.thrift.client.connect-timeout", "30s").put("presto-thrift.lookup-requests-concurrency", "2").build();
    queryRunner.createCatalog("thrift", "presto-thrift", connectorProperties);
    return queryRunner;
}
Also used : Logger(com.facebook.airlift.log.Logger) ThriftTpchService(com.facebook.presto.connector.thrift.server.ThriftTpchService) DriftServer(com.facebook.drift.server.DriftServer) ThriftCodecManager(com.facebook.drift.codec.ThriftCodecManager) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) QueryRunner(com.facebook.presto.testing.QueryRunner) ConnectorPlanOptimizerManager(com.facebook.presto.sql.planner.ConnectorPlanOptimizerManager) DriftNettyServerTransport(com.facebook.drift.transport.netty.server.DriftNettyServerTransport) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) ArrayList(java.util.ArrayList) StatsCalculator(com.facebook.presto.cost.StatsCalculator) ImmutableList(com.google.common.collect.ImmutableList) ThriftIndexedTpchService(com.facebook.presto.connector.thrift.server.ThriftIndexedTpchService) PageSourceManager(com.facebook.presto.split.PageSourceManager) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) QualifiedObjectName(com.facebook.presto.common.QualifiedObjectName) EventListener(com.facebook.presto.spi.eventlistener.EventListener) TransactionManager(com.facebook.presto.transaction.TransactionManager) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Session(com.facebook.presto.Session) NullMethodInvocationStatsFactory(com.facebook.drift.server.stats.NullMethodInvocationStatsFactory) DriftNettyServerTransportFactory(com.facebook.drift.transport.netty.server.DriftNettyServerTransportFactory) SplitManager(com.facebook.presto.split.SplitManager) TestingSession.testSessionBuilder(com.facebook.presto.testing.TestingSession.testSessionBuilder) Closeables.closeQuietly(com.facebook.airlift.testing.Closeables.closeQuietly) Plugin(com.facebook.presto.spi.Plugin) Collectors.joining(java.util.stream.Collectors.joining) DriftService(com.facebook.drift.server.DriftService) MaterializedResult(com.facebook.presto.testing.MaterializedResult) List(java.util.List) Lock(java.util.concurrent.locks.Lock) ThriftPlugin(com.facebook.presto.connector.thrift.ThriftPlugin) TestingAccessControlManager(com.facebook.presto.testing.TestingAccessControlManager) Logging(com.facebook.airlift.log.Logging) Optional(java.util.Optional) DriftNettyServerConfig(com.facebook.drift.transport.netty.server.DriftNettyServerConfig) Metadata(com.facebook.presto.metadata.Metadata) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) ThriftPlugin(com.facebook.presto.connector.thrift.ThriftPlugin) Session(com.facebook.presto.Session)

Aggregations

DriftServer (com.facebook.drift.server.DriftServer)3 DriftService (com.facebook.drift.server.DriftService)2 NullMethodInvocationStatsFactory (com.facebook.drift.server.stats.NullMethodInvocationStatsFactory)2 DriftNettyServerConfig (com.facebook.drift.transport.netty.server.DriftNettyServerConfig)2 DriftNettyServerTransportFactory (com.facebook.drift.transport.netty.server.DriftNettyServerTransportFactory)2 ThriftIndexedTpchService (com.facebook.presto.connector.thrift.server.ThriftIndexedTpchService)2 ThriftTpchService (com.facebook.presto.connector.thrift.server.ThriftTpchService)2 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)2 ArrayList (java.util.ArrayList)2 Logger (com.facebook.airlift.log.Logger)1 Logging (com.facebook.airlift.log.Logging)1 Closeables.closeQuietly (com.facebook.airlift.testing.Closeables.closeQuietly)1 ThriftCodecManager (com.facebook.drift.codec.ThriftCodecManager)1 DriftNettyServerTransport (com.facebook.drift.transport.netty.server.DriftNettyServerTransport)1 Session (com.facebook.presto.Session)1 QualifiedObjectName (com.facebook.presto.common.QualifiedObjectName)1 ThriftPlugin (com.facebook.presto.connector.thrift.ThriftPlugin)1 StatsCalculator (com.facebook.presto.cost.StatsCalculator)1 Metadata (com.facebook.presto.metadata.Metadata)1 TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)1