Search in sources :

Example 36 with StateStore

use of io.prestosql.spi.statestore.StateStore in project hetu-core by openlookeng.

the class TestHazelcastStateStoreBootstrapper method testBootstrap.

/**
 * Test Bootstrap
 */
@Test
public void testBootstrap() {
    Map<String, String> config = new HashMap<>(0);
    config.put(DISCOVERY_MODE_CONFIG_NAME, "tcp-ip");
    config.put("state-store.cluster", "cluster-" + UUID.randomUUID());
    config.put("hazelcast.cp-system.member-count", "3");
    config.put(DISCOVERY_PORT_CONFIG_NAME, PORT);
    StateStoreBootstrapper bootstrapper = new HazelcastStateStoreBootstrapper();
    StateStore stateStore = bootstrapper.bootstrap(ImmutableSet.of(LOCALHOST), config);
    assertTrue(stateStore instanceof HazelcastStateStore);
    ((HazelcastStateStore) stateStore).shutdown();
}
Also used : HashMap(java.util.HashMap) StateStore(io.prestosql.spi.statestore.StateStore) StateStoreBootstrapper(io.prestosql.spi.statestore.StateStoreBootstrapper) Test(org.testng.annotations.Test)

Example 37 with StateStore

use of io.prestosql.spi.statestore.StateStore in project hetu-core by openlookeng.

the class TestHazelcastStateStoreFactory method testTcpipCreateWithStaticSeeds.

/**
 * Test state store creation with tcp-ip with static seeds configured
 */
@Test
public void testTcpipCreateWithStaticSeeds() {
    HazelcastStateStoreFactory factory = new HazelcastStateStoreFactory();
    assertEquals(factory.getName(), HAZELCAST);
    SeedStoreFactory seedStoreFactory = new FileBasedSeedStoreFactory();
    assertEquals(seedStoreFactory.getName(), "filebased");
    // bootstrap state store with static seeds
    Map<String, String> config = new HashMap<>(0);
    config.put(DISCOVERY_MODE_CONFIG_NAME, DISCOVERY_MODE_TCPIP);
    config.put(STATE_STORE_CLUSTER_CONFIG_NAME, "static-seed-cluster");
    config.put(DISCOVERY_PORT_CONFIG_NAME, PORT2);
    config.put(DISCOVERY_TCPIP_SEEDS, MEMBER_ADDRESS2);
    StateStoreBootstrapper bootstrapper = new HazelcastStateStoreBootstrapper();
    bootstrapper.bootstrap(ImmutableSet.of(MEMBER_ADDRESS2), config);
    // create state store client
    String stateStoreName = "static-seed-state-store";
    StateStore stateStore = factory.create(stateStoreName, null, config);
    assertEquals(stateStore.getName(), stateStoreName);
    StateCollection collection = stateStore.createStateCollection("test", StateCollection.Type.MAP);
    ((StateMap<String, String>) collection).put(TEST_KEY, TEST_VALUE);
    assertEquals(collection.size(), 1);
    assertEquals(((StateMap<String, String>) collection).get(TEST_KEY), TEST_VALUE);
    ((HazelcastStateStore) stateStore).shutdown();
}
Also used : HashMap(java.util.HashMap) StateCollection(io.prestosql.spi.statestore.StateCollection) StateMap(io.prestosql.spi.statestore.StateMap) StateStore(io.prestosql.spi.statestore.StateStore) SeedStoreFactory(io.prestosql.spi.seedstore.SeedStoreFactory) FileBasedSeedStoreFactory(io.hetu.core.seedstore.filebased.FileBasedSeedStoreFactory) FileBasedSeedStoreFactory(io.hetu.core.seedstore.filebased.FileBasedSeedStoreFactory) StateStoreBootstrapper(io.prestosql.spi.statestore.StateStoreBootstrapper) Test(org.testng.annotations.Test)

Example 38 with StateStore

use of io.prestosql.spi.statestore.StateStore in project hetu-core by openlookeng.

the class PagePublisherQueryManager method saveDynamicFilter.

public synchronized void saveDynamicFilter(String globalQueryId, Map<String, byte[]> bloomFilters) {
    PagePublisherQueryRunner queryRunner = this.queryRunners.get(globalQueryId);
    StateStore stateStore = this.stateStoreProvider.getStateStore();
    if (queryRunner != null && stateStore != null) {
        if (this.stateStoreProvider.getStateStore() == null) {
            return;
        }
        String collectionName = queryRunner.getQueryId().getId() + CROSS_REGION_DYNAMIC_FILTER_COLLECTION;
        synchronized (queryRunner) {
            if (queryRunner.isDone() || queryRunner.isExpired()) {
                return;
            }
            StateMap map = (StateMap<String, Map<String, byte[]>>) stateStore.getOrCreateStateCollection(CROSS_REGION_DYNAMIC_FILTERS, StateCollection.Type.MAP);
            map.put(collectionName, bloomFilters);
        }
    }
}
Also used : StateMap(io.prestosql.spi.statestore.StateMap) StateStore(io.prestosql.spi.statestore.StateStore)

Example 39 with StateStore

use of io.prestosql.spi.statestore.StateStore in project hetu-core by openlookeng.

the class TestDynamicFilterServiceWithBloomFilter method setUp.

// setup for test provider
@BeforeTest
private void setUp() {
    filterId = "df1";
    session = testSessionBuilder().setQueryId(QueryId.valueOf("qq1")).setSystemProperty(DYNAMIC_FILTERING_DATA_TYPE, "BLOOM_FILTER").build();
    StateStore stateStore = setupMockStateStore(new HashMap<>(), new HashMap<>(), new HashSet<>(), new HashSet<>(), session.getQueryId().toString(), filterId);
    stateStoreProvider = mock(StateStoreProvider.class);
    when(stateStoreProvider.getStateStore()).thenReturn(stateStore);
    dynamicFilterService = new DynamicFilterService(stateStoreProvider);
    dynamicFilterService.start();
}
Also used : StateStore(io.prestosql.spi.statestore.StateStore) TestDynamicFilterUtil.setupMockStateStore(io.prestosql.utils.TestDynamicFilterUtil.setupMockStateStore) DynamicFilterService(io.prestosql.dynamicfilter.DynamicFilterService) StateStoreProvider(io.prestosql.statestore.StateStoreProvider) BeforeTest(org.testng.annotations.BeforeTest)

Example 40 with StateStore

use of io.prestosql.spi.statestore.StateStore in project hetu-core by openlookeng.

the class TestDynamicFilterServiceWithHashSet method setUpHashSet.

@BeforeTest
private void setUpHashSet() {
    filterId = "df2";
    session = testSessionBuilder().setQueryId(QueryId.valueOf("qq2")).setSystemProperty(DYNAMIC_FILTERING_DATA_TYPE, "HASHSET").build();
    StateStore stateStore = setupMockStateStore(new HashMap<>(), new HashMap<>(), new HashSet<>(), new HashSet<>(), session.getQueryId().toString(), filterId);
    stateStoreProvider = mock(StateStoreProvider.class);
    when(stateStoreProvider.getStateStore()).thenReturn(stateStore);
    dynamicFilterService = new DynamicFilterService(stateStoreProvider);
    dynamicFilterService.start();
}
Also used : StateStore(io.prestosql.spi.statestore.StateStore) TestDynamicFilterUtil.setupMockStateStore(io.prestosql.utils.TestDynamicFilterUtil.setupMockStateStore) DynamicFilterService(io.prestosql.dynamicfilter.DynamicFilterService) StateStoreProvider(io.prestosql.statestore.StateStoreProvider) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

StateStore (io.prestosql.spi.statestore.StateStore)40 StateMap (io.prestosql.spi.statestore.StateMap)16 HashMap (java.util.HashMap)16 Test (org.testng.annotations.Test)14 StateStoreProvider (io.prestosql.statestore.StateStoreProvider)11 ImmutableMap (com.google.common.collect.ImmutableMap)8 StateCollection (io.prestosql.spi.statestore.StateCollection)8 IOException (java.io.IOException)8 HashSet (java.util.HashSet)8 PrestoException (io.prestosql.spi.PrestoException)7 Map (java.util.Map)7 Set (java.util.Set)6 Symbol (io.prestosql.spi.plan.Symbol)5 Optional (java.util.Optional)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 Duration (io.airlift.units.Duration)4 DynamicFilter (io.prestosql.spi.dynamicfilter.DynamicFilter)4 StateSet (io.prestosql.spi.statestore.StateSet)4 StateStoreBootstrapper (io.prestosql.spi.statestore.StateStoreBootstrapper)4 BeforeTest (org.testng.annotations.BeforeTest)4