Search in sources :

Example 36 with TestingPrestoServer

use of io.prestosql.server.testing.TestingPrestoServer in project hetu-core by openlookeng.

the class DistributedQueryRunnerWithStateStore method setupStateStore.

public void setupStateStore() throws Exception {
    int port = SslSocketUtil.getAvailablePort();
    for (TestingPrestoServer server : servers) {
        server.installPlugin(new StateStoreManagerPlugin());
        // State Store
        StateStoreLauncher launcher = server.getInstance(Key.get(StateStoreLauncher.class));
        if (launcher instanceof EmbeddedStateStoreLauncher) {
            Set<String> ips = Sets.newHashSet(Arrays.asList("127.0.0.1"));
            Map<String, String> stateStoreProperties = new HashMap<>();
            stateStoreProperties.put(DISCOVERY_PORT_CONFIG_NAME, port + "");
            stateStoreProperties.putIfAbsent(HazelcastConstants.DISCOVERY_MODE_CONFIG_NAME, HazelcastConstants.DISCOVERY_MODE_TCPIP);
            this.stateStores.add(((EmbeddedStateStoreLauncher) launcher).launchStateStore(ips, stateStoreProperties));
        }
        launcher.launchStateStore();
        StateStoreProvider provider = server.getInstance(Key.get(StateStoreProvider.class));
        Seed seed = new FileBasedSeed("127.0.0.1:" + port, 0);
        SeedStore seedStore = new SeedStore() {

            @Override
            public Collection<Seed> add(Collection<Seed> seeds) throws IOException {
                return null;
            }

            @Override
            public Collection<Seed> get() throws IOException {
                return new ArrayList<>((Arrays.asList(seed)));
            }

            @Override
            public Collection<Seed> remove(Collection<Seed> seeds) throws IOException {
                return null;
            }

            @Override
            public Seed create(Map<String, String> properties) {
                return null;
            }

            @Override
            public String getName() {
                return null;
            }

            @Override
            public void setName(String name) {
            }
        };
        server.getInstance(Key.get(SeedStoreManager.class)).setSeedStore(SeedStoreSubType.HAZELCAST, seedStore);
        if (provider instanceof LocalStateStoreProvider) {
            Map<String, String> stateStoreProperties = new HashMap<>();
            stateStoreProperties.putIfAbsent(HazelcastConstants.DISCOVERY_MODE_CONFIG_NAME, HazelcastConstants.DISCOVERY_MODE_TCPIP);
            stateStoreProperties.put(DISCOVERY_PORT_CONFIG_NAME, port + "");
            ((LocalStateStoreProvider) provider).setStateStore("hazelcast", stateStoreProperties);
            ((LocalStateStoreProvider) provider).createStateCollections();
        }
        provider.loadStateStore();
        this.providers.add(provider);
    }
}
Also used : EmbeddedStateStoreLauncher(io.prestosql.statestore.EmbeddedStateStoreLauncher) FileBasedSeed(io.hetu.core.seedstore.filebased.FileBasedSeed) HashMap(java.util.HashMap) TestingPrestoServer(io.prestosql.server.testing.TestingPrestoServer) ArrayList(java.util.ArrayList) LocalStateStoreProvider(io.prestosql.statestore.LocalStateStoreProvider) StateStoreProvider(io.prestosql.statestore.StateStoreProvider) LocalStateStoreProvider(io.prestosql.statestore.LocalStateStoreProvider) FileBasedSeed(io.hetu.core.seedstore.filebased.FileBasedSeed) Seed(io.prestosql.spi.seedstore.Seed) StateStoreLauncher(io.prestosql.statestore.StateStoreLauncher) EmbeddedStateStoreLauncher(io.prestosql.statestore.EmbeddedStateStoreLauncher) SeedStore(io.prestosql.spi.seedstore.SeedStore) Collection(java.util.Collection) StateStoreManagerPlugin(io.hetu.core.statestore.StateStoreManagerPlugin) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

TestingPrestoServer (io.prestosql.server.testing.TestingPrestoServer)36 BeforeClass (org.testng.annotations.BeforeClass)17 Test (org.testng.annotations.Test)11 TpchPlugin (io.prestosql.plugin.tpch.TpchPlugin)8 ArrayList (java.util.ArrayList)8 BlackHolePlugin (io.prestosql.plugin.blackhole.BlackHolePlugin)5 BasicQueryInfo (io.prestosql.server.BasicQueryInfo)5 DistributedQueryRunner (io.prestosql.tests.DistributedQueryRunner)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 JettyHttpClient (io.airlift.http.client.jetty.JettyHttpClient)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 QueryId (io.prestosql.spi.QueryId)3 CatalogName (io.prestosql.spi.connector.CatalogName)3 HashMap (java.util.HashMap)3 Future (java.util.concurrent.Future)3 QueryManager (io.prestosql.execution.QueryManager)2 TaskManager (io.prestosql.execution.TaskManager)2 NodeStateChangeHandler (io.prestosql.server.NodeStateChangeHandler)2 File (java.io.File)2 URL (java.net.URL)2