Search in sources :

Example 1 with FileBasedSeedStoreFactory

use of io.hetu.core.seedstore.filebased.FileBasedSeedStoreFactory in project hetu-core by openlookeng.

the class TestHazelcastStateStoreFactory method testUnableGetSeeds.

/**
 * Test what happens to hazelcast factory if no seeds get from seed store
 *
 * @throws IOException IOException thrown if seedStore read write errors happen
 */
@Test(expectedExceptions = RuntimeException.class)
public void testUnableGetSeeds() throws IOException {
    HazelcastStateStoreFactory factory = new HazelcastStateStoreFactory();
    assertEquals(factory.getName(), HAZELCAST);
    SeedStoreFactory seedStoreFactory = new FileBasedSeedStoreFactory();
    assertEquals(seedStoreFactory.getName(), "filebased");
    Map<String, String> properties = new HashMap<>(0);
    properties.put(STATE_STORE_CLUSTER_CONFIG_NAME, TEST_CLUSTER_NAME);
    properties.put(DISCOVERY_MODE_CONFIG_NAME, DISCOVERY_MODE_TCPIP);
    SeedStore seedStore = mock(SeedStore.class);
    when(seedStore.get()).thenReturn(ImmutableList.of());
    factory.create(TEST_STATE_STORE_NAME, seedStore, properties);
}
Also used : HashMap(java.util.HashMap) SeedStore(io.prestosql.spi.seedstore.SeedStore) SeedStoreFactory(io.prestosql.spi.seedstore.SeedStoreFactory) FileBasedSeedStoreFactory(io.hetu.core.seedstore.filebased.FileBasedSeedStoreFactory) FileBasedSeedStoreFactory(io.hetu.core.seedstore.filebased.FileBasedSeedStoreFactory) Test(org.testng.annotations.Test)

Example 2 with FileBasedSeedStoreFactory

use of io.hetu.core.seedstore.filebased.FileBasedSeedStoreFactory in project hetu-core by openlookeng.

the class TestHazelcastStateStoreFactory method testTcpipCreate.

/**
 * Test state store creation with tcp-ip mode
 *
 * @throws IOException IOException thrown if seedStore read write errors happen
 */
@Test
public void testTcpipCreate() throws IOException {
    HazelcastStateStoreFactory factory = new HazelcastStateStoreFactory();
    assertEquals(factory.getName(), HAZELCAST);
    SeedStoreFactory seedStoreFactory = new FileBasedSeedStoreFactory();
    assertEquals(seedStoreFactory.getName(), "filebased");
    Map<String, String> properties = new HashMap<>(0);
    properties.put(STATE_STORE_CLUSTER_CONFIG_NAME, TEST_CLUSTER_NAME);
    properties.put(DISCOVERY_MODE_CONFIG_NAME, DISCOVERY_MODE_TCPIP);
    SeedStore seedStore = mock(SeedStore.class);
    Seed seed = new FileBasedSeed(MEMBER_ADDRESS, 0);
    when(seedStore.get()).thenReturn(ImmutableList.of(seed));
    setupHazelcastInstance();
    StateStore stateStore = factory.create(TEST_STATE_STORE_NAME, seedStore, properties);
    assertEquals(stateStore.getName(), TEST_STATE_STORE_NAME);
    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 : FileBasedSeed(io.hetu.core.seedstore.filebased.FileBasedSeed) 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) Seed(io.prestosql.spi.seedstore.Seed) FileBasedSeed(io.hetu.core.seedstore.filebased.FileBasedSeed) SeedStore(io.prestosql.spi.seedstore.SeedStore) FileBasedSeedStoreFactory(io.hetu.core.seedstore.filebased.FileBasedSeedStoreFactory) Test(org.testng.annotations.Test)

Example 3 with FileBasedSeedStoreFactory

use of io.hetu.core.seedstore.filebased.FileBasedSeedStoreFactory 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)

Aggregations

FileBasedSeedStoreFactory (io.hetu.core.seedstore.filebased.FileBasedSeedStoreFactory)3 SeedStoreFactory (io.prestosql.spi.seedstore.SeedStoreFactory)3 HashMap (java.util.HashMap)3 Test (org.testng.annotations.Test)3 SeedStore (io.prestosql.spi.seedstore.SeedStore)2 StateCollection (io.prestosql.spi.statestore.StateCollection)2 StateMap (io.prestosql.spi.statestore.StateMap)2 StateStore (io.prestosql.spi.statestore.StateStore)2 FileBasedSeed (io.hetu.core.seedstore.filebased.FileBasedSeed)1 Seed (io.prestosql.spi.seedstore.Seed)1 StateStoreBootstrapper (io.prestosql.spi.statestore.StateStoreBootstrapper)1