use of io.hetu.core.statestore.hazelcast.HazelcastStateStore 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);
}
Aggregations