Search in sources :

Example 1 with HazelcastStateStoreBootstrapper

use of io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper in project hetu-core by openlookeng.

the class TestStateStoreLauncherAndProvider method setupSecondInstance.

// A second instance is setup using bootstrapper directly to manually configure port
// Using launcher to launch will cause it to read from config file (same port as first member)
private StateStore setupSecondInstance() {
    Map<String, String> config = new HashMap<>();
    config.put("hazelcast.discovery.mode", "tcp-ip");
    config.put("state-store.cluster", "test-cluster");
    config.put(DISCOVERY_PORT_CONFIG_NAME, PORT2);
    StateStoreBootstrapper bootstrapper = new HazelcastStateStoreBootstrapper();
    return bootstrapper.bootstrap(ImmutableSet.of(LOCALHOST + ":" + PORT1, LOCALHOST + ":" + PORT2), config);
}
Also used : HashMap(java.util.HashMap) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) StateStoreBootstrapper(io.prestosql.spi.statestore.StateStoreBootstrapper)

Example 2 with HazelcastStateStoreBootstrapper

use of io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper in project hetu-core by openlookeng.

the class TestStateStoreLauncherAndProvider method createStateStoreCluster.

private StateStore createStateStoreCluster(String port) {
    Map<String, String> config = new HashMap<>();
    config.put("hazelcast.discovery.mode", "tcp-ip");
    config.put("state-store.cluster", "test-cluster");
    config.put(DISCOVERY_PORT_CONFIG_NAME, port);
    StateStoreBootstrapper bootstrapper = new HazelcastStateStoreBootstrapper();
    return bootstrapper.bootstrap(ImmutableSet.of(LOCALHOST + ":" + port), config);
}
Also used : HashMap(java.util.HashMap) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) StateStoreBootstrapper(io.prestosql.spi.statestore.StateStoreBootstrapper)

Example 3 with HazelcastStateStoreBootstrapper

use of io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper in project hetu-core by openlookeng.

the class TestDynamicFilterSourceOperator method createStateStoreCluster.

private StateStore createStateStoreCluster(String port) {
    Map<String, String> config = new HashMap<>();
    config.put("hazelcast.discovery.mode", "tcp-ip");
    config.put("state-store.cluster", "test-cluster");
    config.put(DISCOVERY_PORT_CONFIG_NAME, port);
    StateStoreBootstrapper bootstrapper = new HazelcastStateStoreBootstrapper();
    return bootstrapper.bootstrap(ImmutableSet.of("127.0.0.1:" + port), config);
}
Also used : HashMap(java.util.HashMap) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) StateStoreBootstrapper(io.prestosql.spi.statestore.StateStoreBootstrapper)

Example 4 with HazelcastStateStoreBootstrapper

use of io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper in project hetu-core by openlookeng.

the class TestHetuMetastoreGlobalCache method createStateStoreCluster.

private StateStore createStateStoreCluster(String port) {
    Map<String, String> config = new HashMap<>();
    config.put("hazelcast.discovery.mode", "tcp-ip");
    config.put("state-store.cluster", "test-cluster");
    config.put(DISCOVERY_PORT_CONFIG_NAME, port);
    StateStoreBootstrapper bootstrapper = new HazelcastStateStoreBootstrapper();
    return bootstrapper.bootstrap(ImmutableSet.of(LOCALHOST + ":" + port), config);
}
Also used : HashMap(java.util.HashMap) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) StateStoreBootstrapper(io.prestosql.spi.statestore.StateStoreBootstrapper)

Example 5 with HazelcastStateStoreBootstrapper

use of io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper in project hetu-core by openlookeng.

the class TestStateStoreLauncherAndProvider method testLaunchAndFailure.

// Test Launcher
@Test
public void testLaunchAndFailure() throws Exception {
    Set<Seed> seeds = new HashSet<>();
    SeedStore mockSeedStore = mock(SeedStore.class);
    Seed mockSeed1 = mock(Seed.class);
    Seed mockSeed2 = mock(Seed.class);
    seeds.add(mockSeed1);
    seeds.add(mockSeed2);
    when(mockSeed1.getLocation()).thenReturn(LOCALHOST + ":" + PORT1);
    when(mockSeed2.getLocation()).thenReturn(LOCALHOST + ":" + PORT2);
    when(mockSeedStore.get()).thenReturn(seeds);
    SeedStoreManager mockSeedStoreManager = mock(SeedStoreManager.class);
    when(mockSeedStoreManager.getSeedStore(SeedStoreSubType.HAZELCAST)).thenReturn(mockSeedStore);
    when(mockSeedStoreManager.addSeed(SeedStoreSubType.HAZELCAST, LOCALHOST, true)).thenReturn(seeds);
    when(mockSeedStoreManager.getFileSystemClient()).thenReturn(new HetuLocalFileSystemClient(new LocalConfig(new Properties()), Paths.get("/")));
    InternalCommunicationConfig mockInternalCommunicationConfig = mock(InternalCommunicationConfig.class);
    HttpServerInfo mockHttpServerInfo = mock(HttpServerInfo.class);
    when(mockHttpServerInfo.getHttpsUri()).thenReturn(new URI("https://" + LOCALHOST + ":" + PORT1));
    when(mockInternalCommunicationConfig.isHttpsRequired()).thenReturn(true);
    EmbeddedStateStoreLauncher launcher = new EmbeddedStateStoreLauncher(mockSeedStoreManager, mockInternalCommunicationConfig, mockHttpServerInfo, new HetuConfig());
    StateStoreBootstrapper bootstrapper = new HazelcastStateStoreBootstrapper();
    launcher.addStateStoreBootstrapper(bootstrapper);
    launcher.launchStateStore();
    StateStore second = setupSecondInstance();
    // mock "remove" second instance from cluster (delete from seed store)
    seeds.remove(mockSeed2);
    when(mockSeed1.getLocation()).thenReturn(LOCALHOST + ":" + PORT1);
    when(mockSeedStoreManager.addSeed(SeedStoreSubType.HAZELCAST, LOCALHOST, true)).thenReturn(seeds);
    ((HazelcastStateStore) second).shutdown();
    // Allow the first node to handle failure
    Thread.sleep(3000L);
}
Also used : HazelcastStateStore(io.hetu.core.statestore.hazelcast.HazelcastStateStore) LocalConfig(io.hetu.core.filesystem.LocalConfig) StateStore(io.prestosql.spi.statestore.StateStore) HazelcastStateStore(io.hetu.core.statestore.hazelcast.HazelcastStateStore) Properties(java.util.Properties) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) URI(java.net.URI) HetuConfig(io.prestosql.utils.HetuConfig) SeedStoreManager(io.prestosql.seedstore.SeedStoreManager) InternalCommunicationConfig(io.prestosql.server.InternalCommunicationConfig) Seed(io.prestosql.spi.seedstore.Seed) SeedStore(io.prestosql.spi.seedstore.SeedStore) HetuLocalFileSystemClient(io.hetu.core.filesystem.HetuLocalFileSystemClient) HttpServerInfo(io.airlift.http.server.HttpServerInfo) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) StateStoreBootstrapper(io.prestosql.spi.statestore.StateStoreBootstrapper) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Aggregations

HazelcastStateStoreBootstrapper (io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper)5 StateStoreBootstrapper (io.prestosql.spi.statestore.StateStoreBootstrapper)5 HashMap (java.util.HashMap)4 HttpServerInfo (io.airlift.http.server.HttpServerInfo)1 HetuLocalFileSystemClient (io.hetu.core.filesystem.HetuLocalFileSystemClient)1 LocalConfig (io.hetu.core.filesystem.LocalConfig)1 HazelcastStateStore (io.hetu.core.statestore.hazelcast.HazelcastStateStore)1 SeedStoreManager (io.prestosql.seedstore.SeedStoreManager)1 InternalCommunicationConfig (io.prestosql.server.InternalCommunicationConfig)1 Seed (io.prestosql.spi.seedstore.Seed)1 SeedStore (io.prestosql.spi.seedstore.SeedStore)1 StateStore (io.prestosql.spi.statestore.StateStore)1 HetuConfig (io.prestosql.utils.HetuConfig)1 URI (java.net.URI)1 HashSet (java.util.HashSet)1 Properties (java.util.Properties)1 AfterTest (org.testng.annotations.AfterTest)1 BeforeTest (org.testng.annotations.BeforeTest)1 Test (org.testng.annotations.Test)1