use of io.prestosql.spi.seedstore.SeedStore in project hetu-core by openlookeng.
the class SeedStoreManager method removeSeed.
/**
* remove seed from seed store
*
* @param seedLocation
* @return a collection of seeds in the seed store
* @throws IOException
*/
public Collection<Seed> removeSeed(SeedStoreSubType subType, String seedLocation) throws IOException {
Collection<Seed> seeds = new HashSet<>();
SeedStore seedStore = getSeedStore(subType);
if (seedStore == null) {
throw new PrestoException(SEED_STORE_FAILURE, "Seed store is null");
}
refreshableSeedsMap.remove(seedLocation);
Optional<Seed> seedOptional;
if (subType == SeedStoreSubType.ON_YARN) {
seedOptional = seedStore.get().stream().filter(s -> {
return s.getLocation().equals(seedLocation) || s.getUniqueInstanceId().equals(seedLocation);
}).findFirst();
} else {
seedOptional = seedStore.get().stream().filter(s -> s.getLocation().equals(seedLocation)).findFirst();
}
if (seedOptional.isPresent()) {
seeds = seedStore.remove(Lists.newArrayList(seedOptional.get()));
LOG.debug("Seed=%s removed from seed store", seedLocation);
}
return seeds;
}
use of io.prestosql.spi.seedstore.SeedStore in project hetu-core by openlookeng.
the class TestSeedStoreManager method testLoadAndGetSeedStore.
@Test
public void testLoadAndGetSeedStore() throws IOException {
seedStoreManager.loadSeedStore();
SeedStore returned = seedStoreManager.getSeedStore(SeedStoreSubType.HAZELCAST);
}
use of io.prestosql.spi.seedstore.SeedStore in project hetu-core by openlookeng.
the class TestSeedStoreManager method setUp.
@BeforeMethod
private void setUp() throws IOException {
FileSystemClientManager mockFileSystemClientManager = mock(FileSystemClientManager.class);
when(mockFileSystemClientManager.getFileSystemClient(anyString(), any())).thenReturn(null);
seedStoreManager = new SeedStoreManager(mockFileSystemClientManager);
SeedStore mockSeedStore = new MockSeedStore();
mockSeedStore.add(new HashSet<>());
SeedStoreFactory mockSeedStoreFactory = mock(SeedStoreFactory.class);
when(mockSeedStoreFactory.getName()).thenReturn("filebased");
when(mockSeedStoreFactory.create(any(String.class), any(SeedStoreSubType.class), any(HetuFileSystemClient.class), any(Map.class))).thenReturn(mockSeedStore);
seedStoreManager.addSeedStoreFactory(mockSeedStoreFactory);
}
use of io.prestosql.spi.seedstore.SeedStore in project hetu-core by openlookeng.
the class TestDynamicFilterSourceOperator method prepareConfigFiles.
@BeforeTest
private void prepareConfigFiles() throws Exception {
File launcherConfigFile = new File(STATE_STORE_CONFIGURATION_PATH);
if (launcherConfigFile.exists()) {
launcherConfigFile.delete();
}
launcherConfigFile.createNewFile();
FileWriter configWriter = new FileWriter(STATE_STORE_CONFIGURATION_PATH);
configWriter.write("state-store.type=hazelcast\n" + "state-store.name=test\n" + "state-store.cluster=test-cluster\n" + "hazelcast.discovery.mode=tcp-ip\n" + "hazelcast.discovery.port=7980\n");
configWriter.close();
Set<Seed> seeds = new HashSet<>();
SeedStore mockSeedStore = mock(SeedStore.class);
Seed mockSeed = mock(Seed.class);
seeds.add(mockSeed);
SeedStoreManager mockSeedStoreManager = mock(SeedStoreManager.class);
when(mockSeedStoreManager.getSeedStore(SeedStoreSubType.HAZELCAST)).thenReturn(mockSeedStore);
when(mockSeed.getLocation()).thenReturn("127.0.0.1:6991");
when(mockSeedStore.get()).thenReturn(seeds);
StateStoreFactory factory = new HazelcastStateStoreFactory();
stateStoreProvider = new LocalStateStoreProvider(mockSeedStoreManager);
stateStoreProvider.addStateStoreFactory(factory);
createStateStoreCluster("6991");
stateStoreProvider.loadStateStore();
}
use of io.prestosql.spi.seedstore.SeedStore 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);
}
Aggregations